File tree Expand file tree Collapse file tree 3 files changed +37
-27
lines changed Expand file tree Collapse file tree 3 files changed +37
-27
lines changed Original file line number Diff line number Diff line change @@ -598,7 +598,7 @@ fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type {
598598 if node.has_update_expr {
599599 update_type := c.expr (node.update_expr)
600600 node.update_expr_type = update_type
601- if c.table.sym (update_type).kind != .struct_ {
601+ if c.table.final_sym (update_type).kind != .struct_ {
602602 s := c.table.type_to_str (update_type)
603603 c.error ('expected struct, found `${s} `' , node.update_expr.pos ())
604604 } else if update_type != node.typ {
Original file line number Diff line number Diff line change 1- vlib/v/checker/tests/struct_init_update_type_err.vv:11 :6: error: expected struct, found `int`
2- 9 | i := 2
3- 10 | _ := Foo{
4- 11 | ...i
1+ vlib/v/checker/tests/struct_init_update_type_err.vv:13 :6: error: expected struct, found `int`
2+ 11 | i := 2
3+ 12 | _ := Foo{
4+ 13 | ...i
55 | ^
6- 12 | name: 'f2'
7- 13 | }
8- vlib/v/checker/tests/struct_init_update_type_err.vv:16 :6: error: expected struct, found `&int`
9- 14 | p := &i
10- 15 | _ = Foo{
11- 16 | ...p
6+ 14 | name: 'f2'
7+ 15 | }
8+ vlib/v/checker/tests/struct_init_update_type_err.vv:18 :6: error: expected struct, found `&int`
9+ 16 | p := &i
10+ 17 | _ = Foo{
11+ 18 | ...p
1212 | ^
13- 17 | }
14- 18 | f2 := Foo2{}
15- vlib/v/checker/tests/struct_init_update_type_err.vv:20 :6: error: struct `Foo2` is not compatible with struct `Foo`
16- 18 | f2 := Foo2{}
17- 19 | _ = Foo{
18- 20 | ...f2
13+ 19 | }
14+ 20 | f2 := Foo2{}
15+ vlib/v/checker/tests/struct_init_update_type_err.vv:22 :6: error: struct `Foo2` is not compatible with struct `Foo`
16+ 20 | f2 := Foo2{}
17+ 21 | _ = Foo{
18+ 22 | ...f2
1919 | ~~
20- 21 | }
21- 22 | _ = Foo{
22- vlib/v/checker/tests/struct_init_update_type_err.vv:32 :6: error: struct `Empty` is not compatible with struct `Foo`
23- 30 | e := Empty{}
24- 31 | _ = Foo{
25- 32 | ...e
20+ 23 | }
21+ 24 | _ = Foo{
22+ vlib/v/checker/tests/struct_init_update_type_err.vv:34 :6: error: struct `Empty` is not compatible with struct `Foo`
23+ 32 | e := Empty{}
24+ 33 | _ = Foo{
25+ 34 | ...e
2626 | ^
27- 33 | }
28- 34 | }
27+ 35 | }
28+ 36 | }
Original file line number Diff line number Diff line change 11struct Foo {
22 name string
3- age int
3+ age int
44}
55
6- struct Foo2 {b bool}
6+ struct Foo2 {
7+ b bool
8+ }
79
810fn main() {
911 i := 2
@@ -33,3 +35,11 @@ fn empty() {
3335 }
3436}
3537
38+ type AliasFoo = Foo
39+
40+ fn alias() {
41+ a := AliasFoo{}
42+ _ = AliasFoo{
43+ ...a
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments