mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
@@ -49,8 +49,7 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
|
||||
}
|
||||
}
|
||||
if is_anon {
|
||||
// No name needed for anon structs, C figures it out on its own.
|
||||
g.writeln('{')
|
||||
g.writeln('($styp){')
|
||||
} else if g.is_shared && !g.inside_opt_data && !g.is_arraymap_set {
|
||||
mut shared_typ := node.typ.set_flag(.shared_f)
|
||||
shared_styp = g.typ(shared_typ)
|
||||
|
||||
11
vlib/v/tests/anon_struct_type_test.v
Normal file
11
vlib/v/tests/anon_struct_type_test.v
Normal file
@@ -0,0 +1,11 @@
|
||||
module main
|
||||
|
||||
fn func(arg struct { foo string }) {
|
||||
assert arg.foo == 'foo'
|
||||
}
|
||||
|
||||
fn test_anon_struct_as_parameter() {
|
||||
func(struct {
|
||||
foo: 'foo'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user