mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: add tests for assign sum type to non sum type error
This commit is contained in:
parent
5c213de003
commit
90b5f6f4e0
7
vlib/v/checker/tests/assign_sumtype2_err.out
Normal file
7
vlib/v/checker/tests/assign_sumtype2_err.out
Normal file
@ -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 | }
|
15
vlib/v/checker/tests/assign_sumtype2_err.vv
Normal file
15
vlib/v/checker/tests/assign_sumtype2_err.vv
Normal file
@ -0,0 +1,15 @@
|
||||
type Stmt = Decl | Expr
|
||||
|
||||
struct Decl {}
|
||||
struct Expr {}
|
||||
|
||||
struct File {
|
||||
decl Decl
|
||||
}
|
||||
|
||||
fn main() {
|
||||
stmt := Stmt(Decl{})
|
||||
_ := File{
|
||||
decl: stmt
|
||||
}
|
||||
}
|
6
vlib/v/checker/tests/assign_sumtype_err.out
Normal file
6
vlib/v/checker/tests/assign_sumtype_err.out
Normal file
@ -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 | }
|
14
vlib/v/checker/tests/assign_sumtype_err.vv
Normal file
14
vlib/v/checker/tests/assign_sumtype_err.vv
Normal file
@ -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
Block a user