checker: fix sumtype matching test (#7235)

pull/7240/head
Daniel Däschle 2020-12-10 16:22:54 +01:00 committed by GitHub
parent 8b3ffb9be2
commit 916a64935a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 23 deletions

View File

@ -1,14 +1,14 @@
vlib/v/checker/tests/sum_type_mutable_cast_err.vv:23:10: error: cannot use operator `+` with `Abc`
21 | mut x := Abc(0)
22 | if x is int {
23 | _ := x + 5
vlib/v/checker/tests/sum_type_mutable_cast_err.vv:15:10: error: cannot use operator `+` with `Abc`
13 | mut x := Abc(0)
14 | if x is int {
15 | _ := x + 5
| ^
24 | }
25 | mut f2 := Foo2{Bar2{Abc(0)}}
vlib/v/checker/tests/sum_type_mutable_cast_err.vv:27:8: error: undefined ident: `f`
25 | mut f2 := Foo2{Bar2{Abc(0)}}
26 | if f2.b.a is int {
27 | _ := f.b.a + 5
| ^
28 | }
29 | }
16 | }
17 | mut f := Foo{Bar{Abc(0)}}
vlib/v/checker/tests/sum_type_mutable_cast_err.vv:19:14: error: cannot use operator `+` with `Abc`
17 | mut f := Foo{Bar{Abc(0)}}
18 | if f.b.a is int {
19 | _ := f.b.a + 5
| ^
20 | }
21 | }

View File

@ -9,21 +9,13 @@ struct Foo {
b Bar
}
struct Bar2 {
a Abc
}
struct Foo2 {
b Bar2
}
fn main() {
mut x := Abc(0)
if x is int {
_ := x + 5
}
mut f2 := Foo2{Bar2{Abc(0)}}
if f2.b.a is int {
mut f := Foo{Bar{Abc(0)}}
if f.b.a is int {
_ := f.b.a + 5
}
}