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 {
598
598
if node.has_update_expr {
599
599
update_type := c.expr (node.update_expr)
600
600
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_ {
602
602
s := c.table.type_to_str (update_type)
603
603
c.error ('expected struct, found `${s} `' , node.update_expr.pos ())
604
604
} 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
5
5
| ^
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
12
12
| ^
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
19
19
| ~~
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
26
26
| ^
27
- 33 | }
28
- 34 | }
27
+ 35 | }
28
+ 36 | }
Original file line number Diff line number Diff line change 1
1
struct Foo {
2
2
name string
3
- age int
3
+ age int
4
4
}
5
5
6
- struct Foo2 {b bool}
6
+ struct Foo2 {
7
+ b bool
8
+ }
7
9
8
10
fn main() {
9
11
i := 2
@@ -33,3 +35,11 @@ fn empty() {
33
35
}
34
36
}
35
37
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