57 lines
942 B
V
57 lines
942 B
V
type Foo = Bar | Baz
|
|
|
|
struct Bar {
|
|
x string
|
|
y int
|
|
z int
|
|
a int
|
|
}
|
|
|
|
struct Baz {
|
|
x string
|
|
}
|
|
|
|
fn bar_func(bar Bar) {}
|
|
fn foo_func(f Foo) {}
|
|
|
|
fn main() {
|
|
bar_func(x: 'bar', y: 13, z: 42)
|
|
bar_func(
|
|
x: 'bar'
|
|
y: 13
|
|
z: 42
|
|
)
|
|
foo_func(Baz{
|
|
x: 'Baz as Foo sumtype'
|
|
})
|
|
func_from_other_file(val: 'something')
|
|
bar_func(
|
|
// pre comment
|
|
x: 'struct has a pre comment'
|
|
)
|
|
bar_func(
|
|
x: 'first field'
|
|
// comment between fields
|
|
y: 100
|
|
)
|
|
bar_func(
|
|
x: 'Look! A comment to my right.' // comment after field
|
|
)
|
|
func_from_other_file(
|
|
xyz: AnotherStruct{
|
|
f: 'here'
|
|
}
|
|
)
|
|
ui.button(
|
|
width: 70
|
|
onclick: fn (a voidptr, b voidptr) {
|
|
webview.new_window(url: 'https://vlang.io', title: 'The V programming language')
|
|
}
|
|
)
|
|
}
|
|
|
|
fn trailing_struct_with_update_expr() {
|
|
c.error('duplicate const `$field.name`', { ...field.pos, len: name_len })
|
|
c.error('duplicate const `$field.name`', Position{ ...field.pos, len: name_len })
|
|
}
|