v / vlib / v2 / tests / syntax_ambiguities.v_
21 lines · 18 sloc · 716 bytes · 7519f915ffdafd3229fdd8912f7d78481614cb35
Raw
1// this file is just to test the parser so there may be a
2// bunch of stuff in here that does not really make sense
3
4const len_a = 6
5struct StructA {
6 // NOTE: ideally attributes would not use `[]`
7 // it would eliminate these issues completely.
8
9 // ambiguous: return `!` followed by attribute or
10 // result w/ fixed array `![attribute_a]func_b`?
11 // rely on newline and space between `!` and `[`,
12 // or check later if we are using a var or const?
13 // try eliminate this type of thing from the syntax.
14 // TODO/FIXME: currently broken, must fix.
15 func_a fn() ! [attribute_a]
16 // this is fine
17 func_b fn() ![len_a]u8
18
19 // fixed - parse as attribute, not as index of `'foo'`
20 field_c string = 'foo' [attribute_a]
21}
22