We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b429aad commit bce1039Copy full SHA for bce1039
vlib/v/gen/c/struct.v
@@ -49,8 +49,7 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
49
}
50
51
if is_anon {
52
- // No name needed for anon structs, C figures it out on its own.
53
- g.writeln('{')
+ g.writeln('($styp){')
54
} else if g.is_shared && !g.inside_opt_data && !g.is_arraymap_set {
55
mut shared_typ := node.typ.set_flag(.shared_f)
56
shared_styp = g.typ(shared_typ)
vlib/v/tests/anon_struct_type_test.v
@@ -0,0 +1,11 @@
1
+module main
2
+
3
+fn func(arg struct { foo string }) {
4
+ assert arg.foo == 'foo'
5
+}
6
7
+fn test_anon_struct_as_parameter() {
8
+ func(struct {
9
+ foo: 'foo'
10
+ })
11
0 commit comments