checker: add tests for assign sum type to non sum type error
parent
5c213de003
commit
90b5f6f4e0
|
@ -0,0 +1,7 @@
|
||||||
|
vlib/v/checker/tests/assign_sumtype2_err.vv:13:3: error: cannot assign to field `decl`: expected `Decl`, not `Stmt`
|
||||||
|
11 | stmt := Stmt(Decl{})
|
||||||
|
12 | _ := File{
|
||||||
|
13 | decl: stmt
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
14 | }
|
||||||
|
15 | }
|
|
@ -0,0 +1,15 @@
|
||||||
|
type Stmt = Decl | Expr
|
||||||
|
|
||||||
|
struct Decl {}
|
||||||
|
struct Expr {}
|
||||||
|
|
||||||
|
struct File {
|
||||||
|
decl Decl
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
stmt := Stmt(Decl{})
|
||||||
|
_ := File{
|
||||||
|
decl: stmt
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
vlib/v/checker/tests/assign_sumtype_err.vv:13:9: error: cannot assign to `decl`: expected `Decl`, not `Stmt`
|
||||||
|
11 | stmt := Stmt(Decl{})
|
||||||
|
12 | mut decl := Decl{}
|
||||||
|
13 | decl = stmt
|
||||||
|
| ~~~~
|
||||||
|
14 | }
|
|
@ -0,0 +1,14 @@
|
||||||
|
type Stmt = Decl | Expr
|
||||||
|
|
||||||
|
struct Decl {}
|
||||||
|
struct Expr {}
|
||||||
|
|
||||||
|
struct File {
|
||||||
|
decl Decl
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
stmt := Stmt(Decl{})
|
||||||
|
mut decl := Decl{}
|
||||||
|
decl = stmt
|
||||||
|
}
|
Loading…
Reference in New Issue