vxx2 / vlib / v / checker / tests / opt_is_op_check_err.vv
21 lines · 17 sloc · 201 bytes · a7fef7c4930a3443b41f2a53c855839df4cccea6
Raw
1type Foo = int | string
2
3struct Struct {
4 a ?Foo
5}
6
7fn r(a string) {}
8
9fn process(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 process(s)
21}
22