v2 / vlib / v / checker / tests / option_fn_err.out
133 lines · 133 sloc · 5.37 KB · f4cc3c19b2ca2c1a9ff19425fd30e498c2a38a02
Raw
1vlib/v/checker/tests/option_fn_err.vv:7:11: notice: unused parameter: `v`
2 5 | }
3 6 |
4 7 | fn bar[T](v T) ?T {
5 | ^
6 8 | return none
7 9 | }
8vlib/v/checker/tests/option_fn_err.vv:32:16: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `twice`
9 30 | foo()
10 31 | _ := bar(0)
11 32 | println(twice(bar(0)))
12 | ~~~~~~
13 33 |
14 34 | // anon fn
15vlib/v/checker/tests/option_fn_err.vv:35:16: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `anon`
16 33 |
17 34 | // anon fn
18 35 | fn (_ int) {}(bar(0))
19 | ~~~~~~
20 36 |
21 37 | // assert
22vlib/v/checker/tests/option_fn_err.vv:38:9: error: assert can be used only with `bool` expressions, but found `bool` instead
23 36 |
24 37 | // assert
25 38 | assert bar(true)
26 | ~~~~~~~~~
27 39 |
28 40 | // struct
29vlib/v/checker/tests/option_fn_err.vv:43:3: error: cannot assign an Option value to a non-option struct field
30 41 | mut v := Data{
31 42 | f: fn (_ int) {}
32 43 | value: bar(0)
33 | ~~~~~~~~~~~~~
34 44 | opt: bar(0)
35 45 | }
36vlib/v/checker/tests/option_fn_err.vv:46:8: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `Data.add`
37 44 | opt: bar(0)
38 45 | }
39 46 | v.add(bar(0)) // call method
40 | ~~~~~~
41 47 | v.f(bar(0)) // call fn field
42 48 |
43vlib/v/checker/tests/option_fn_err.vv:47:6: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `Data.f`
44 45 | }
45 46 | v.add(bar(0)) // call method
46 47 | v.f(bar(0)) // call fn field
47 | ~~~~~~
48 48 |
49 49 | // array
50vlib/v/checker/tests/option_fn_err.vv:51:6: error: unwrapped Option cannot be used in an infix expression
51 49 | // array
52 50 | mut arr := [1, 2]
53 51 | arr << bar(0)
54 | ~~
55 52 | // init
56 53 | _ := [bar(0)]
57vlib/v/checker/tests/option_fn_err.vv:54:27: error: cannot use unwrapped Option as initializer
58 52 | // init
59 53 | _ := [bar(0)]
60 54 | _ := []int{len: 1, init: bar(0)}
61 | ~~~~~~
62 55 | _ := [bar(0)]!
63 56 | _ := [1]int{init: bar(0)}
64vlib/v/checker/tests/option_fn_err.vv:56:20: error: cannot use unwrapped Option as initializer
65 54 | _ := []int{len: 1, init: bar(0)}
66 55 | _ := [bar(0)]!
67 56 | _ := [1]int{init: bar(0)}
68 | ~~~~~~
69 57 | // index
70 58 | println(arr[bar(0)])
71vlib/v/checker/tests/option_fn_err.vv:58:14: error: cannot use Option or Result as index (array type `[]int`)
72 56 | _ := [1]int{init: bar(0)}
73 57 | // index
74 58 | println(arr[bar(0)])
75 | ~~~~~~
76 59 | // array builtin methods
77 60 | arr.insert(0, bar(0))
78vlib/v/checker/tests/option_fn_err.vv:60:16: error: cannot use `?int` as `voidptr`, it must be unwrapped first in argument 2 to `[]int.insert`
79 58 | println(arr[bar(0)])
80 59 | // array builtin methods
81 60 | arr.insert(0, bar(0))
82 | ~~~~~~
83 61 | arr.prepend(bar(0))
84 62 | arr.contains(bar(0))
85vlib/v/checker/tests/option_fn_err.vv:61:14: error: cannot use `?int` as `voidptr`, it must be unwrapped first in argument 1 to `[]int.prepend`
86 59 | // array builtin methods
87 60 | arr.insert(0, bar(0))
88 61 | arr.prepend(bar(0))
89 | ~~~~~~
90 62 | arr.contains(bar(0))
91 63 | arr.index(bar(0))
92vlib/v/checker/tests/option_fn_err.vv:62:15: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `.contains()`
93 60 | arr.insert(0, bar(0))
94 61 | arr.prepend(bar(0))
95 62 | arr.contains(bar(0))
96 | ~~~~~~
97 63 | arr.index(bar(0))
98 64 | println(arr.map(bar(0)))
99vlib/v/checker/tests/option_fn_err.vv:63:12: error: cannot use `?int` as `int`, it must be unwrapped first in argument 1 to `.index()`
100 61 | arr.prepend(bar(0))
101 62 | arr.contains(bar(0))
102 63 | arr.index(bar(0))
103 | ~~~~~~
104 64 | println(arr.map(bar(0)))
105 65 | println(arr.filter(bar(true)))
106vlib/v/checker/tests/option_fn_err.vv:65:21: error: type mismatch, `bar` must return a bool
107 63 | arr.index(bar(0))
108 64 | println(arr.map(bar(0)))
109 65 | println(arr.filter(bar(true)))
110 | ~~~~~~~~~
111 66 | println(arr.any(bar(true)))
112 67 | println(arr.all(bar(true)))
113vlib/v/checker/tests/option_fn_err.vv:66:18: error: type mismatch, `bar` must return a bool
114 64 | println(arr.map(bar(0)))
115 65 | println(arr.filter(bar(true)))
116 66 | println(arr.any(bar(true)))
117 | ~~~~~~~~~
118 67 | println(arr.all(bar(true)))
119 68 |
120vlib/v/checker/tests/option_fn_err.vv:67:18: error: type mismatch, `bar` must return a bool
121 65 | println(arr.filter(bar(true)))
122 66 | println(arr.any(bar(true)))
123 67 | println(arr.all(bar(true)))
124 | ~~~~~~~~~
125 68 |
126 69 | match bar(0) {
127vlib/v/checker/tests/option_fn_err.vv:70:3: error: `match` expression with Option type only checks against `none`, to match its value you must unwrap it first `var?`
128 68 |
129 69 | match bar(0) {
130 70 | 0 {}
131 | ^
132 71 | else {}
133 72 | }
134