v2 / vlib / v / fmt / tests / fn_trailing_arg_syntax_keep.vv
56 lines · 50 sloc · 872 bytes · c51d30bf5309653c6b573ec815268e69a78ea8cc
Raw
1type Foo = Bar | Baz
2
3struct Bar {
4 x string
5 y int
6 z int
7 a int
8}
9
10struct Baz {
11 x string
12}
13
14fn bar_func(bar Bar) {}
15
16fn foo_func(f Foo) {}
17
18fn main() {
19 bar_func(x: 'bar', y: 13, z: 42)
20 bar_func(
21 x: 'bar'
22 y: 13
23 z: 42
24 )
25 foo_func(Baz{
26 x: 'Baz as Foo sumtype'
27 })
28 func_from_other_file(val: 'something')
29 bar_func(
30 // pre comment
31 x: 'struct has a pre comment'
32 )
33 bar_func(
34 x: 'first field'
35 // comment between fields
36 y: 100
37 )
38 bar_func(
39 x: 'Look! A comment to my right.' // comment after field
40 )
41 func_from_other_file(
42 xyz: AnotherStruct{
43 f: 'here'
44 }
45 )
46 ui.button(
47 width: 70
48 onclick: fn (a voidptr, b voidptr) {
49 webview.new_window(url: 'https://vlang.io', title: 'The V programming language')
50 }
51 )
52}
53
54fn trailing_struct_with_update_expr() {
55 c.error('duplicate const `${field.name}`', Position{ ...field.pos, len: name_len })
56}
57