mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
parser: fix parsing new attribute syntax in struct decl field (stage 1) (#19682)
This commit is contained in:
parent
b3b68e418d
commit
22e57d2f41
1 changed files with 13 additions and 1 deletions
|
@ -267,7 +267,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|
||||||
// Comments after type (same line)
|
// Comments after type (same line)
|
||||||
prev_attrs := p.attrs
|
prev_attrs := p.attrs
|
||||||
p.attrs = []
|
p.attrs = []
|
||||||
if p.tok.kind == .lsbr || p.tok.kind == .at {
|
// TODO: remove once old syntax is no longer supported
|
||||||
|
if p.tok.kind == .lsbr {
|
||||||
p.inside_struct_attr_decl = true
|
p.inside_struct_attr_decl = true
|
||||||
// attrs are stored in `p.attrs`
|
// attrs are stored in `p.attrs`
|
||||||
p.attributes()
|
p.attributes()
|
||||||
|
@ -294,6 +295,17 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|
||||||
has_default_expr = true
|
has_default_expr = true
|
||||||
comments << p.eat_comments()
|
comments << p.eat_comments()
|
||||||
}
|
}
|
||||||
|
if p.tok.kind == .at {
|
||||||
|
p.inside_struct_attr_decl = true
|
||||||
|
// attrs are stored in `p.attrs`
|
||||||
|
p.attributes()
|
||||||
|
for fa in p.attrs {
|
||||||
|
if fa.name == 'deprecated' {
|
||||||
|
is_field_deprecated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.inside_struct_attr_decl = false
|
||||||
|
}
|
||||||
ast_fields << ast.StructField{
|
ast_fields << ast.StructField{
|
||||||
name: field_name
|
name: field_name
|
||||||
typ: typ
|
typ: typ
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue