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 e355ae7 commit 0876cf8Copy full SHA for 0876cf8
vlib/v/gen/c/struct.v
@@ -195,7 +195,9 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
195
if is_update_tmp_var {
196
g.write(tmp_update_var)
197
} else {
198
+ g.write('(')
199
g.expr(node.update_expr)
200
+ g.write(')')
201
}
202
if node.update_expr_type.is_ptr() {
203
g.write('->')
vlib/v/tests/struct_init_with_update_test.v
@@ -30,3 +30,21 @@ fn test_struct_init_with_update_expr() {
30
assert o.height == 175
31
assert o.age == 21
32
33
+
34
+struct Foo {
35
+ s string
36
+ n int
37
+}
38
39
+fn test_struct_init_with_update_expr2() {
40
+ f := &Foo{
41
+ s: 'AA'
42
+ }
43
+ b := Foo{
44
+ ...*f
45
+ n: 3
46
47
+ println(b)
48
+ assert b.s == 'AA'
49
+ assert b.n == 3
50
0 commit comments