Skip to content

Commit a33ffce

Browse files
committed
parser: remove attributes from anonymous structs (fixes #18233)
1 parent c382f4d commit a33ffce

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

vlib/v/fmt/tests/struct_keep.vv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ struct KeepMultiLineDefaultExprsIndent {
4444
text: 'M5'
4545
}]
4646
}
47+
48+
[typedef]
49+
struct C.some_t {
50+
@type int
51+
data struct {}
52+
53+
}

vlib/v/parser/struct.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
387387
module_pos: module_pos
388388
language: language
389389
is_union: is_union
390-
attrs: attrs
390+
attrs: if is_anon { []ast.Attr{} } else { attrs } // anon structs can't have attributes
391391
end_comments: end_comments
392392
generic_types: generic_types
393393
embeds: embeds

0 commit comments

Comments
 (0)