Skip to content

Commit 22e57d2

Browse files
parser: fix parsing new attribute syntax in struct decl field (stage 1) (#19682)
1 parent b3b68e4 commit 22e57d2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

vlib/v/parser/struct.v

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
267267
// Comments after type (same line)
268268
prev_attrs := p.attrs
269269
p.attrs = []
270-
if p.tok.kind == .lsbr || p.tok.kind == .at {
270+
// TODO: remove once old syntax is no longer supported
271+
if p.tok.kind == .lsbr {
271272
p.inside_struct_attr_decl = true
272273
// attrs are stored in `p.attrs`
273274
p.attributes()
@@ -294,6 +295,17 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
294295
has_default_expr = true
295296
comments << p.eat_comments()
296297
}
298+
if p.tok.kind == .at {
299+
p.inside_struct_attr_decl = true
300+
// attrs are stored in `p.attrs`
301+
p.attributes()
302+
for fa in p.attrs {
303+
if fa.name == 'deprecated' {
304+
is_field_deprecated = true
305+
}
306+
}
307+
p.inside_struct_attr_decl = false
308+
}
297309
ast_fields << ast.StructField{
298310
name: field_name
299311
typ: typ

0 commit comments

Comments
 (0)