1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: fix bug of disappearing pub in struct decl (#8777)

This commit is contained in:
zakuro 2021-02-16 20:39:50 +09:00 committed by GitHub
parent 0bbc5a5c6a
commit 6813866141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View File

@ -7,6 +7,12 @@ struct User {
very_long_type_field2 very_loooooooong_type // long
}
struct FamousUser {
User
pub:
aka string
}
struct Foo {
field1 int // f1
field2 string // f2

View File

@ -7,6 +7,12 @@ struct User {
very_long_type_field2 very_loooooooong_type // long
}
struct FamousUser {
pub:
User
aka string
}
struct Foo {
field1 int // f1
field2 string // f2

View File

@ -121,7 +121,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
return ast.StructDecl{}
}
p.next()
pub_mut_pos = fields.len
pub_mut_pos = ast_fields.len
is_field_pub = true
is_field_mut = true
is_field_global = false
@ -130,7 +130,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
p.error('redefinition of `pub` section')
return ast.StructDecl{}
}
pub_pos = fields.len
pub_pos = ast_fields.len
is_field_pub = true
is_field_mut = false
is_field_global = false
@ -143,7 +143,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
}
p.next()
p.check(.colon)
mut_pos = fields.len
mut_pos = ast_fields.len
is_field_pub = false
is_field_mut = true
is_field_global = false
@ -154,7 +154,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
}
p.next()
p.check(.colon)
global_pos = fields.len
global_pos = ast_fields.len
is_field_pub = true
is_field_mut = true
is_field_global = true
@ -165,7 +165,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
}
p.next()
p.check(.colon)
module_pos = fields.len
module_pos = ast_fields.len
is_field_pub = false
is_field_mut = false
is_field_global = false
@ -320,11 +320,11 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
is_pub: is_pub
fields: ast_fields
pos: start_pos.extend_with_last_line(name_pos, last_line)
mut_pos: mut_pos - embeds.len
pub_pos: pub_pos - embeds.len
pub_mut_pos: pub_mut_pos - embeds.len
global_pos: global_pos - embeds.len
module_pos: module_pos - embeds.len
mut_pos: mut_pos
pub_pos: pub_pos
pub_mut_pos: pub_mut_pos
global_pos: global_pos
module_pos: module_pos
language: language
is_union: is_union
attrs: attrs