v2 / vlib / v / checker / tests / opt_is_op_check_err.vv
21 lines · 17 sloc · 189 bytes · 89089ab1d55e39a5f89909d8df71e1e31d814347
Raw
1type Foo = int | string
2
3struct Struct {
4 a ?Foo
5}
6
7fn r(a string) {}
8
9fn t(s ?Foo) {
10 mut t := Struct{
11 a: s
12 }
13 if t.a is string {
14 r(t.a)
15 }
16}
17
18fn main() {
19 s := ?Foo('hello')
20 t(s)
21}
22