File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ // foo.v
2
+
3
+ [params]
4
+ fn hello(person struct { name string }) string {
5
+ if person.name == '' {
6
+ return 'Hello World!'
7
+ } else {
8
+ return 'Hello ${person.name}'
9
+ }
10
+ }
11
+
12
+ fn main() {
13
+ println(hello())
14
+ }
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
11
11
p.top_level_statement_start ()
12
12
// save attributes, they will be changed later in fields
13
13
attrs := p.attrs
14
- p.attrs = []
15
14
start_pos := p.tok.pos ()
16
15
mut is_pub := p.tok.kind == .key_pub
17
16
if is_pub {
@@ -267,6 +266,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
267
266
}
268
267
// Comments after type (same line)
269
268
comments << p.eat_comments ()
269
+ prev_attrs := p.attrs
270
+ p.attrs = []
270
271
if p.tok.kind == .lsbr {
271
272
p.inside_struct_attr_decl = true
272
273
// attrs are stored in `p.attrs`
@@ -331,7 +332,7 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
331
332
is_volatile: is_field_volatile
332
333
is_deprecated: is_field_deprecated
333
334
}
334
- p.attrs = []
335
+ p.attrs = prev_attrs
335
336
i++
336
337
}
337
338
p.top_level_statement_end ()
You can’t perform that action at this time.
0 commit comments