v2 / vlib / v / checker / tests / incorrect_smartcast2_err.vv
30 lines · 25 sloc · 342 bytes · 3d60410b605d001e54f280070d5f952da9de1112
Raw
1struct Left[E] {
2 error E
3}
4
5struct Right[T] {
6 inner T
7}
8
9type Either[T, E] = Left[E] | Right[T]
10
11fn works(v []Either[int, int]) {
12 first := v[0]
13 match first {
14 Left[int] {
15 println(first.error)
16 }
17 else {}
18 }
19}
20
21fn doesntwork(v []Either[int, int]) {
22 match v[0] {
23 Left[int] {
24 println(v[0].error)
25 }
26 else {}
27 }
28}
29
30fn main() {}
31