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

v.fmt: keep comments after struct embeds

This commit is contained in:
Delyan Angelov
2021-06-18 18:42:05 +03:00
parent de384f1cc8
commit d56ae2d508
6 changed files with 142 additions and 151 deletions

View File

@@ -187,12 +187,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
// struct embedding
type_pos = p.tok.position()
typ = p.parse_type()
for p.tok.kind == .comment {
comments << p.comment()
if p.tok.kind == .rcbr {
break
}
}
ecomments := p.eat_comments({})
type_pos = type_pos.extend(p.prev_tok.position())
if !is_on_top {
p.error_with_pos('struct embedding must be declared at the beginning of the struct body',
@@ -214,6 +209,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
embeds << ast.Embed{
typ: typ
pos: type_pos
comments: ecomments
}
} else {
// struct field