diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/vlib/v/checker/tests | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'v_windows/v/old/vlib/v/checker/tests')
1018 files changed, 12468 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/v/checker/tests/.gitattributes b/v_windows/v/old/vlib/v/checker/tests/.gitattributes new file mode 100644 index 0000000..20f8e01 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/.gitattributes @@ -0,0 +1,2 @@ +*_crlf_* binary +*_lf_* binary diff --git a/v_windows/v/old/vlib/v/checker/tests/.gitignore b/v_windows/v/old/vlib/v/checker/tests/.gitignore new file mode 100644 index 0000000..868d19e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/.gitignore @@ -0,0 +1,4 @@ +*.v +*.c +!*_test.v +!modules/**/*.v
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.out b/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.out new file mode 100644 index 0000000..3734061 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/a_test_file_with_0_test_fns_test.vv:1:1: error: a _test.v file should have *at least* one `test_` function + 1 | fn abc() {} + | ^ +Details: The name of a test function in V, should start with `test_`. +The test function should take 0 parameters, and no return type. Example: +fn test_xyz(){ assert 2 + 2 == 4 } diff --git a/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.vv b/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.vv new file mode 100644 index 0000000..45f81ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/a_test_file_with_0_test_fns_test.vv @@ -0,0 +1 @@ +fn abc() {} diff --git a/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.out new file mode 100644 index 0000000..c1c8699 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/add_op_wrong_type_err.vv:3:13: error: mismatched types `Aaa` and `int literal` + 1 | struct Aaa{} + 2 | fn main() { + 3 | println(Aaa{} + 10) + | ~~~~~~~~~~ + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) +vlib/v/checker/tests/add_op_wrong_type_err.vv:4:13: error: mismatched types `int literal` and `Aaa` + 2 | fn main() { + 3 | println(Aaa{} + 10) + 4 | println(10 + Aaa{}) + | ~~~~~~~~~~ + 5 | println([1,2,3] + 10) + 6 | println(10 + [1,2,3]) +vlib/v/checker/tests/add_op_wrong_type_err.vv:5:13: error: mismatched types `[]int` and `int literal` + 3 | println(Aaa{} + 10) + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) + | ~~~~~~~~~~~~ + 6 | println(10 + [1,2,3]) + 7 | a := map[string]int +vlib/v/checker/tests/add_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `[]int` + 4 | println(10 + Aaa{}) + 5 | println([1,2,3] + 10) + 6 | println(10 + [1,2,3]) + | ~~~~~~~~~~~~ + 7 | a := map[string]int + 8 | println(a + 10) +vlib/v/checker/tests/add_op_wrong_type_err.vv:8:13: error: mismatched types `map[string]int` and `int literal` + 6 | println(10 + [1,2,3]) + 7 | a := map[string]int + 8 | println(a + 10) + | ~~~~~~ + 9 | println(10 + a) + 10 | } +vlib/v/checker/tests/add_op_wrong_type_err.vv:9:13: error: mismatched types `int literal` and `map[string]int` + 7 | a := map[string]int + 8 | println(a + 10) + 9 | println(10 + a) + | ~~~~~~ + 10 | } + diff --git a/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.vv new file mode 100644 index 0000000..f02798b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/add_op_wrong_type_err.vv @@ -0,0 +1,10 @@ +struct Aaa{} +fn main() { + println(Aaa{} + 10) + println(10 + Aaa{}) + println([1,2,3] + 10) + println(10 + [1,2,3]) + a := map[string]int + println(a + 10) + println(10 + a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.out b/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.out new file mode 100644 index 0000000..34cfbdb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/alias_array_unknown_op_overloading_err.vv:17:7: error: undefined operation `Tuple` - `Tuple` + 15 | mut a := new_tuple(12, 4.5, 6.7, 6) + 16 | b := new_tuple(12, 4.5, 6.7, 6) + 17 | a -= b + | ~~ + 18 | println(a - b) + 19 | } +vlib/v/checker/tests/alias_array_unknown_op_overloading_err.vv:18:13: error: undefined operation `Tuple` - `Tuple` + 16 | b := new_tuple(12, 4.5, 6.7, 6) + 17 | a -= b + 18 | println(a - b) + | ~~~~~ + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.vv b/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.vv new file mode 100644 index 0000000..84d7034 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_array_unknown_op_overloading_err.vv @@ -0,0 +1,19 @@ +type Tuple = []f64 + +fn new_tuple(x f64, y f64, z f64, w f64) Tuple { + return Tuple([x, y, z, w]) +} + +fn (a Tuple) + (b Tuple) Tuple { + mut res := []f64{len: a.len} + for i := 0; i < a.len; i++ { + res[i] = a[i] + b[i] + } + return Tuple(res) +} +fn main() { + mut a := new_tuple(12, 4.5, 6.7, 6) + b := new_tuple(12, 4.5, 6.7, 6) + a -= b + println(a - b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.out b/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.out new file mode 100644 index 0000000..6a93514 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv:19:10: error: undefined operation `Map` - `Map` + 17 | mut a := new_map() + 18 | b := new_map() + 19 | println(a - b) + | ~~~~~ + 20 | a -= b + 21 | } +vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv:20:7: error: undefined operation `Map` - `Map` + 18 | b := new_map() + 19 | println(a - b) + 20 | a -= b + | ~~ + 21 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv b/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv new file mode 100644 index 0000000..bea0261 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_map_unknown_op_overloading_err.vv @@ -0,0 +1,21 @@ +type Map = map[string]string + +pub fn new_map() Map { + return Map(map{ + '23': 'str' + }) +} + +fn (a Map) + (b Map) Map { + str := b['23'] + return Map(map{ + '34': str + '12' + }) +} + +fn main() { + mut a := new_map() + b := new_map() + println(a - b) + a -= b +} diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.out b/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.out new file mode 100644 index 0000000..d79df8a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/alias_type_exists.vv:1:15: error: unknown type `Bird` + 1 | type Pigeon = Bird + | ~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.vv b/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.vv new file mode 100644 index 0000000..da63abd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/alias_type_exists.vv @@ -0,0 +1 @@ +type Pigeon = Bird diff --git a/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.out b/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.out new file mode 100644 index 0000000..019eef5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/ambiguous_field_method_err.vv:22:4: error: ambiguous method `test` + 20 | fn main() { + 21 | b := Bar{} + 22 | b.test() + | ~~~~~~ + 23 | n := b.name + 24 | } +vlib/v/checker/tests/ambiguous_field_method_err.vv:23:9: error: ambiguous field `name` + 21 | b := Bar{} + 22 | b.test() + 23 | n := b.name + | ~~~~ + 24 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.vv b/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.vv new file mode 100644 index 0000000..fa32755 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ambiguous_field_method_err.vv @@ -0,0 +1,24 @@ +struct Foo { + name int = 5 +} +struct Bar { + Foo + Foo2 +} + +struct Foo2 { + name string +} +fn (f Foo2) test() { + println(f) +} + +fn (f Foo) test() { + println(f) +} + +fn main() { + b := Bar{} + b.test() + n := b.name +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.out b/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.out new file mode 100644 index 0000000..b88ef1a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/ambiguous_function_call.vv:2:2: error: ambiguous call to: `foo1`, may refer to fn `foo1` or variable `foo1` + 1 | fn foo1(foo1 int) { + 2 | foo1(foo1 + 1) + | ~~~~~~~~~~~~~~ + 3 | } + 4 | +vlib/v/checker/tests/ambiguous_function_call.vv:7:2: error: ambiguous call to: `foo2`, may refer to fn `foo2` or variable `foo2` + 5 | fn foo2() { + 6 | foo2 := 1 + 7 | foo2(foo2) + | ~~~~~~~~~~ + 8 | } + 9 | diff --git a/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.vv b/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.vv new file mode 100644 index 0000000..2d21224 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ambiguous_function_call.vv @@ -0,0 +1,13 @@ +fn foo1(foo1 int) { + foo1(foo1 + 1) +} + +fn foo2() { + foo2 := 1 + foo2(foo2) +} + +fn main() { + foo1(5) + foo2() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.out b/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.out new file mode 100644 index 0000000..8b9eb5d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.out @@ -0,0 +1,45 @@ +vlib/v/checker/tests/any_int_float_ban_err.vv:1:12: error: unknown type `int_literal` + 1 | type Foo = int_literal | float_literal + | ~~~~~~~~~~~ + 2 | type Fo2 = int_literal + 3 | +vlib/v/checker/tests/any_int_float_ban_err.vv:2:12: error: unknown type `int_literal` + 1 | type Foo = int_literal | float_literal + 2 | type Fo2 = int_literal + | ~~~~~~~~~~~ + 3 | + 4 | struct Int { +vlib/v/checker/tests/any_int_float_ban_err.vv:5:7: error: unknown type `int_literal` + 3 | + 4 | struct Int { + 5 | i int_literal + | ~~~~~~~~~~~ + 6 | f float_literal + 7 | } +vlib/v/checker/tests/any_int_float_ban_err.vv:6:7: error: unknown type `float_literal` + 4 | struct Int { + 5 | i int_literal + 6 | f float_literal + | ~~~~~~~~~~~~~ + 7 | } + 8 | +vlib/v/checker/tests/any_int_float_ban_err.vv:9:10: error: unknown type `int_literal` + 7 | } + 8 | + 9 | fn foo(i int_literal) int_literal { + | ~~~~~~~~~~~ + 10 | return i + 11 | } +vlib/v/checker/tests/any_int_float_ban_err.vv:13:11: error: unknown type `int_literal` + 11 | } + 12 | + 13 | fn foo2() int_literal { + | ~~~~~~~~~~~ + 14 | return 1 + 15 | } +vlib/v/checker/tests/any_int_float_ban_err.vv:14:12: error: cannot use `int literal` as type `int_literal` in return argument + 12 | + 13 | fn foo2() int_literal { + 14 | return 1 + | ^ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.vv b/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.vv new file mode 100644 index 0000000..15fab98 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/any_int_float_ban_err.vv @@ -0,0 +1,15 @@ +type Foo = int_literal | float_literal +type Fo2 = int_literal + +struct Int { + i int_literal + f float_literal +} + +fn foo(i int_literal) int_literal { + return i +} + +fn foo2() int_literal { + return 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/append_err.out b/v_windows/v/old/vlib/v/checker/tests/append_err.out new file mode 100644 index 0000000..4c87f24 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/append_err.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/append_err.vv:3:7: error: cannot append `string` to `[]int` + 1 | fn main() { + 2 | mut l := []int{} + 3 | l << 'test' + | ~~~~~~ + 4 | + 5 | _ = l << 3 +vlib/v/checker/tests/append_err.vv:5:8: error: array append cannot be used in an expression + 3 | l << 'test' + 4 | + 5 | _ = l << 3 + | ~~ + 6 | _ = (l << 3).len + 7 | } +vlib/v/checker/tests/append_err.vv:6:9: error: array append cannot be used in an expression + 4 | + 5 | _ = l << 3 + 6 | _ = (l << 3).len + | ~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/append_err.vv b/v_windows/v/old/vlib/v/checker/tests/append_err.vv new file mode 100644 index 0000000..bc506b6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/append_err.vv @@ -0,0 +1,7 @@ +fn main() { + mut l := []int{} + l << 'test' + + _ = l << 3 + _ = (l << 3).len +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.out b/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.out new file mode 100644 index 0000000..0cd37f3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/array_append_array_type_mismatch_err.vv:3:8: error: cannot append `[]int` to `[]byte` + 1 | fn main() { + 2 | mut bc := []byte{} + 3 | bc << [0xCA, 0xFE, 0xBA, 0xBE] + | ~~~~~~~~~~~~~~~~~~~~~~~~ + 4 | println(bc) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv new file mode 100644 index 0000000..45de913 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv @@ -0,0 +1,5 @@ +fn main() { + mut bc := []byte{} + bc << [0xCA, 0xFE, 0xBA, 0xBE] + println(bc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.out b/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.out new file mode 100644 index 0000000..da5c05d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/array_builtin_redefinition.vv:7:1: error: method overrides built-in array method + 5 | // fn (a []Abc) repeat() int { return 0 } + 6 | // fn (a []Abc) reverse() int { return 0 } + 7 | fn (a []Abc) map() int { return 0 } + | ~~~~~~~~~~~~~~~~~~~~~~ + 8 | // fn (a []Abc) slice() int { return 0 } + 9 | // fn (a []Abc) sort() int { return 0 } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.vv b/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.vv new file mode 100644 index 0000000..809b86a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_builtin_redefinition.vv @@ -0,0 +1,11 @@ +type Abc = int + +// fn (a []Abc) filter() int { return 0 } +// fn (a []Abc) clone() int { return 0 } +// fn (a []Abc) repeat() int { return 0 } +// fn (a []Abc) reverse() int { return 0 } +fn (a []Abc) map() int { return 0 } +// fn (a []Abc) slice() int { return 0 } +// fn (a []Abc) sort() int { return 0 } +// fn (a []Abc) contains() int { return 0 } +// fn (a []Abc) index() int { return 0 } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.out b/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.out new file mode 100644 index 0000000..885a514 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.out @@ -0,0 +1,26 @@ +vlib/v/checker/tests/array_cmp_err.vv:2:26: error: only `==` and `!=` are defined on arrays + 1 | fn main() { + 2 | println([2, 3, 4, 6] < [2, 5]) + | ^ + 3 | println([2, 3, 4, 6] > [2, 5]) + 4 | println([2, 3, 1, 6] >= [3, 5, 7]) +vlib/v/checker/tests/array_cmp_err.vv:3:26: error: only `==` and `!=` are defined on arrays + 1 | fn main() { + 2 | println([2, 3, 4, 6] < [2, 5]) + 3 | println([2, 3, 4, 6] > [2, 5]) + | ^ + 4 | println([2, 3, 1, 6] >= [3, 5, 7]) + 5 | println([2, 3, 6, 8] <= [2, 5, 8, 9]) +vlib/v/checker/tests/array_cmp_err.vv:4:26: error: only `==` and `!=` are defined on arrays + 2 | println([2, 3, 4, 6] < [2, 5]) + 3 | println([2, 3, 4, 6] > [2, 5]) + 4 | println([2, 3, 1, 6] >= [3, 5, 7]) + | ~~ + 5 | println([2, 3, 6, 8] <= [2, 5, 8, 9]) + 6 | } +vlib/v/checker/tests/array_cmp_err.vv:5:26: error: only `==` and `!=` are defined on arrays + 3 | println([2, 3, 4, 6] > [2, 5]) + 4 | println([2, 3, 1, 6] >= [3, 5, 7]) + 5 | println([2, 3, 6, 8] <= [2, 5, 8, 9]) + | ~~ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.vv new file mode 100644 index 0000000..ec60eb9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_cmp_err.vv @@ -0,0 +1,6 @@ +fn main() { + println([2, 3, 4, 6] < [2, 5]) + println([2, 3, 4, 6] > [2, 5]) + println([2, 3, 1, 6] >= [3, 5, 7]) + println([2, 3, 6, 8] <= [2, 5, 8, 9]) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.out b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.out new file mode 100644 index 0000000..15335cc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/array_declare_element_a.vv:2:5: error: non-name `arr[0]` on left side of `:=` + 1 | fn main() { + 2 | arr[0] := 2 + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.vv b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.vv new file mode 100644 index 0000000..ac07498 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_a.vv @@ -0,0 +1,3 @@ +fn main() { + arr[0] := 2 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.out b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.out new file mode 100644 index 0000000..a898165 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/array_declare_element_b.vv:3:5: error: non-name `arr[1]` on left side of `:=` + 1 | fn main() { + 2 | arr := [1, 2] + 3 | arr[1] := 1 + | ~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.vv b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.vv new file mode 100644 index 0000000..a87a0e5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_b.vv @@ -0,0 +1,4 @@ +fn main() { + arr := [1, 2] + arr[1] := 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.out b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.out new file mode 100644 index 0000000..d6e2aaf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/array_declare_element_c.vv:3:8: error: non-name `arr[1][0]` on left side of `:=` + 1 | fn main() { + 2 | arr := [[1, 2], [0, 3]] + 3 | arr[1][0] := 1 + | ~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.vv b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.vv new file mode 100644 index 0000000..aacad55 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_declare_element_c.vv @@ -0,0 +1,4 @@ +fn main() { + arr := [[1, 2], [0, 3]] + arr[1][0] := 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_element_type.out b/v_windows/v/old/vlib/v/checker/tests/array_element_type.out new file mode 100644 index 0000000..71a50e2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_element_type.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/array_element_type.vv:2:8: error: unknown type `abc` + 1 | fn main() { + 2 | _ = []abc{} + | ~~~ + 3 | _ = [2, ''] + 4 | } +vlib/v/checker/tests/array_element_type.vv:3:10: error: invalid array element: expected `int`, not `string` + 1 | fn main() { + 2 | _ = []abc{} + 3 | _ = [2, ''] + | ~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_element_type.vv b/v_windows/v/old/vlib/v/checker/tests/array_element_type.vv new file mode 100644 index 0000000..95fd275 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_element_type.vv @@ -0,0 +1,4 @@ +fn main() { + _ = []abc{} + _ = [2, ''] +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.out new file mode 100644 index 0000000..cd0b1fc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/array_filter_fn_err.vv:2:25: error: function needs exactly 1 argument + 1 | fn main() { + 2 | a1 := [1,2,3,4].filter(fn(a int, b int) bool { return a > 0 }) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 3 | println(a1) + 4 | +vlib/v/checker/tests/array_filter_fn_err.vv:5:25: error: type mismatch, should use `fn(a int) bool {...}` + 3 | println(a1) + 4 | + 5 | a2 := [1,2,3,4].filter(fn(a string) bool { return a.len > 0 }) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | println(a2) + 7 | +vlib/v/checker/tests/array_filter_fn_err.vv:8:18: error: function needs exactly 1 argument + 6 | println(a2) + 7 | + 8 | a3 := [1,2,3,4].filter(fil1) + | ~~~~~~~~~~~~ + 9 | println(a3) + 10 | +vlib/v/checker/tests/array_filter_fn_err.vv:11:25: error: type mismatch, should use `fn(a int) bool {...}` + 9 | println(a3) + 10 | + 11 | a4 := [1,2,3,4].filter(fil2) + | ~~~~ + 12 | println(a4) + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.vv new file mode 100644 index 0000000..27c3867 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_filter_fn_err.vv @@ -0,0 +1,21 @@ +fn main() { + a1 := [1,2,3,4].filter(fn(a int, b int) bool { return a > 0 }) + println(a1) + + a2 := [1,2,3,4].filter(fn(a string) bool { return a.len > 0 }) + println(a2) + + a3 := [1,2,3,4].filter(fil1) + println(a3) + + a4 := [1,2,3,4].filter(fil2) + println(a4) +} + +fn fil1(a int, b int) bool { + return a > 0 +} + +fn fil2(a string) bool { + return a.len > 0 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_index.out b/v_windows/v/old/vlib/v/checker/tests/array_index.out new file mode 100644 index 0000000..d2e6795 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_index.out @@ -0,0 +1,34 @@ +vlib/v/checker/tests/array_index.vv:3:7: error: non-integer index `float literal` (array type `[2]int`) + 1 | fn fixed() { + 2 | a := [1,2]! + 3 | _ = a[0.2] + | ~~~~~ + 4 | _ = a[1] // OK + 5 | _ = a[-1] +vlib/v/checker/tests/array_index.vv:5:8: error: negative index `-1` + 3 | _ = a[0.2] + 4 | _ = a[1] // OK + 5 | _ = a[-1] + | ~~ + 6 | _ = a[2] + 7 | _ = a[1..2] // OK +vlib/v/checker/tests/array_index.vv:6:8: error: index out of range (index: 2, len: 2) + 4 | _ = a[1] // OK + 5 | _ = a[-1] + 6 | _ = a[2] + | ^ + 7 | _ = a[1..2] // OK + 8 | _ = a[2..2] // empty, OK +vlib/v/checker/tests/array_index.vv:9:11: error: index out of range (index: 3, len: 2) + 7 | _ = a[1..2] // OK + 8 | _ = a[2..2] // empty, OK + 9 | _ = a[1..3] + | ^ + 10 | _ = a[3..3] + 11 | } +vlib/v/checker/tests/array_index.vv:10:8: error: index out of range (index: 3, len: 2) + 8 | _ = a[2..2] // empty, OK + 9 | _ = a[1..3] + 10 | _ = a[3..3] + | ^ + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_index.vv b/v_windows/v/old/vlib/v/checker/tests/array_index.vv new file mode 100644 index 0000000..74200ff --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_index.vv @@ -0,0 +1,11 @@ +fn fixed() { + a := [1,2]! + _ = a[0.2] + _ = a[1] // OK + _ = a[-1] + _ = a[2] + _ = a[1..2] // OK + _ = a[2..2] // empty, OK + _ = a[1..3] + _ = a[3..3] +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.out b/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.out new file mode 100644 index 0000000..129d9db --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.vv:4:7: error: cannot initialize sum type array without default value + 2 | + 3 | fn main() { + 4 | a := []Foo{len: 10} + | ~~~~~~ + 5 | println(a) + 6 | +vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.vv:7:13: error: cannot initialize sum type array without default value + 5 | println(a) + 6 | + 7 | fixed_a := [10]Foo{} + | ~~~~~~~~~ + 8 | println(fixed_a) + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.vv new file mode 100644 index 0000000..2494d52 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_init_sum_type_without_init_value_and_len_err.vv @@ -0,0 +1,9 @@ +type Foo = int | string + +fn main() { + a := []Foo{len: 10} + println(a) + + fixed_a := [10]Foo{} + println(fixed_a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.out new file mode 100644 index 0000000..78f0a64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.out @@ -0,0 +1,56 @@ +vlib/v/checker/tests/array_insert_type_mismatch.vv:3:14: error: cannot insert `float literal` to `[]int` + 1 | fn main() { + 2 | mut a := [1, 2] + 3 | a.insert(1, 2.3) + | ~~~ + 4 | a.insert(1, 'abc') + 5 | a.insert(1, [1.1, 2.2]) +vlib/v/checker/tests/array_insert_type_mismatch.vv:4:14: error: cannot insert `string` to `[]int` + 2 | mut a := [1, 2] + 3 | a.insert(1, 2.3) + 4 | a.insert(1, 'abc') + | ~~~~~ + 5 | a.insert(1, [1.1, 2.2]) + 6 | a.insert(1, ['aa', 'bb', 'cc']) +vlib/v/checker/tests/array_insert_type_mismatch.vv:5:14: error: cannot insert `[]f64` to `[]int` + 3 | a.insert(1, 2.3) + 4 | a.insert(1, 'abc') + 5 | a.insert(1, [1.1, 2.2]) + | ~~~~~~~~~~ + 6 | a.insert(1, ['aa', 'bb', 'cc']) + 7 | a.insert(1, [[1]]) +vlib/v/checker/tests/array_insert_type_mismatch.vv:6:14: error: cannot insert `[]string` to `[]int` + 4 | a.insert(1, 'abc') + 5 | a.insert(1, [1.1, 2.2]) + 6 | a.insert(1, ['aa', 'bb', 'cc']) + | ~~~~~~~~~~~~~~~~~~ + 7 | a.insert(1, [[1]]) + 8 | a.insert(1, [[['aa']]]) +vlib/v/checker/tests/array_insert_type_mismatch.vv:7:14: error: cannot insert `[][]int` to `[]int` + 5 | a.insert(1, [1.1, 2.2]) + 6 | a.insert(1, ['aa', 'bb', 'cc']) + 7 | a.insert(1, [[1]]) + | ~~~~~ + 8 | a.insert(1, [[['aa']]]) + 9 | println(a) +vlib/v/checker/tests/array_insert_type_mismatch.vv:8:14: error: cannot insert `[][][]string` to `[]int` + 6 | a.insert(1, ['aa', 'bb', 'cc']) + 7 | a.insert(1, [[1]]) + 8 | a.insert(1, [[['aa']]]) + | ~~~~~~~~~~ + 9 | println(a) + 10 | +vlib/v/checker/tests/array_insert_type_mismatch.vv:12:14: error: cannot insert `[][][]int` to `[][]int` + 10 | + 11 | mut b := [[1, 2, 3]] + 12 | b.insert(0, [[[2]]]) + | ~~~~~~~ + 13 | b.insert(0, [[[['aa']]]]) + 14 | println(b) +vlib/v/checker/tests/array_insert_type_mismatch.vv:13:14: error: cannot insert `[][][][]string` to `[][]int` + 11 | mut b := [[1, 2, 3]] + 12 | b.insert(0, [[[2]]]) + 13 | b.insert(0, [[[['aa']]]]) + | ~~~~~~~~~~~~ + 14 | println(b) + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.vv new file mode 100644 index 0000000..518b44a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_insert_type_mismatch.vv @@ -0,0 +1,15 @@ +fn main() { + mut a := [1, 2] + a.insert(1, 2.3) + a.insert(1, 'abc') + a.insert(1, [1.1, 2.2]) + a.insert(1, ['aa', 'bb', 'cc']) + a.insert(1, [[1]]) + a.insert(1, [[['aa']]]) + println(a) + + mut b := [[1, 2, 3]] + b.insert(0, [[[2]]]) + b.insert(0, [[[['aa']]]]) + println(b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.out b/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.out new file mode 100644 index 0000000..eaec4f9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/array_literal_modify_err.vv:2:24: error: array append cannot be used in an expression + 1 | fn main() { + 2 | mut nums := [1, 2, 3] << 4 + | ~~ + 3 | println(nums) + 4 | } +vlib/v/checker/tests/array_literal_modify_err.vv:3:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | mut nums := [1, 2, 3] << 4 + 3 | println(nums) + | ~~~~~~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.vv new file mode 100644 index 0000000..79c7f97 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_literal_modify_err.vv @@ -0,0 +1,4 @@ +fn main() { + mut nums := [1, 2, 3] << 4 + println(nums) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.out new file mode 100644 index 0000000..8e06495 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/array_map_arg_mismatch.vv:3:4: error: expected 1 argument, but got 0 + 1 | fn main() { + 2 | a := [1, 2, 3] + 3 | a.map() + | ~~~~~ + 4 | a.map(it * 2, 3) + 5 | } +vlib/v/checker/tests/array_map_arg_mismatch.vv:4:4: error: expected 1 argument, but got 2 + 2 | a := [1, 2, 3] + 3 | a.map() + 4 | a.map(it * 2, 3) + | ~~~~~~~~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.vv new file mode 100644 index 0000000..629707b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_arg_mismatch.vv @@ -0,0 +1,5 @@ +fn main() { + a := [1, 2, 3] + a.map() + a.map(it * 2, 3) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.out new file mode 100644 index 0000000..b4df650 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.out @@ -0,0 +1,41 @@ +vlib/v/checker/tests/array_map_fn_err.vv:2:22: error: function needs exactly 1 argument + 1 | fn main() { + 2 | a1 := [1,2,3,4].map(fn(a int, b int) int {return a + b}) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 3 | println(a1) + 4 | +vlib/v/checker/tests/array_map_fn_err.vv:5:22: error: type mismatch, should use `fn(a int) T {...}` + 3 | println(a1) + 4 | + 5 | a2 := [1,2,3,4].map(fn(a string) string { return a }) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | println(a2) + 7 | +vlib/v/checker/tests/array_map_fn_err.vv:8:22: error: type mismatch, should use `fn(a int) T {...}` + 6 | println(a2) + 7 | + 8 | a3 := [1,2,3,4].map(fn(a string) {}) + | ~~~~~~~~~~~~~~~ + 9 | println(a3) + 10 | +vlib/v/checker/tests/array_map_fn_err.vv:11:18: error: function needs exactly 1 argument + 9 | println(a3) + 10 | + 11 | a4 := [1,2,3,4].map(add1) + | ~~~~~~~~~ + 12 | println(a4) + 13 | +vlib/v/checker/tests/array_map_fn_err.vv:14:22: error: type mismatch, should use `fn(a int) T {...}` + 12 | println(a4) + 13 | + 14 | a5 := [1,2,3,4].map(add2) + | ~~~~ + 15 | println(a5) + 16 | +vlib/v/checker/tests/array_map_fn_err.vv:17:22: error: type mismatch, should use `fn(a int) T {...}` + 15 | println(a5) + 16 | + 17 | a6 := [1,2,3,4].map(do_nothing) + | ~~~~~~~~~~ + 18 | println(a6) + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.vv new file mode 100644 index 0000000..50d0241 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_fn_err.vv @@ -0,0 +1,30 @@ +fn main() { + a1 := [1,2,3,4].map(fn(a int, b int) int {return a + b}) + println(a1) + + a2 := [1,2,3,4].map(fn(a string) string { return a }) + println(a2) + + a3 := [1,2,3,4].map(fn(a string) {}) + println(a3) + + a4 := [1,2,3,4].map(add1) + println(a4) + + a5 := [1,2,3,4].map(add2) + println(a5) + + a6 := [1,2,3,4].map(do_nothing) + println(a6) +} + +fn add1(a int, b int) int { + return a + b +} + +fn add2(a string) string { + return a +} + +fn do_nothing(a string) { +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.out new file mode 100644 index 0000000..9bd41e1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/array_map_void_fn_err.vv:3:12: error: type mismatch, `println` does not return anything + 1 | fn main(){ + 2 | array := [1,2,3,4] + 3 | array.map(println(it)) + | ~~~~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.vv new file mode 100644 index 0000000..e429c8a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_map_void_fn_err.vv @@ -0,0 +1,4 @@ +fn main(){ + array := [1,2,3,4] + array.map(println(it)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.out b/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.out new file mode 100644 index 0000000..bfd51b0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/array_of_interfaces_with_len_without_init.vv:14:37: error: cannot instantiate an array of interfaces without also giving a default `init:` value + 12 | + 13 | fn main() { + 14 | mut parsed_lines := []MObject{len: 9} + | ^ + 15 | println(parsed_lines) + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.vv b/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.vv new file mode 100644 index 0000000..d9bc2d7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_of_interfaces_with_len_without_init.vv @@ -0,0 +1,16 @@ +interface MObject { + give_string() string +} + +struct LeStruct { + le_string string +} + +fn (a LeStruct) give_string() string { + return 'V' +} + +fn main() { + mut parsed_lines := []MObject{len: 9} + println(parsed_lines) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.out b/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.out new file mode 100644 index 0000000..fca758b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.out @@ -0,0 +1,35 @@ +vlib/v/checker/tests/array_or_map_assign_err.vv:3:5: error: use `array2 := array1.clone()` instead of `array2 := array1` (or use `unsafe`) + 1 | fn main() { + 2 | a1 := [1, 2, 3] + 3 | a2 := a1 + | ~~ + 4 | mut a3 := []int{} + 5 | a3 = a1 +vlib/v/checker/tests/array_or_map_assign_err.vv:5:5: error: use `array2 = array1.clone()` instead of `array2 = array1` (or use `unsafe`) + 3 | a2 := a1 + 4 | mut a3 := []int{} + 5 | a3 = a1 + | ^ + 6 | + 7 | m1 := map{'one': 1} +vlib/v/checker/tests/array_or_map_assign_err.vv:8:8: error: cannot copy map: call `move` or `clone` method (or use a reference) + 6 | + 7 | m1 := map{'one': 1} + 8 | m2 := m1 + | ~~ + 9 | mut m3 := map[string]int{} + 10 | m3 = m1 +vlib/v/checker/tests/array_or_map_assign_err.vv:10:7: error: cannot copy map: call `move` or `clone` method (or use a reference) + 8 | m2 := m1 + 9 | mut m3 := map[string]int{} + 10 | m3 = m1 + | ~~ + 11 | + 12 | _ = a2 +vlib/v/checker/tests/array_or_map_assign_err.vv:25:8: error: cannot copy map: call `move` or `clone` method (or use a reference) + 23 | + 24 | fn foo(mut m map[string]int) { + 25 | m2 := m + | ^ + 26 | m['foo'] = 100 + 27 | println(m) diff --git a/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.vv new file mode 100644 index 0000000..517a25d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_or_map_assign_err.vv @@ -0,0 +1,29 @@ +fn main() { + a1 := [1, 2, 3] + a2 := a1 + mut a3 := []int{} + a3 = a1 + + m1 := map{'one': 1} + m2 := m1 + mut m3 := map[string]int{} + m3 = m1 + + _ = a2 + _ = m2 + + mut m := map{'foo':1} + foo(mut m) + + _ = a3 + _ = m1 + _ = m2 + _ = m3 +} + +fn foo(mut m map[string]int) { + m2 := m + m['foo'] = 100 + println(m) + println(m2) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.out new file mode 100644 index 0000000..8e74b7f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.out @@ -0,0 +1,56 @@ +vlib/v/checker/tests/array_prepend_type_mismatch.vv:3:12: error: cannot prepend `float literal` to `[]int` + 1 | fn main() { + 2 | mut a := [1, 2] + 3 | a.prepend(2.3) + | ~~~ + 4 | a.prepend('abc') + 5 | a.prepend([2.2, 3.3]) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:4:12: error: cannot prepend `string` to `[]int` + 2 | mut a := [1, 2] + 3 | a.prepend(2.3) + 4 | a.prepend('abc') + | ~~~~~ + 5 | a.prepend([2.2, 3.3]) + 6 | a.prepend(['aa', 'bb', 'cc']) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:5:12: error: cannot prepend `[]f64` to `[]int` + 3 | a.prepend(2.3) + 4 | a.prepend('abc') + 5 | a.prepend([2.2, 3.3]) + | ~~~~~~~~~~ + 6 | a.prepend(['aa', 'bb', 'cc']) + 7 | a.prepend([[1]]) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:6:12: error: cannot prepend `[]string` to `[]int` + 4 | a.prepend('abc') + 5 | a.prepend([2.2, 3.3]) + 6 | a.prepend(['aa', 'bb', 'cc']) + | ~~~~~~~~~~~~~~~~~~ + 7 | a.prepend([[1]]) + 8 | a.prepend([[['aa']]]) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:7:12: error: cannot prepend `[][]int` to `[]int` + 5 | a.prepend([2.2, 3.3]) + 6 | a.prepend(['aa', 'bb', 'cc']) + 7 | a.prepend([[1]]) + | ~~~~~ + 8 | a.prepend([[['aa']]]) + 9 | println(a) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:8:12: error: cannot prepend `[][][]string` to `[]int` + 6 | a.prepend(['aa', 'bb', 'cc']) + 7 | a.prepend([[1]]) + 8 | a.prepend([[['aa']]]) + | ~~~~~~~~~~ + 9 | println(a) + 10 | +vlib/v/checker/tests/array_prepend_type_mismatch.vv:12:12: error: cannot prepend `[][][]int` to `[][]int` + 10 | + 11 | mut b := [[1, 2, 3]] + 12 | b.prepend([[[2]]]) + | ~~~~~~~ + 13 | b.prepend([[[['aa']]]]) + 14 | println(b) +vlib/v/checker/tests/array_prepend_type_mismatch.vv:13:12: error: cannot prepend `[][][][]string` to `[][]int` + 11 | mut b := [[1, 2, 3]] + 12 | b.prepend([[[2]]]) + 13 | b.prepend([[[['aa']]]]) + | ~~~~~~~~~~~~ + 14 | println(b) + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.vv new file mode 100644 index 0000000..925156e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_prepend_type_mismatch.vv @@ -0,0 +1,15 @@ +fn main() { + mut a := [1, 2] + a.prepend(2.3) + a.prepend('abc') + a.prepend([2.2, 3.3]) + a.prepend(['aa', 'bb', 'cc']) + a.prepend([[1]]) + a.prepend([[['aa']]]) + println(a) + + mut b := [[1, 2, 3]] + b.prepend([[[2]]]) + b.prepend([[[['aa']]]]) + println(b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_sort_err.out b/v_windows/v/old/vlib/v/checker/tests/array_sort_err.out new file mode 100644 index 0000000..04c3dbf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_sort_err.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/array_sort_err.vv:3:6: error: expected 0 or 1 argument, but got 2 + 1 | fn main() { + 2 | mut arr := [3, 2, 1] + 3 | arr.sort(a < b, a) + | ~~~~~~~~~~~~~~ + 4 | arr.sort(a == b) + 5 | arr.sort(a > a) +vlib/v/checker/tests/array_sort_err.vv:4:9: error: `.sort()` can only use `<` or `>` comparison + 2 | mut arr := [3, 2, 1] + 3 | arr.sort(a < b, a) + 4 | arr.sort(a == b) + | ~~~~~~~~~~~~ + 5 | arr.sort(a > a) + 6 | arr.sort(c > d) +vlib/v/checker/tests/array_sort_err.vv:5:9: error: `.sort()` cannot use same argument + 3 | arr.sort(a < b, a) + 4 | arr.sort(a == b) + 5 | arr.sort(a > a) + | ~~~~~~~~~~~ + 6 | arr.sort(c > d) + 7 | } +vlib/v/checker/tests/array_sort_err.vv:6:9: error: `.sort()` can only use `a` or `b` as argument, e.g. `arr.sort(a < b)` + 4 | arr.sort(a == b) + 5 | arr.sort(a > a) + 6 | arr.sort(c > d) + | ~~~~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/array_sort_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_sort_err.vv new file mode 100644 index 0000000..821cfd0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_sort_err.vv @@ -0,0 +1,7 @@ +fn main() { + mut arr := [3, 2, 1] + arr.sort(a < b, a) + arr.sort(a == b) + arr.sort(a > a) + arr.sort(c > d) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.out b/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.out new file mode 100644 index 0000000..dd83a0b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/array_sort_struct_no_body_err.vv:6:5: error: custom sorting condition must be supplied for type `Foo` + 4 | + 5 | mut arr := []Foo{} + 6 | arr.sort() + | ~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.vv b/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.vv new file mode 100644 index 0000000..6b53ea9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/array_sort_struct_no_body_err.vv @@ -0,0 +1,6 @@ +struct Foo { + bar int +} + +mut arr := []Foo{} +arr.sort() diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.out b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.out new file mode 100644 index 0000000..9f838fd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.vv:4:2: error: cannot push on non-channel `i64` + 2 | ch := i64(3) + 3 | obj := 5 + 4 | ch <- obj + | ~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.vv new file mode 100644 index 0000000..d205205 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_a.vv @@ -0,0 +1,5 @@ +fn main() { + ch := i64(3) + obj := 5 + ch <- obj +} diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.out b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.out new file mode 100644 index 0000000..61d6c99 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.vv:4:8: error: cannot assign to `obj`: expected `int`, not `string` + 2 | ch := chan string{} + 3 | mut obj := 9 + 4 | obj = <-ch + | ~~ + 5 | _ = obj + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000..3e842d9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_left_type_err_b.vv @@ -0,0 +1,6 @@ +fn main() { + ch := chan string{} + mut obj := 9 + obj = <-ch + _ = obj +} diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.out b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.out new file mode 100644 index 0000000..e16afc8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.vv:4:8: error: cannot push `string` on `chan u64` + 2 | ch := chan u64{cap: 10} + 3 | obj := 'test' + 4 | ch <- obj + | ~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.vv new file mode 100644 index 0000000..f74184d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_a.vv @@ -0,0 +1,5 @@ +fn main() { + ch := chan u64{cap: 10} + obj := 'test' + ch <- obj +} diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.out b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.out new file mode 100644 index 0000000..ae9be38 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.vv:3:9: error: <- operator can only be used with `chan` types + 1 | fn main() { + 2 | ch := i64(3) + 3 | obj := <-ch + | ~~ + 4 | println(obj) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000..48de2bf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/arrow_op_wrong_right_type_err_b.vv @@ -0,0 +1,5 @@ +fn main() { + ch := i64(3) + obj := <-ch + println(obj) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.out b/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.out new file mode 100644 index 0000000..2153ae9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/asm_immutable_err.vv:9:9: error: `c` is immutable, declare it with `mut` to make it mutable + 7 | add eax, b + 8 | mov c, eax + 9 | ; =r (c) // output + | ^ + 10 | ; r (a) // input + 11 | r (b)
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.vv b/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.vv new file mode 100644 index 0000000..e991206 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/asm_immutable_err.vv @@ -0,0 +1,16 @@ +fn main() { + a := 100 + b := 20 + c := 0 + asm amd64 { + mov eax, a + add eax, b + mov c, eax + ; =r (c) // output + ; r (a) // input + r (b) + } + println('a: $a') // 100 + println('b: $b') // 20 + println('c: $c') // 120 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.out b/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.out new file mode 100644 index 0000000..9d2f49a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assert_optional_err.vv:4:9: error: assert can be used only with `bool` expressions, but found `void` instead + 2 | + 3 | fn main(){ + 4 | assert os.truncate("testfile.txt", 6666) or { panic(err) } + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.vv b/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.vv new file mode 100644 index 0000000..7036616 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assert_optional_err.vv @@ -0,0 +1,5 @@ +import os + +fn main(){ + assert os.truncate("testfile.txt", 6666) or { panic(err) } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.out b/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.out new file mode 100644 index 0000000..b04c3f7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/assign_array_init_with_no_type.vv:2:11: error: array_init: no type specified (maybe: `[]Type{}` instead of `[]`) + 1 | fn main() { + 2 | mut x := [] + | ~~ + 3 | println(x) + 4 | } +vlib/v/checker/tests/assign_array_init_with_no_type.vv:3:2: error: `println` can not print void expressions + 1 | fn main() { + 2 | mut x := [] + 3 | println(x) + | ~~~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.vv b/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.vv new file mode 100644 index 0000000..cc06a55 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_array_init_with_no_type.vv @@ -0,0 +1,4 @@ +fn main() { + mut x := [] + println(x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out b/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out new file mode 100644 index 0000000..d26ab1b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv:8:2: error: cannot dereference a function call on the left side of an assignment, use a temporary variable + 6 | + 7 | fn main() { + 8 | *foo('s') = 1 + | ^ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv b/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv new file mode 100644 index 0000000..50aa22b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_deref_fn_call_on_left_side_err.vv @@ -0,0 +1,9 @@ +struct Foo{} + +fn foo(s string) &Foo { + return &Foo{} +} + +fn main() { + *foo('s') = 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.out new file mode 100644 index 0000000..cba2860 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_a.vv:3:2: error: operator <<= not defined on left operand type `f64` + 1 | fn main() { + 2 | mut foo := 0.5 + 3 | foo <<= 1 + | ~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.vv new file mode 100644 index 0000000..8ea403d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_a.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 0.5 + foo <<= 1 + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.out new file mode 100644 index 0000000..e5f01ca --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_b.vv:3:9: error: operator %= not defined on right operand type `string` + 1 | fn main() { + 2 | mut foo := 10 + 3 | foo %= 'hello' + | ~~~~~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.vv new file mode 100644 index 0000000..db28266 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_b.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 10 + foo %= 'hello' + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.out new file mode 100644 index 0000000..338ce5b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_c.vv:3:2: error: operator *= not defined on left operand type `string` + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo *= 10 + | ~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.vv new file mode 100644 index 0000000..98409ac --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_c.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 'hello' + foo *= 10 + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.out new file mode 100644 index 0000000..7753629 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_d.vv:3:9: error: operator /= not defined on right operand type `bool` + 1 | fn main() { + 2 | mut foo := 1.5 + 3 | foo /= true + | ~~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.vv new file mode 100644 index 0000000..ca5c0ee --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_d.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 1.5 + foo /= true + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.out new file mode 100644 index 0000000..b8acd99 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_e.vv:3:2: error: operator `-=` not defined on left operand type `string` + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo -= `a` + | ~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.vv new file mode 100644 index 0000000..b6a4473 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_e.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 'hello' + foo -= `a` + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.out new file mode 100644 index 0000000..7cdaa51 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_f.vv:3:9: error: invalid right operand: int -= bool + 1 | fn main() { + 2 | mut foo := 10 + 3 | foo -= false + | ~~~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.vv new file mode 100644 index 0000000..70213c4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_f.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 10 + foo -= false + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.out new file mode 100644 index 0000000..e017d7b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_g.vv:3:2: error: operator `+=` not defined on left operand type `bool` + 1 | fn main() { + 2 | mut foo := true + 3 | foo += false + | ~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.vv new file mode 100644 index 0000000..c9380f4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_g.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := true + foo += false + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.out new file mode 100644 index 0000000..07d2b6e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_h.vv:3:9: error: invalid right operand: string += bool + 1 | fn main() { + 2 | mut foo := 'hello' + 3 | foo += false + | ~~~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.vv new file mode 100644 index 0000000..51b2207 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_h.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 'hello' + foo += false + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.out new file mode 100644 index 0000000..c8450f0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_type_err_i.vv:3:9: error: invalid right operand: f64 += string + 1 | fn main() { + 2 | mut foo := 1.5 + 3 | foo += 'hello' + | ~~~~~~~ + 4 | _ = foo + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.vv new file mode 100644 index 0000000..2debbae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_type_err_i.vv @@ -0,0 +1,5 @@ +fn main() { + mut foo := 1.5 + foo += 'hello' + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.out new file mode 100644 index 0000000..d7aaac0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_a.vv:2:7: error: undefined variable: `a` + 1 | fn main() { + 2 | a := a + | ^ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.vv new file mode 100644 index 0000000..05ffdf4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_a.vv @@ -0,0 +1,4 @@ +fn main() { + a := a + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.out new file mode 100644 index 0000000..f43a641 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_b.vv:2:10: error: undefined variable: `a` + 1 | fn main() { + 2 | a, b := a, b + | ^ + 3 | println('$a, $b') + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.vv new file mode 100644 index 0000000..b77ab6c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_b.vv @@ -0,0 +1,4 @@ +fn main() { + a, b := a, b + println('$a, $b') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.out new file mode 100644 index 0000000..a68f329 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_c.vv:2:10: error: undefined variable: `a` + 1 | fn main() { + 2 | a, b := a + 1, b * 3 + | ^ + 3 | println('$a, $b') + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.vv new file mode 100644 index 0000000..b845893 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a, b := a + 1, b * 3 + println('$a, $b') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.out new file mode 100644 index 0000000..4a8df88 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_d.vv:2:9: error: undefined variable: `s` + 1 | fn main() { + 2 | s := '$s' + | ^ + 3 | println(s) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.vv new file mode 100644 index 0000000..f9acc47 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_d.vv @@ -0,0 +1,4 @@ +fn main() { + s := '$s' + println(s) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.out new file mode 100644 index 0000000..e505e4c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_e.vv:2:11: error: undefined variable: `a` + 1 | fn main() { + 2 | a, b := -a, -b + | ^ + 3 | println(s) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.vv new file mode 100644 index 0000000..47e4ed5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_e.vv @@ -0,0 +1,4 @@ +fn main() { + a, b := -a, -b + println(s) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.out new file mode 100644 index 0000000..1b1f926 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_f.vv:2:12: error: undefined variable: `a` + 1 | fn main() { + 2 | a, b := (-a + 1), 1 + | ^ + 3 | println('$a, $b') + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.vv new file mode 100644 index 0000000..79ec348 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_f.vv @@ -0,0 +1,4 @@ +fn main() { + a, b := (-a + 1), 1 + println('$a, $b') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.out new file mode 100644 index 0000000..277bbaf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/assign_expr_undefined_err_g.vv:2:14: error: undefined variable: `file` + 1 | fn main() { + 2 | mut file := file.open_file('bees.pdf', 'rw', 0o666) + | ~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.vv new file mode 100644 index 0000000..b589a78 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_g.vv @@ -0,0 +1,3 @@ +fn main() { + mut file := file.open_file('bees.pdf', 'rw', 0o666) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.out new file mode 100644 index 0000000..9c647c8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_expr_undefined_err_h.vv:6:9: error: undefined variable: `n` + 4 | + 5 | fn main() { + 6 | n := f(n) + | ^ + 7 | println(n) + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.vv new file mode 100644 index 0000000..d872d7e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_h.vv @@ -0,0 +1,8 @@ +fn f(i int) int { + return i +} + +fn main() { + n := f(n) + println(n) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.out new file mode 100644 index 0000000..74705af --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_i.vv:2:23: error: undefined variable: `a` + 1 | fn main() { + 2 | mut a := []int{init: a} + | ^ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.vv new file mode 100644 index 0000000..26d689e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_i.vv @@ -0,0 +1,4 @@ +fn main() { + mut a := []int{init: a} + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.out new file mode 100644 index 0000000..5ca8f5a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_j.vv:2:12: error: undefined variable: `a` + 1 | fn main() { + 2 | mut a := [a] + | ^ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.vv new file mode 100644 index 0000000..0406da7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_j.vv @@ -0,0 +1,4 @@ +fn main() { + mut a := [a] + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.out new file mode 100644 index 0000000..0dd8e1c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_expr_undefined_err_k.vv:2:22: error: undefined variable: `a` + 1 | fn main() { + 2 | mut a := map{'one': a} + | ^ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.vv new file mode 100644 index 0000000..e4d1e89 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_undefined_err_k.vv @@ -0,0 +1,4 @@ +fn main() { + mut a := map{'one': a} + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out b/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out new file mode 100644 index 0000000..5c7e5cf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:2:7: error: undefined variable `b` (used before declaration) + 1 | fn main() { + 2 | a := b + | ^ + 3 | b := c + 4 | c := a +vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv:3:7: error: undefined variable `c` (used before declaration) + 1 | fn main() { + 2 | a := b + 3 | b := c + | ^ + 4 | c := a + 5 | _ = a diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv b/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv new file mode 100644 index 0000000..279d6f5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_expr_unresolved_variables_err_chain.vv @@ -0,0 +1,8 @@ +fn main() { + a := b + b := c + c := a + _ = a + _ = b + _ = c +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.out b/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.out new file mode 100644 index 0000000..6a1a663 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/assign_fn_call_on_left_side_err.vv:6:2: error: cannot call function `foo()` on the left side of an assignment + 4 | + 5 | fn main() { + 6 | foo('s') = 1 + | ~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.vv b/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.vv new file mode 100644 index 0000000..69c26dd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_fn_call_on_left_side_err.vv @@ -0,0 +1,7 @@ +fn foo(s string) int { + return 1 +} + +fn main() { + foo('s') = 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.out b/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.out new file mode 100644 index 0000000..635e020 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/assign_multi_immutable_err.vv:4:2: error: `a` is immutable, declare it with `mut` to make it mutable + 2 | a := 10 + 3 | b := 20 + 4 | a, b = 1, 2 + | ^ + 5 | + 6 | println('$a, $b') +vlib/v/checker/tests/assign_multi_immutable_err.vv:18:5: error: cannot assign to function `error` + 16 | + 17 | fn assign_fn() { + 18 | _, error = g() + | ~~~~~ + 19 | g = f() + 20 | } +vlib/v/checker/tests/assign_multi_immutable_err.vv:19:2: error: cannot assign to function `g` + 17 | fn assign_fn() { + 18 | _, error = g() + 19 | g = f() + | ^ + 20 | } + 21 | diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.vv b/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.vv new file mode 100644 index 0000000..cfed449 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_multi_immutable_err.vv @@ -0,0 +1,21 @@ +fn main() { + a := 10 + b := 20 + a, b = 1, 2 + + println('$a, $b') +} + +fn f() int { + return 2 +} + +fn g() (int, int) { + return 1, 2 +} + +fn assign_fn() { + _, error = g() + g = f() +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.out new file mode 100644 index 0000000..ded3db7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.out @@ -0,0 +1,81 @@ +vlib/v/checker/tests/assign_multi_mismatch.vv:5:3: error: assignment mismatch: 1 variable(s) 2 value(s) + 3 | } + 4 | + 5 | _ := 0, 0 + | ~~ + 6 | _ := f() + 7 | _, _ := f() +vlib/v/checker/tests/assign_multi_mismatch.vv:6:3: error: assignment mismatch: 1 variable(s) but `f()` returns 2 value(s) + 4 | + 5 | _ := 0, 0 + 6 | _ := f() + | ~~ + 7 | _, _ := f() + 8 | _, _ := 0, f() +vlib/v/checker/tests/assign_multi_mismatch.vv:8:12: error: cannot use multi-value (int, int) in single-value context + 6 | _ := f() + 7 | _, _ := f() + 8 | _, _ := 0, f() + | ~~~ + 9 | _, _ := f(), 0 + 10 | _, _, _ := 0, f() +vlib/v/checker/tests/assign_multi_mismatch.vv:9:9: error: cannot use multi-value (int, int) in single-value context + 7 | _, _ := f() + 8 | _, _ := 0, f() + 9 | _, _ := f(), 0 + | ~~~ + 10 | _, _, _ := 0, f() + 11 | _, _, _ := f(), 0 +vlib/v/checker/tests/assign_multi_mismatch.vv:10:15: error: cannot use multi-value (int, int) in single-value context + 8 | _, _ := 0, f() + 9 | _, _ := f(), 0 + 10 | _, _, _ := 0, f() + | ~~~ + 11 | _, _, _ := f(), 0 + 12 | _, _ := f(), f() +vlib/v/checker/tests/assign_multi_mismatch.vv:11:12: error: cannot use multi-value (int, int) in single-value context + 9 | _, _ := f(), 0 + 10 | _, _, _ := 0, f() + 11 | _, _, _ := f(), 0 + | ~~~ + 12 | _, _ := f(), f() + 13 | _, _, _, _ := f(), f() +vlib/v/checker/tests/assign_multi_mismatch.vv:12:9: error: cannot use multi-value (int, int) in single-value context + 10 | _, _, _ := 0, f() + 11 | _, _, _ := f(), 0 + 12 | _, _ := f(), f() + | ~~~ + 13 | _, _, _, _ := f(), f() + 14 | +vlib/v/checker/tests/assign_multi_mismatch.vv:13:15: error: cannot use multi-value (int, int) in single-value context + 11 | _, _, _ := f(), 0 + 12 | _, _ := f(), f() + 13 | _, _, _, _ := f(), f() + | ~~~ + 14 | + 15 | _, _ := 0, match 4 { +vlib/v/checker/tests/assign_multi_mismatch.vv:19:3: error: assignment mismatch: 1 variable(s) 2 value(s) + 17 | else { 1 } + 18 | } + 19 | _ := match 4 { + | ~~ + 20 | 1 { f() } + 21 | else { f() } +vlib/v/checker/tests/assign_multi_mismatch.vv:23:12: error: cannot use multi-value (int, int) in single-value context + 21 | else { f() } + 22 | } + 23 | _, _ := 0, match 4 { + | ~~~~~~~~~ + 24 | 1 { f() } + 25 | else { f() } +vlib/v/checker/tests/assign_multi_mismatch.vv:29:3: error: assignment mismatch: 1 variable(s) 2 value(s) + 27 | + 28 | _, _ := 0, if true { 0 } else { 1 } + 29 | _ := if true { f() } else { f() } + | ~~ + 30 | _, _ := 0, if true { f() } else { f() } +vlib/v/checker/tests/assign_multi_mismatch.vv:30:12: error: cannot use multi-value (int, int) in single-value context + 28 | _, _ := 0, if true { 0 } else { 1 } + 29 | _ := if true { f() } else { f() } + 30 | _, _ := 0, if true { f() } else { f() } + | ~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.vv new file mode 100644 index 0000000..d25815c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_multi_mismatch.vv @@ -0,0 +1,30 @@ +fn f() (int, int) { + return 0, 0 +} + +_ := 0, 0 +_ := f() +_, _ := f() +_, _ := 0, f() +_, _ := f(), 0 +_, _, _ := 0, f() +_, _, _ := f(), 0 +_, _ := f(), f() +_, _, _, _ := f(), f() + +_, _ := 0, match 4 { + 1 { 0 } + else { 1 } +} +_ := match 4 { + 1 { f() } + else { f() } +} +_, _ := 0, match 4 { + 1 { f() } + else { f() } +} + +_, _ := 0, if true { 0 } else { 1 } +_ := if true { f() } else { f() } +_, _ := 0, if true { f() } else { f() } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_mut.out b/v_windows/v/old/vlib/v/checker/tests/assign_mut.out new file mode 100644 index 0000000..93a1d06 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_mut.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_mut.vv:3:11: error: expecting `:=` (e.g. `mut x :=`) + 1 | fn main() { + 2 | mut z := 1 + 3 | mut z = 1 + | ^ + 4 | mut i := 2 + 5 | i, mut z = 2,3 diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_mut.vv b/v_windows/v/old/vlib/v/checker/tests/assign_mut.vv new file mode 100644 index 0000000..be80643 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_mut.vv @@ -0,0 +1,6 @@ +fn main() { + mut z := 1 + mut z = 1 + mut i := 2 + i, mut z = 2,3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.out b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.out new file mode 100644 index 0000000..9e1b60a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_sumtype2_err.vv:13:3: error: cannot assign to field `decl`: expected `Decl`, not `Stmt` + 11 | stmt := Stmt(Decl{}) + 12 | _ := File{ + 13 | decl: stmt + | ~~~~~~~~~~ + 14 | } + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.vv b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.vv new file mode 100644 index 0000000..29e36ce --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype2_err.vv @@ -0,0 +1,15 @@ +type Stmt = Decl | Expr + +struct Decl {} +struct Expr {} + +struct File { + decl Decl +} + +fn main() { + stmt := Stmt(Decl{}) + _ := File{ + decl: stmt + } +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.out b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.out new file mode 100644 index 0000000..ebb4b7a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/assign_sumtype_err.vv:13:9: error: cannot assign to `decl`: expected `Decl`, not `Stmt` + 11 | stmt := Stmt(Decl{}) + 12 | mut decl := Decl{} + 13 | decl = stmt + | ~~~~ + 14 | _ = decl + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.vv b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.vv new file mode 100644 index 0000000..94e6fa1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/assign_sumtype_err.vv @@ -0,0 +1,15 @@ +type Stmt = Decl | Expr + +struct Decl {} +struct Expr {} + +struct File { + decl Decl +} + +fn main() { + stmt := Stmt(Decl{}) + mut decl := Decl{} + decl = stmt + _ = decl +} diff --git a/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.out b/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.out new file mode 100644 index 0000000..e6a1cac --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.out @@ -0,0 +1,8 @@ +vlib/v/checker/tests/bad_types_in_string_inter_lit.vv:1:12: error: expression does not return a value + 1 | println('${exit(0)}') + | ~~~~~~~ + 2 | println('${char(48)}') +vlib/v/checker/tests/bad_types_in_string_inter_lit.vv:2:12: error: expression returning type `char` cannot be used in string interpolation directly, print its address or cast it to an integer instead + 1 | println('${exit(0)}') + 2 | println('${char(48)}') + | ~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.vv b/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.vv new file mode 100644 index 0000000..e4dc26c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bad_types_in_string_inter_lit.vv @@ -0,0 +1,2 @@ +println('${exit(0)}') +println('${char(48)}') diff --git a/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.out new file mode 100644 index 0000000..772f15d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/bin_lit_without_digit_err.vv:2:14: error: number part of this binary is not provided + 1 | fn main() { + 2 | println(0b**) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.vv new file mode 100644 index 0000000..a85579d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bin_lit_without_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0b**) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.out new file mode 100644 index 0000000..e2f993a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/bin_lit_wrong_digit_err.vv:2:18: error: this binary number has unsuitable digit `2` + 1 | fn main() { + 2 | println(0b1112) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.vv new file mode 100644 index 0000000..b8347fa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bin_lit_wrong_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0b1112) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.out b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.out new file mode 100644 index 0000000..e8d7a31 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/bit_op_wrong_left_type_err.vv:2:10: error: left type of `&` cannot be non-integer type `float literal` + 1 | fn main() { + 2 | println(0.5 & 1) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv new file mode 100644 index 0000000..60b0da5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0.5 & 1) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.out b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.out new file mode 100644 index 0000000..7b24344 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/bit_op_wrong_right_type_err.vv:2:14: error: right type of `|` cannot be non-integer type `float literal` + 1 | fn main() { + 2 | println(1 | 0.5) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv new file mode 100644 index 0000000..d9da95c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(1 | 0.5) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.out b/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.out new file mode 100644 index 0000000..9385664 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/blank_ident_invalid_use.vv:2:8: error: undefined ident: `_` (may only be used in assignments) + 1 | fn main() { + 2 | _ := [_] + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.vv b/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.vv new file mode 100644 index 0000000..4be90be --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/blank_ident_invalid_use.vv @@ -0,0 +1,3 @@ +fn main() { + _ := [_] +} diff --git a/v_windows/v/old/vlib/v/checker/tests/blank_modify.out b/v_windows/v/old/vlib/v/checker/tests/blank_modify.out new file mode 100644 index 0000000..e0d02e2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/blank_modify.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/blank_modify.vv:2:2: error: cannot modify blank `_` identifier + 1 | fn main() { + 2 | _ += 1 + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/blank_modify.vv b/v_windows/v/old/vlib/v/checker/tests/blank_modify.vv new file mode 100644 index 0000000..0a22021 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/blank_modify.vv @@ -0,0 +1,3 @@ +fn main() { + _ += 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.out b/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.out new file mode 100644 index 0000000..44a1643 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/bool_string_cast_err.vv:2:13: error: cannot cast type `bool` to string, use `x.str()` instead + 1 | fn main() { + 2 | println(string(true)) + | ~~~~~~~~~~~~ + 3 | println(string(false)) + 4 | } +vlib/v/checker/tests/bool_string_cast_err.vv:3:13: error: cannot cast type `bool` to string, use `x.str()` instead + 1 | fn main() { + 2 | println(string(true)) + 3 | println(string(false)) + | ~~~~~~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.vv b/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.vv new file mode 100644 index 0000000..c261155 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/bool_string_cast_err.vv @@ -0,0 +1,4 @@ +fn main() { + println(string(true)) + println(string(false)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.out new file mode 100644 index 0000000..82b7ab5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/break_anon_fn_err.vv:4:4: error: break statement not within a loop + 2 | for true { + 3 | _ := fn () int { + 4 | break + | ~~~~~ + 5 | return 3 + 6 | }() diff --git a/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.vv new file mode 100644 index 0000000..26586e6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/break_anon_fn_err.vv @@ -0,0 +1,8 @@ +fn main() { + for true { + _ := fn () int { + break + return 3 + }() + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.out b/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.out new file mode 100644 index 0000000..a462c84 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/c_fn_surplus_args.vv:6:7: error: expected 0 arguments, but got 1 + 4 | + 5 | fn main() { + 6 | C.no(1) // allowed + | ^ + 7 | C.y1() + 8 | C.y1(1) // ok +vlib/v/checker/tests/c_fn_surplus_args.vv:7:4: error: expected 1 arguments, but got 0 + 5 | fn main() { + 6 | C.no(1) // allowed + 7 | C.y1() + | ~~~~ + 8 | C.y1(1) // ok + 9 | C.y1(1, 2) +vlib/v/checker/tests/c_fn_surplus_args.vv:9:10: error: expected 1 arguments, but got 2 + 7 | C.y1() + 8 | C.y1(1) // ok + 9 | C.y1(1, 2) + | ^ + 10 | C.ret() // ok + 11 | C.ret(1) +vlib/v/checker/tests/c_fn_surplus_args.vv:11:8: error: expected 0 arguments, but got 1 + 9 | C.y1(1, 2) + 10 | C.ret() // ok + 11 | C.ret(1) + | ^ + 12 | // avoid cgen whilst warning, later above should error + 13 | main() +vlib/v/checker/tests/c_fn_surplus_args.vv:13:2: error: the `main` function cannot be called in the program + 11 | C.ret(1) + 12 | // avoid cgen whilst warning, later above should error + 13 | main() + | ~~~~~~ + 14 | C.af() // ok + 15 | C.af(3) +vlib/v/checker/tests/c_fn_surplus_args.vv:15:7: error: expected 0 arguments, but got 1 + 13 | main() + 14 | C.af() // ok + 15 | C.af(3) + | ^ + 16 | } + 17 | diff --git a/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.vv b/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.vv new file mode 100644 index 0000000..e7c6466 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/c_fn_surplus_args.vv @@ -0,0 +1,19 @@ +fn C.no() // untyped +fn C.y1(int) +fn C.ret()byte + +fn main() { + C.no(1) // allowed + C.y1() + C.y1(1) // ok + C.y1(1, 2) + C.ret() // ok + C.ret(1) + // avoid cgen whilst warning, later above should error + main() + C.af() // ok + C.af(3) +} + +[trusted] +fn C.af()int diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.out b/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.out new file mode 100644 index 0000000..fc82be4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/cannot_assign_array.vv:9:11: error: cannot assign to `ctx.vb`: expected `string`, not `[8]f64` + 7 | mut ctx := Context{} + 8 | x := 2.32 + 9 | ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]! + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.vv b/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.vv new file mode 100644 index 0000000..d6aba2d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_assign_array.vv @@ -0,0 +1,10 @@ +struct Context { + pub mut: + vb string +} + +fn main() { + mut ctx := Context{} + x := 2.32 + ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]! +} diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.out b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.out new file mode 100644 index 0000000..6a7960c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/cannot_cast_to_alias.vv:6:7: error: cannot convert type `int literal` to `MyType` (alias to `string`) + 4 | + 5 | fn main() { + 6 | _ := MyType(5) + | ~~~~~~~~~ + 7 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.vv b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.vv new file mode 100644 index 0000000..1198570 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_alias.vv @@ -0,0 +1,7 @@ +module main + +type MyType = string + +fn main() { + _ := MyType(5) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.out b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.out new file mode 100644 index 0000000..9fe4c10 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/cannot_cast_to_struct.vv:10:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 8 | + 9 | fn main() { + 10 | _ := Test(Abc{}) + | ~~~~~~~~~~~ + 11 | sum := Alphabet(Xyz{}) + 12 | _ = Xyz(sum) +vlib/v/checker/tests/cannot_cast_to_struct.vv:12:6: error: cannot cast `Alphabet` to struct + 10 | _ := Test(Abc{}) + 11 | sum := Alphabet(Xyz{}) + 12 | _ = Xyz(sum) + | ~~~~~~~~ + 13 | _ = Xyz(5) + 14 | s := Abc{} +vlib/v/checker/tests/cannot_cast_to_struct.vv:13:6: error: cannot cast `int literal` to struct + 11 | sum := Alphabet(Xyz{}) + 12 | _ = Xyz(sum) + 13 | _ = Xyz(5) + | ~~~~~~ + 14 | s := Abc{} + 15 | _ = Xyz(&s) +vlib/v/checker/tests/cannot_cast_to_struct.vv:15:6: error: cannot cast `&Abc` to struct + 13 | _ = Xyz(5) + 14 | s := Abc{} + 15 | _ = Xyz(&s) + | ~~~~~~~ + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.vv b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.vv new file mode 100644 index 0000000..64cf7fa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cannot_cast_to_struct.vv @@ -0,0 +1,16 @@ +struct Abc {} +struct Xyz {} +type Alphabet = Abc | Xyz + +struct Test { + abc Alphabet +} + +fn main() { + _ := Test(Abc{}) + sum := Alphabet(Xyz{}) + _ = Xyz(sum) + _ = Xyz(5) + s := Abc{} + _ = Xyz(&s) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_err.out b/v_windows/v/old/vlib/v/checker/tests/cast_err.out new file mode 100644 index 0000000..c78a99d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_err.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/cast_err.vv:3:6: error: cannot cast to bool - use e.g. `some_int != 0` instead + 1 | fn test_bool_cast() { + 2 | v := 3 + 3 | _ = bool(v) + | ~~~~~~~ + 4 | _ = bool(&v) + 5 | _ = bool([2]) +vlib/v/checker/tests/cast_err.vv:4:6: error: cannot cast to bool - use e.g. `some_int != 0` instead + 2 | v := 3 + 3 | _ = bool(v) + 4 | _ = bool(&v) + | ~~~~~~~~ + 5 | _ = bool([2]) + 6 | } +vlib/v/checker/tests/cast_err.vv:5:6: error: cannot cast to bool - use e.g. `some_int != 0` instead + 3 | _ = bool(v) + 4 | _ = bool(&v) + 5 | _ = bool([2]) + | ~~~~~~~~~ + 6 | } + 7 | +vlib/v/checker/tests/cast_err.vv:9:6: error: unknown type `Foo` + 7 | + 8 | fn unknown() { + 9 | _ = Foo(3) + | ~~~~~~ + 10 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_err.vv b/v_windows/v/old/vlib/v/checker/tests/cast_err.vv new file mode 100644 index 0000000..bcf8ad3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_err.vv @@ -0,0 +1,10 @@ +fn test_bool_cast() { + v := 3 + _ = bool(v) + _ = bool(&v) + _ = bool([2]) +} + +fn unknown() { + _ = Foo(3) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_string_err.out b/v_windows/v/old/vlib/v/checker/tests/cast_string_err.out new file mode 100644 index 0000000..3c09bf4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_string_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/cast_string_err.vv:2:7: error: cannot cast type `int literal` to string, use `x.str()` instead + 1 | fn main() { + 2 | a := string(1) + | ~~~~~~~~~ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_string_err.vv b/v_windows/v/old/vlib/v/checker/tests/cast_string_err.vv new file mode 100644 index 0000000..56247ce --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_string_err.vv @@ -0,0 +1,4 @@ +fn main() { + a := string(1) + println(a) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.out b/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.out new file mode 100644 index 0000000..1b04218 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/cast_string_with_byte_err.vv:2:12: error: can not cast type `byte` to string, use `by.str()` instead. + 1 | for by in 'abc' { + 2 | println(string(by)) + | ~~~~~~~~~~ + 3 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.vv b/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.vv new file mode 100644 index 0000000..4626e28 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_string_with_byte_err.vv @@ -0,0 +1,3 @@ +for by in 'abc' { + println(string(by)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_void.out b/v_windows/v/old/vlib/v/checker/tests/cast_void.out new file mode 100644 index 0000000..ddd389a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_void.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/cast_void.vv:1:12: error: expression does not return a value so it cannot be cast + 1 | num := int(print('')) + | ~~~~~~~~~ + 2 | println(num) diff --git a/v_windows/v/old/vlib/v/checker/tests/cast_void.vv b/v_windows/v/old/vlib/v/checker/tests/cast_void.vv new file mode 100644 index 0000000..1b61f14 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/cast_void.vv @@ -0,0 +1,2 @@ +num := int(print('')) +println(num) diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_args.out b/v_windows/v/old/vlib/v/checker/tests/chan_args.out new file mode 100644 index 0000000..605bcfe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_args.out @@ -0,0 +1,28 @@ +vlib/v/checker/tests/chan_args.vv:4:19: error: cannot use `int` as `&f64` in argument 1 to `chan f64.try_push` + 2 | ch := chan f64{cap: 5} + 3 | a := 2 + 4 | _ := ch.try_push(a) + | ^ + 5 | _ := ch.try_push(2.5) + 6 | b := 2.5 +vlib/v/checker/tests/chan_args.vv:5:19: error: cannot use `float literal` as `&f64` in argument 1 to `chan f64.try_push` + 3 | a := 2 + 4 | _ := ch.try_push(a) + 5 | _ := ch.try_push(2.5) + | ~~~ + 6 | b := 2.5 + 7 | _ := ch.try_pop(b) +vlib/v/checker/tests/chan_args.vv:7:18: error: `try_pop` parameter `obj` is `mut`, you need to provide `mut` e.g. `mut arg1` + 5 | _ := ch.try_push(2.5) + 6 | b := 2.5 + 7 | _ := ch.try_pop(b) + | ^ + 8 | // this should work: + 9 | _ := ch.try_push(b) +vlib/v/checker/tests/chan_args.vv:11:22: error: cannot use `int` as argument for `try_pop` (`f64` expected) + 9 | _ := ch.try_push(b) + 10 | mut c := 7 + 11 | _ := ch.try_pop(mut c) + | ^ + 12 | mut x := 12.5 + 13 | // this should work: diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_args.vv b/v_windows/v/old/vlib/v/checker/tests/chan_args.vv new file mode 100644 index 0000000..ce16cd8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_args.vv @@ -0,0 +1,15 @@ +fn main() { + ch := chan f64{cap: 5} + a := 2 + _ := ch.try_push(a) + _ := ch.try_push(2.5) + b := 2.5 + _ := ch.try_pop(b) + // this should work: + _ := ch.try_push(b) + mut c := 7 + _ := ch.try_pop(mut c) + mut x := 12.5 + // this should work: + _ := ch.try_pop(mut x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_mut.out b/v_windows/v/old/vlib/v/checker/tests/chan_mut.out new file mode 100644 index 0000000..e82419b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_mut.out @@ -0,0 +1,28 @@ +vlib/v/checker/tests/chan_mut.vv:8:8: error: `v` is immutable, declare it with `mut` to make it mutable + 6 | fn f(ch chan mut St) { + 7 | v := St{} + 8 | ch <- v + | ^ + 9 | mut w := St{} + 10 | ch <- w +vlib/v/checker/tests/chan_mut.vv:10:8: error: cannot push non-reference `St` on `chan mut St` + 8 | ch <- v + 9 | mut w := St{} + 10 | ch <- w + | ^ + 11 | x := &St{} + 12 | ch <- x +vlib/v/checker/tests/chan_mut.vv:12:8: error: `x` is immutable, declare it with `mut` to make it mutable + 10 | ch <- w + 11 | x := &St{} + 12 | ch <- x + | ^ + 13 | mut y := St{} + 14 | ch <- y +vlib/v/checker/tests/chan_mut.vv:14:8: error: cannot push non-reference `St` on `chan mut St` + 12 | ch <- x + 13 | mut y := St{} + 14 | ch <- y + | ^ + 15 | mut z := &St{n: 7} + 16 | // this works diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_mut.vv b/v_windows/v/old/vlib/v/checker/tests/chan_mut.vv new file mode 100644 index 0000000..1250c51 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_mut.vv @@ -0,0 +1,27 @@ +struct St{ +mut: + n int +} + +fn f(ch chan mut St) { + v := St{} + ch <- v + mut w := St{} + ch <- w + x := &St{} + ch <- x + mut y := St{} + ch <- y + mut z := &St{n: 7} + // this works + ch <- z +} + +fn main() { + c := chan mut St{} + go f(c) + mut y := <-c + z := <-c + println(y) + println(z) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_ref.out b/v_windows/v/old/vlib/v/checker/tests/chan_ref.out new file mode 100644 index 0000000..3eeb76b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_ref.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/chan_ref.vv:10:8: error: cannot push non-reference `St` on `chan &St` + 8 | fn f(ch chan &St, mut sem sync.Semaphore) { + 9 | w := St{} + 10 | ch <- w + | ^ + 11 | mut x := St{} + 12 | ch <- x +vlib/v/checker/tests/chan_ref.vv:12:8: error: cannot push non-reference `St` on `chan &St` + 10 | ch <- w + 11 | mut x := St{} + 12 | ch <- x + | ^ + 13 | // the following works + 14 | y := &St{} diff --git a/v_windows/v/old/vlib/v/checker/tests/chan_ref.vv b/v_windows/v/old/vlib/v/checker/tests/chan_ref.vv new file mode 100644 index 0000000..ad3dcec --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/chan_ref.vv @@ -0,0 +1,33 @@ +import sync + +struct St{ +mut: + n int +} + +fn f(ch chan &St, mut sem sync.Semaphore) { + w := St{} + ch <- w + mut x := St{} + ch <- x + // the following works + y := &St{} + ch <- y + mut z := &St{} + ch <- z + sem.wait() + println(z) +} + +fn main() { + c := chan &St{} + mut sem := sync.new_semaphore() + go f(c, mut sem) + y := <-c + // this should fail + mut z := <-c + z.n = 9 + sem.post() + println(y) + println(z) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/char_str.out b/v_windows/v/old/vlib/v/checker/tests/char_str.out new file mode 100644 index 0000000..9779e64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/char_str.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/char_str.vv:1:1: error: calling `.str()` on type `char` is not allowed, use its address or cast it to an integer instead + 1 | char(91).str() + | ~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/char_str.vv b/v_windows/v/old/vlib/v/checker/tests/char_str.vv new file mode 100644 index 0000000..88d9a9b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/char_str.vv @@ -0,0 +1 @@ +char(91).str() diff --git a/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.out b/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.out new file mode 100644 index 0000000..3b8aae9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.vv:12:7: error: possible type mismatch of compared values of `==` operation + 10 | x := ityp == ast.string_type + 11 | // the next line should produce at least a warning, or even an error, without an explicit cast: + 12 | z := isym == ast.string_type + | ~~~~~~~~~~~~~~~~~~~~~~~ + 13 | println(typeof(isym).name) + 14 | println(typeof(ast.string_type).name) diff --git a/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.vv b/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.vv new file mode 100644 index 0000000..6a307d3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comparing_typesymbol_to_a_type_should_not_compile.vv @@ -0,0 +1,17 @@ +import v.ast + +fn main() { + t := ast.new_table() + ityp := ast.int_type + isym := t.get_type_symbol(ityp) + println(ityp.debug()) + println(isym) + println(isym.debug()) + x := ityp == ast.string_type + // the next line should produce at least a warning, or even an error, without an explicit cast: + z := isym == ast.string_type + println(typeof(isym).name) + println(typeof(ast.string_type).name) + println(x) + println(z) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.out b/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.out new file mode 100644 index 0000000..de71203 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/comptime_call_method.vv:10:14: error: undefined ident: `wrong` + 8 | s1 := S1{} + 9 | $for method in S1.methods { + 10 | s1.$method(wrong) + | ~~~~~ + 11 | } + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.vv new file mode 100644 index 0000000..2c21789 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_call_method.vv @@ -0,0 +1,12 @@ +struct S1 {} + +fn (t S1) m(s string) int { + return 7 +} + +fn test_methods_arg() { + s1 := S1{} + $for method in S1.methods { + s1.$method(wrong) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.out b/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.out new file mode 100644 index 0000000..17aae7c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/comptime_call_no_unused_var.vv:11:8: error: unknown identifier `w` + 9 | abc := 'print' + 10 | test.$abc() // OK + 11 | test.$w() + | ^ + 12 | v := 4 + 13 | test.$v() +vlib/v/checker/tests/comptime_call_no_unused_var.vv:13:8: error: invalid string method call: expected `string`, not `int` + 11 | test.$w() + 12 | v := 4 + 13 | test.$v() + | ^ + 14 | s := 'x' + 'y' + 15 | test.$s() +vlib/v/checker/tests/comptime_call_no_unused_var.vv:15:8: error: todo: not a string literal + 13 | test.$v() + 14 | s := 'x' + 'y' + 15 | test.$s() + | ^ + 16 | s2 := 'x' + 17 | test.$s2() +vlib/v/checker/tests/comptime_call_no_unused_var.vv:17:8: error: could not find method `x` + 15 | test.$s() + 16 | s2 := 'x' + 17 | test.$s2() + | ~~ + 18 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.vv new file mode 100644 index 0000000..b38c031 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_call_no_unused_var.vv @@ -0,0 +1,18 @@ +struct Test {} + +fn (test Test) print() { + println('test') +} + +fn main() { + test := Test{} + abc := 'print' + test.$abc() // OK + test.$w() + v := 4 + test.$v() + s := 'x' + 'y' + test.$s() + s2 := 'x' + test.$s2() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.run.out new file mode 100644 index 0000000..098d716 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.run.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/comptime_env/env_parser_errors_1.vv:1:1: error: supply an env variable name like HOME, PATH or USER + 1 | #flag -I $env('')/xyz + | ~~~~~~~~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.vv new file mode 100644 index 0000000..83b2ff3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_1.vv @@ -0,0 +1 @@ +#flag -I $env('')/xyz diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.run.out new file mode 100644 index 0000000..0cc6a11 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.run.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/comptime_env/env_parser_errors_2.vv:1:1: error: cannot use string interpolation in compile time $env() expression + 1 | #flag -I $env('$ABC')/xyz + | ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.vv new file mode 100644 index 0000000..abd0b76 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_2.vv @@ -0,0 +1 @@ +#flag -I $env('$ABC')/xyz diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.run.out new file mode 100644 index 0000000..eab0231 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.run.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/comptime_env/env_parser_errors_3.vv:1:1: error: no "$env('...')" could be found in "-I $env()/xyz". + 1 | #flag -I $env()/xyz + | ~~~~~~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.vv new file mode 100644 index 0000000..98fc6fe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/env_parser_errors_3.vv @@ -0,0 +1 @@ +#flag -I $env()/xyz diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.run.out new file mode 100644 index 0000000..962652a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.run.out @@ -0,0 +1,11 @@ +vlib/v/checker/tests/comptime_env/using_comptime_env.vv:1:1: error: the environment variable "VAR" does not exist. + 1 | #flag -I $env('VAR')/xyz + | ~~~~~~~~~~~~~~~~~~~~~~~~ + 2 | #include "$env('VAR')/stdio.h" + 3 | +vlib/v/checker/tests/comptime_env/using_comptime_env.vv:2:1: error: the environment variable "VAR" does not exist. + 1 | #flag -I $env('VAR')/xyz + 2 | #include "$env('VAR')/stdio.h" + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 3 | + 4 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var.run.out new file mode 100644 index 0000000..012aa03 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var.run.out @@ -0,0 +1,2 @@ +/usr/include +done diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var_invalid.run.out b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var_invalid.run.out new file mode 100644 index 0000000..0739bb2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.var_invalid.run.out @@ -0,0 +1 @@ +builder error: '/opt/invalid/path/stdio.h' not found diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.vv new file mode 100644 index 0000000..f49508c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_env/using_comptime_env.vv @@ -0,0 +1,8 @@ +#flag -I $env('VAR')/xyz +#include "$env('VAR')/stdio.h" + +fn main() { + env := $env('VAR') + println(env) + println('done') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out new file mode 100644 index 0000000..bc3e1f9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv:9:6: error: expected selector expression e.g. `$(field.name)` + 7 | mut t := T{} + 8 | name := 'test' + 9 | t.$(name) = '3' + | ~~~~ + 10 | } + 11 | diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv new file mode 100644 index 0000000..bbbf854 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_in_for_err.vv @@ -0,0 +1,14 @@ +struct Foo { + test int + name string +} + +fn test<T>() { + mut t := T{} + name := 'test' + t.$(name) = '3' +} + +fn main() { + test<Foo>() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.out b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.out new file mode 100644 index 0000000..c53955c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:10:8: error: expected `string` instead of `FieldData` (e.g. `field.name`) + 8 | $for f in T.fields { + 9 | $if f.typ is string { + 10 | t.$(f) = '3' + | ^ + 11 | fv := Foo{} + 12 | _ = t.$(fv.name) +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:12:12: error: unknown `$for` variable `fv` + 10 | t.$(f) = '3' + 11 | fv := Foo{} + 12 | _ = t.$(fv.name) + | ~~ + 13 | } + 14 | } +vlib/v/checker/tests/comptime_field_selector_not_name_err.vv:15:10: error: undefined ident: `f` + 13 | } + 14 | } + 15 | _ = t.$(f.name) + | ^ + 16 | } + 17 | diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.vv new file mode 100644 index 0000000..9efd144 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_field_selector_not_name_err.vv @@ -0,0 +1,20 @@ +struct Foo { + test int + name string +} + +fn test<T>() { + mut t := T{} + $for f in T.fields { + $if f.typ is string { + t.$(f) = '3' + fv := Foo{} + _ = t.$(fv.name) + } + } + _ = t.$(f.name) +} + +fn main() { + test<Foo>() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_for.out b/v_windows/v/old/vlib/v/checker/tests/comptime_for.out new file mode 100644 index 0000000..0eea091 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_for.out @@ -0,0 +1,55 @@ +vlib/v/checker/tests/comptime_for.vv:2:12: error: unknown type `Huh` + 1 | fn unknown() { + 2 | $for m in Huh.methods {} + | ~~~ + 3 | $for f in Huh.fields {} + 4 | $for f in T.fields { +vlib/v/checker/tests/comptime_for.vv:3:12: error: unknown type `Huh` + 1 | fn unknown() { + 2 | $for m in Huh.methods {} + 3 | $for f in Huh.fields {} + | ~~~ + 4 | $for f in T.fields { + 5 | $if f.typ is Huh {} +vlib/v/checker/tests/comptime_for.vv:4:12: error: unknown type `T` + 2 | $for m in Huh.methods {} + 3 | $for f in Huh.fields {} + 4 | $for f in T.fields { + | ^ + 5 | $if f.typ is Huh {} + 6 | $if f.typ is T {} +vlib/v/checker/tests/comptime_for.vv:5:16: error: unknown type `Huh` + 3 | $for f in Huh.fields {} + 4 | $for f in T.fields { + 5 | $if f.typ is Huh {} + | ~~~ + 6 | $if f.typ is T {} + 7 | } +vlib/v/checker/tests/comptime_for.vv:6:16: error: unknown type `T` + 4 | $for f in T.fields { + 5 | $if f.typ is Huh {} + 6 | $if f.typ is T {} + | ^ + 7 | } + 8 | _ = m +vlib/v/checker/tests/comptime_for.vv:8:6: error: undefined ident: `m` + 6 | $if f.typ is T {} + 7 | } + 8 | _ = m + | ^ + 9 | } + 10 | +vlib/v/checker/tests/comptime_for.vv:14:16: error: unknown type `U` + 12 | $for f in T.fields { + 13 | $if f.typ is T {} + 14 | $if f.typ is U {} + | ^ + 15 | } + 16 | _ = f +vlib/v/checker/tests/comptime_for.vv:16:6: error: undefined ident: `f` + 14 | $if f.typ is U {} + 15 | } + 16 | _ = f + | ^ + 17 | } + 18 | diff --git a/v_windows/v/old/vlib/v/checker/tests/comptime_for.vv b/v_windows/v/old/vlib/v/checker/tests/comptime_for.vv new file mode 100644 index 0000000..a6d67a0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/comptime_for.vv @@ -0,0 +1,23 @@ +fn unknown() { + $for m in Huh.methods {} + $for f in Huh.fields {} + $for f in T.fields { + $if f.typ is Huh {} + $if f.typ is T {} + } + _ = m +} + +fn gf<T>() { + $for f in T.fields { + $if f.typ is T {} + $if f.typ is U {} + } + _ = f +} + +struct S1 { + i int +} + +gf<S1>() diff --git a/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.out b/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.out new file mode 100644 index 0000000..8b55d3f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/const_array_unknown_type_err.vv:1:11: error: unknown type `BB`. +Did you mean `AA`? + 1 | type AA = [20]BB + | ~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.vv new file mode 100644 index 0000000..88a2bf7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_array_unknown_type_err.vv @@ -0,0 +1 @@ +type AA = [20]BB diff --git a/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.out b/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.out new file mode 100644 index 0000000..e3b3544 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_define_in_function_err.vv:2:2: error: const can only be defined at the top level (outside of functions) + 1 | fn main() { + 2 | const (a = 1) + | ~~~~~ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.vv new file mode 100644 index 0000000..e6da548 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_define_in_function_err.vv @@ -0,0 +1,4 @@ +fn main() { + const (a = 1) + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.out b/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.out new file mode 100644 index 0000000..1250582 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_field_add_err.vv:6:2: error: cannot modify constant `a` + 4 | + 5 | fn main() { + 6 | a += 1 + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.vv new file mode 100644 index 0000000..24a6bb5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_add_err.vv @@ -0,0 +1,7 @@ +const ( + a = 1 +) + +fn main() { + a += 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.out b/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.out new file mode 100644 index 0000000..e0b9acb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_field_dec_err.vv:6:2: error: cannot modify constant `a` + 4 | + 5 | fn main() { + 6 | a-- + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.vv new file mode 100644 index 0000000..0f99839 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_dec_err.vv @@ -0,0 +1,7 @@ +const ( + a = 1 +) + +fn main() { + a-- +} diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.out b/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.out new file mode 100644 index 0000000..adeee60 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_field_inc_err.vv:6:2: error: cannot modify constant `a` + 4 | + 5 | fn main() { + 6 | a++ + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.vv new file mode 100644 index 0000000..9d0d96e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_inc_err.vv @@ -0,0 +1,7 @@ +const ( + a = 1 +) + +fn main() { + a++ +} diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.out new file mode 100644 index 0000000..e887c13 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/const_field_name_duplicate_err.vv:3:2: error: duplicate const `aaa` + 1 | const ( + 2 | aaa = 1 + 3 | aaa = 2 + | ~~~ + 4 | ) + 5 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.vv new file mode 100644 index 0000000..f489f51 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_name_duplicate_err.vv @@ -0,0 +1,7 @@ +const ( + aaa = 1 + aaa = 2 +) +fn main() { + println(aaa) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.out b/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.out new file mode 100644 index 0000000..ff997e4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_field_name_snake_case.vv:2:2: warning: const names cannot contain uppercase letters, use snake_case instead + 1 | const ( + 2 | Red = 1 + | ~~~ + 3 | ) + 4 | fn main() { println(Red) } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.vv new file mode 100644 index 0000000..cd8af8e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_name_snake_case.vv @@ -0,0 +1,4 @@ +const ( + Red = 1 +) +fn main() { println(Red) } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.out b/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.out new file mode 100644 index 0000000..782520b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/const_field_sub_err.vv:6:2: error: cannot modify constant `a` + 4 | + 5 | fn main() { + 6 | a -= 1 + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.vv b/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.vv new file mode 100644 index 0000000..e6c021b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/const_field_sub_err.vv @@ -0,0 +1,7 @@ +const ( + a = 1 +) + +fn main() { + a -= 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/ctdefine.out b/v_windows/v/old/vlib/v/checker/tests/ctdefine.out new file mode 100644 index 0000000..008a7d6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ctdefine.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/ctdefine.vv:4:1: error: only functions that do NOT return values can have `[if test]` tags + 2 | + 3 | [if test] + 4 | fn only_called_in_test() string { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 5 | return 'bah' + 6 | } +vlib/v/checker/tests/ctdefine.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) + 1 | module notmain + | ^ + 2 | + 3 | [if test] diff --git a/v_windows/v/old/vlib/v/checker/tests/ctdefine.vv b/v_windows/v/old/vlib/v/checker/tests/ctdefine.vv new file mode 100644 index 0000000..20d1eb0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ctdefine.vv @@ -0,0 +1,6 @@ +module notmain + +[if test] +fn only_called_in_test() string { + return 'bah' +} diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.mysymbol.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.mysymbol.run.out new file mode 100644 index 0000000..97a3e70 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.mysymbol.run.out @@ -0,0 +1,2 @@ +optional compitme define works +non optional comptime define works diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.out new file mode 100644 index 0000000..b916d1d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/custom_comptime_define_error.vv:6:13: error: undefined ident: `mysymbol` + 4 | println('optional compitme define works') + 5 | } + 6 | $if mysymbol { + | ~~~~~~~~ + 7 | // this will produce a checker error when `-d mysymbol` is not given on the CLI + 8 | println('non optional comptime define works') diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.vv b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.vv new file mode 100644 index 0000000..34f9967 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_error.vv @@ -0,0 +1,10 @@ +fn main() { + $if mysymbol? { + // this should not produce checker errors, but will print only with `-d mysymbol` + println('optional compitme define works') + } + $if mysymbol { + // this will produce a checker error when `-d mysymbol` is not given on the CLI + println('non optional comptime define works') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.cg.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.cg.run.out new file mode 100644 index 0000000..b8cdbba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.cg.run.out @@ -0,0 +1,3 @@ +main with debug +foo, x: 123 +done diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.bar.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.bar.run.out new file mode 100644 index 0000000..702459b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.bar.run.out @@ -0,0 +1,3 @@ +foo, x: 123 +bar, x: 456 +done diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.run.out new file mode 100644 index 0000000..8cdd401 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.debug.run.out @@ -0,0 +1,2 @@ +foo, x: 123 +done diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.g.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.g.run.out new file mode 100644 index 0000000..b8cdbba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.g.run.out @@ -0,0 +1,3 @@ +main with debug +foo, x: 123 +done diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.out diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.run.out new file mode 100644 index 0000000..19f86f4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.run.out @@ -0,0 +1 @@ +done diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.vv b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.vv new file mode 100644 index 0000000..380f738 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_debug.vv @@ -0,0 +1,18 @@ +[if debug] +fn foo(x int) { + println('foo, x: $x') +} + +[if bar ?] +fn bar(x int) { + println('bar, x: $x') +} + +fn main() { + $if debug { + println('main with debug') + } + foo(123) // will not be called if `-d debug` is not passed + bar(456) // will not be called if `-d bar` is not passed + println('done') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.mydebug.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.mydebug.run.out new file mode 100644 index 0000000..7cf4d92 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.mydebug.run.out @@ -0,0 +1,4 @@ +start +message: verbose message +message: debugging system +end diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.nodebug.run.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.nodebug.run.out new file mode 100644 index 0000000..5d0fb3b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.nodebug.run.out @@ -0,0 +1,2 @@ +start +end diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.out b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.out diff --git a/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.vv b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.vv new file mode 100644 index 0000000..23e946a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/custom_comptime_define_if_flag.vv @@ -0,0 +1,13 @@ +// Calls to edebug/1 should be executed only when `-d mydebug` is passed on the CLI +// Otherwise they will not be present *at all* in the generated code. +[if mydebug ?] +fn edebug(message string) { + println('message: $message') +} + +fn main() { + println('start') + edebug('verbose message') + edebug('debugging system') + println('end') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.out new file mode 100644 index 0000000..9166f4c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/dec_lit_wrong_digit_err.vv:2:18: error: this number has unsuitable digit `q` + 1 | fn main() { + 2 | println(12345qrst+10) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.vv new file mode 100644 index 0000000..c8c9583 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/dec_lit_wrong_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(12345qrst+10) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.out b/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.out new file mode 100644 index 0000000..95d56f6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/decompose_type_err.vv:4:13: error: decomposition can only be used on arrays + 2 | + 3 | fn main() { + 4 | varargs(...123) + | ~~~ + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.vv new file mode 100644 index 0000000..d5b43ba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/decompose_type_err.vv @@ -0,0 +1,5 @@ +fn varargs(a ...int) { println(a) } + +fn main() { + varargs(...123) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/defer_in_for.out b/v_windows/v/old/vlib/v/checker/tests/defer_in_for.out new file mode 100644 index 0000000..59faded --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/defer_in_for.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/defer_in_for.vv:4:13: error: `break` is not allowed in defer statements + 2 | for true { + 3 | defer { + 4 | break + | ~~~~~ + 5 | } + 6 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/defer_in_for.vv b/v_windows/v/old/vlib/v/checker/tests/defer_in_for.vv new file mode 100644 index 0000000..bb2525f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/defer_in_for.vv @@ -0,0 +1,7 @@ +fn main() { + for true { + defer { + break + } + } +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/defer_optional.out b/v_windows/v/old/vlib/v/checker/tests/defer_optional.out new file mode 100644 index 0000000..184e35e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/defer_optional.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/defer_optional.vv:5:3: error: opt() returns an option, so it should have an `or {}` block at the end + 3 | fn thing() ?string { + 4 | defer { + 5 | opt() + | ~~~~~ + 6 | } + 7 | return 'ok'
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/defer_optional.vv b/v_windows/v/old/vlib/v/checker/tests/defer_optional.vv new file mode 100644 index 0000000..f153430 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/defer_optional.vv @@ -0,0 +1,8 @@ +fn opt() ? {} + +fn thing() ?string { + defer { + opt() + } + return 'ok' +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/deprecations.out b/v_windows/v/old/vlib/v/checker/tests/deprecations.out new file mode 100644 index 0000000..55b205f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/deprecations.out @@ -0,0 +1,48 @@ +vlib/v/checker/tests/deprecations.vv:54:2: notice: function `future` will be deprecated after 9999-12-30; custom message 4 + 52 | + 53 | fn main() { + 54 | future() + | ~~~~~~~~ + 55 | past() + 56 | simply_deprecated() +vlib/v/checker/tests/deprecations.vv:60:4: notice: method `Abc.future` will be deprecated after 9999-11-01; custom message 1 + 58 | // + 59 | a := Abc{} + 60 | a.future() + | ~~~~~~~~ + 61 | a.past() + 62 | a.simply_deprecated() +vlib/v/checker/tests/deprecations.vv:55:2: error: function `past` has been deprecated since 2021-03-01; custom message 5 + 53 | fn main() { + 54 | future() + 55 | past() + | ~~~~~~ + 56 | simply_deprecated() + 57 | just_deprecated() +vlib/v/checker/tests/deprecations.vv:56:2: error: function `simply_deprecated` has been deprecated; custom message 6 + 54 | future() + 55 | past() + 56 | simply_deprecated() + | ~~~~~~~~~~~~~~~~~~~ + 57 | just_deprecated() + 58 | // +vlib/v/checker/tests/deprecations.vv:57:2: error: function `just_deprecated` has been deprecated + 55 | past() + 56 | simply_deprecated() + 57 | just_deprecated() + | ~~~~~~~~~~~~~~~~~ + 58 | // + 59 | a := Abc{} +vlib/v/checker/tests/deprecations.vv:61:4: error: method `Abc.past` has been deprecated since 2021-03-01; custom message 2 + 59 | a := Abc{} + 60 | a.future() + 61 | a.past() + | ~~~~~~ + 62 | a.simply_deprecated() + 63 | } +vlib/v/checker/tests/deprecations.vv:62:4: error: method `Abc.simply_deprecated` has been deprecated; custom message 3 + 60 | a.future() + 61 | a.past() + 62 | a.simply_deprecated() + | ~~~~~~~~~~~~~~~~~~~ + 63 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/deprecations.vv b/v_windows/v/old/vlib/v/checker/tests/deprecations.vv new file mode 100644 index 0000000..4a731ce --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/deprecations.vv @@ -0,0 +1,63 @@ +// methods using [deprecated_after]: +struct Abc { + x int +} + +fn (a Abc) str() string { + return 'Abc { x: $a.x }' +} + +[deprecated: 'custom message 1'] +[deprecated_after: '9999-11-01'] +fn (a Abc) future() { + dump(@METHOD) + dump(a) +} + +[deprecated: 'custom message 2'] +[deprecated_after: '2021-03-01'] +fn (a Abc) past() { + dump(@METHOD) + dump(a) +} + +[deprecated: 'custom message 3'] +fn (a Abc) simply_deprecated() { + dump(@METHOD) + dump(a) +} + +// functions using [deprecated_after]: +[deprecated: 'custom message 4'] +[deprecated_after: '9999-12-30'] +fn future() { + dump(@FN) +} + +[deprecated: 'custom message 5'] +[deprecated_after: '2021-03-01'] +fn past() { + dump(@FN) +} + +[deprecated: 'custom message 6'] +fn simply_deprecated() { + dump(@FN) +} + +[deprecated] +fn just_deprecated() { + dump(@FN) +} + +fn main() { + future() + past() + simply_deprecated() + just_deprecated() + // + a := Abc{} + a.future() + a.past() + a.simply_deprecated() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.out b/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.out new file mode 100644 index 0000000..d198c66 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/direct_map_alias_init_err.vv:4:7: error: direct map alias init is not possible, use `WordSet(map[string]bool{})` instead + 2 | + 3 | fn main() { + 4 | _ := WordSet{} + | ~~~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.vv b/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.vv new file mode 100644 index 0000000..5921f5b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/direct_map_alias_init_err.vv @@ -0,0 +1,5 @@ +type WordSet = map[string]bool + +fn main() { + _ := WordSet{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.out b/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.out new file mode 100644 index 0000000..3e4422f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.out @@ -0,0 +1,34 @@ +vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv:4:7: error: invalid operator `+` to `&int` and `&int` + 2 | x := 5 + 3 | p := &x + 4 | _ := p + p //should be error + | ~~~~~ + 5 | _ := p * p //should be error + 6 | _ := p * 2 //should be error +vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv:5:7: error: invalid operator `*` to `&int` and `&int` + 3 | p := &x + 4 | _ := p + p //should be error + 5 | _ := p * p //should be error + | ~~~~~ + 6 | _ := p * 2 //should be error + 7 | _ := p + 5 //OK but only in unsafe block, r is *int +vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv:6:7: error: invalid operator `*` to `&int` and `int literal` + 4 | _ := p + p //should be error + 5 | _ := p * p //should be error + 6 | _ := p * 2 //should be error + | ~~~~~ + 7 | _ := p + 5 //OK but only in unsafe block, r is *int + 8 | _ := p - p //OK even in safe code, but n should be isize +vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv:7:7: error: pointer arithmetic is only allowed in `unsafe` blocks + 5 | _ := p * p //should be error + 6 | _ := p * 2 //should be error + 7 | _ := p + 5 //OK but only in unsafe block, r is *int + | ~~~~~ + 8 | _ := p - p //OK even in safe code, but n should be isize + 9 | } +vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv:8:7: error: pointer arithmetic is only allowed in `unsafe` blocks + 6 | _ := p * 2 //should be error + 7 | _ := p + 5 //OK but only in unsafe block, r is *int + 8 | _ := p - p //OK even in safe code, but n should be isize + | ~~~~~ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv b/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv new file mode 100644 index 0000000..0fc91cd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/disallow_pointer_arithmetic_err.vv @@ -0,0 +1,9 @@ +fn main() { + x := 5 + p := &x + _ := p + p //should be error + _ := p * p //should be error + _ := p * 2 //should be error + _ := p + 5 //OK but only in unsafe block, r is *int + _ := p - p //OK even in safe code, but n should be isize +} diff --git a/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.out b/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.out new file mode 100644 index 0000000..b29d963 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.out @@ -0,0 +1,40 @@ +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:2:21: error: division by zero + 1 | fn main() { + 2 | println(u64(1)/u64(0)) + | ^ + 3 | println(u64(1)%u64(0)) + 4 | +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:3:21: error: modulo by zero + 1 | fn main() { + 2 | println(u64(1)/u64(0)) + 3 | println(u64(1)%u64(0)) + | ^ + 4 | + 5 | println(u32(1)/u32(0x0)) +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:5:21: error: division by zero + 3 | println(u64(1)%u64(0)) + 4 | + 5 | println(u32(1)/u32(0x0)) + | ~~~ + 6 | println(u32(1)%u32(0x0)) + 7 | +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:6:21: error: modulo by zero + 4 | + 5 | println(u32(1)/u32(0x0)) + 6 | println(u32(1)%u32(0x0)) + | ~~~ + 7 | + 8 | println(u16(1)/u16(0b0)) +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:8:21: error: division by zero + 6 | println(u32(1)%u32(0x0)) + 7 | + 8 | println(u16(1)/u16(0b0)) + | ~~~ + 9 | println(u16(1)%u16(0b0)) + 10 | } +vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv:9:21: error: modulo by zero + 7 | + 8 | println(u16(1)/u16(0b0)) + 9 | println(u16(1)%u16(0b0)) + | ~~~ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv b/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv new file mode 100644 index 0000000..215ae9e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/div_mod_by_cast_zero_int_err.vv @@ -0,0 +1,10 @@ +fn main() { + println(u64(1)/u64(0)) + println(u64(1)%u64(0)) + + println(u32(1)/u32(0x0)) + println(u32(1)%u32(0x0)) + + println(u16(1)/u16(0b0)) + println(u16(1)%u16(0b0)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.out new file mode 100644 index 0000000..f79c286 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/div_op_wrong_type_err.vv:3:13: error: mismatched types `Aaa` and `int literal` + 1 | struct Aaa{} + 2 | fn main() { + 3 | println(Aaa{} / 10) + | ~~~~~~~~~~ + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) +vlib/v/checker/tests/div_op_wrong_type_err.vv:4:13: error: mismatched types `int literal` and `Aaa` + 2 | fn main() { + 3 | println(Aaa{} / 10) + 4 | println(10 / Aaa{}) + | ~~~~~~~~~~ + 5 | println([1,2,3] / 10) + 6 | println(10 / [1,2,3]) +vlib/v/checker/tests/div_op_wrong_type_err.vv:5:13: error: mismatched types `[]int` and `int literal` + 3 | println(Aaa{} / 10) + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) + | ~~~~~~~~~~~~ + 6 | println(10 / [1,2,3]) + 7 | a := map[string]int +vlib/v/checker/tests/div_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `[]int` + 4 | println(10 / Aaa{}) + 5 | println([1,2,3] / 10) + 6 | println(10 / [1,2,3]) + | ~~~~~~~~~~~~ + 7 | a := map[string]int + 8 | println(a / 10) +vlib/v/checker/tests/div_op_wrong_type_err.vv:8:13: error: mismatched types `map[string]int` and `int literal` + 6 | println(10 / [1,2,3]) + 7 | a := map[string]int + 8 | println(a / 10) + | ~~~~~~ + 9 | println(10 / a) + 10 | } +vlib/v/checker/tests/div_op_wrong_type_err.vv:9:13: error: mismatched types `int literal` and `map[string]int` + 7 | a := map[string]int + 8 | println(a / 10) + 9 | println(10 / a) + | ~~~~~~ + 10 | } + diff --git a/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.vv new file mode 100644 index 0000000..fb2f1cd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/div_op_wrong_type_err.vv @@ -0,0 +1,10 @@ +struct Aaa{} +fn main() { + println(Aaa{} / 10) + println(10 / Aaa{}) + println([1,2,3] / 10) + println(10 / [1,2,3]) + a := map[string]int + println(a / 10) + println(10 / a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.out b/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.out new file mode 100644 index 0000000..f6bbda2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/division_by_cast_zero_float_err.vv:2:23: error: division by zero + 1 | fn main() { + 2 | println(f32(1.0)/f32(0.0)) + | ~~~ + 3 | println(f64(1.0)/f64(0.0)) + 4 | } +vlib/v/checker/tests/division_by_cast_zero_float_err.vv:3:23: error: division by zero + 1 | fn main() { + 2 | println(f32(1.0)/f32(0.0)) + 3 | println(f64(1.0)/f64(0.0)) + | ~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.vv b/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.vv new file mode 100644 index 0000000..6feee15 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_cast_zero_float_err.vv @@ -0,0 +1,4 @@ +fn main() { + println(f32(1.0)/f32(0.0)) + println(f64(1.0)/f64(0.0)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.out b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.out new file mode 100644 index 0000000..7a2ee8d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/division_by_zero_float_err.vv:2:14: error: division by zero + 1 | fn main() { + 2 | println(1.0/0.0) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.vv b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.vv new file mode 100644 index 0000000..b5c1e7c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_float_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(1.0/0.0) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.out b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.out new file mode 100644 index 0000000..6b2ed19 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.out @@ -0,0 +1,26 @@ +vlib/v/checker/tests/division_by_zero_int_err.vv:2:12: error: division by zero + 1 | fn main() { + 2 | println(1/0) + | ^ + 3 | println(1/0x0) + 4 | println(1/0b0) +vlib/v/checker/tests/division_by_zero_int_err.vv:3:12: error: division by zero + 1 | fn main() { + 2 | println(1/0) + 3 | println(1/0x0) + | ~~~ + 4 | println(1/0b0) + 5 | println(1/0o0) +vlib/v/checker/tests/division_by_zero_int_err.vv:4:12: error: division by zero + 2 | println(1/0) + 3 | println(1/0x0) + 4 | println(1/0b0) + | ~~~ + 5 | println(1/0o0) + 6 | } +vlib/v/checker/tests/division_by_zero_int_err.vv:5:12: error: division by zero + 3 | println(1/0x0) + 4 | println(1/0b0) + 5 | println(1/0o0) + | ~~~ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.vv b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.vv new file mode 100644 index 0000000..4316fda --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/division_by_zero_int_err.vv @@ -0,0 +1,6 @@ +fn main() { + println(1/0) + println(1/0x0) + println(1/0b0) + println(1/0o0) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.out b/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.out new file mode 100644 index 0000000..ac6f1b5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/dump_of_void_expr.vv:3:6: error: dump expression can not be void + 1 | fn abc() {} + 2 | + 3 | dump(abc()) + | ~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.vv b/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.vv new file mode 100644 index 0000000..57e8597 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/dump_of_void_expr.vv @@ -0,0 +1,3 @@ +fn abc() {} + +dump(abc()) diff --git a/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.out b/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.out new file mode 100644 index 0000000..b4befdd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/duplicate_field_method_err.vv:5:1: error: type `St` has both field and method named `attr` + 3 | } + 4 | + 5 | fn (s St) attr() {} + | ~~~~~~~~~~~~~~~~ + 6 | + 7 | interface Foo { +vlib/v/checker/tests/duplicate_field_method_err.vv:9:2: error: type `Foo` has both field and method named `bar` + 7 | interface Foo { + 8 | bar fn () + 9 | bar() + | ~~~~~ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.vv b/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.vv new file mode 100644 index 0000000..2c34f78 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/duplicate_field_method_err.vv @@ -0,0 +1,10 @@ +struct St{ + attr fn() +} + +fn (s St) attr() {} + +interface Foo { + bar fn () + bar() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.out b/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.out new file mode 100644 index 0000000..cef283d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/enum_as_int_err.vv:9:10: error: cannot assign to `color`: expected `Color`, not `int literal` + 7 | mut color := Color.red + 8 | mut foo := 1 + 9 | color = 1 + | ^ + 10 | foo = Color.red + 11 | println(color == 0) +vlib/v/checker/tests/enum_as_int_err.vv:10:8: error: cannot assign to `foo`: expected `int`, not `Color` + 8 | mut foo := 1 + 9 | color = 1 + 10 | foo = Color.red + | ~~~~~~~~~ + 11 | println(color == 0) + 12 | _ = foo +vlib/v/checker/tests/enum_as_int_err.vv:11:10: error: infix expr: cannot use `int literal` (right expression) as `Color` + 9 | color = 1 + 10 | foo = Color.red + 11 | println(color == 0) + | ~~~~~~~~~~ + 12 | _ = foo + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.vv b/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.vv new file mode 100644 index 0000000..47605ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_as_int_err.vv @@ -0,0 +1,13 @@ +enum Color { + red + blue +} + +fn main() { + mut color := Color.red + mut foo := 1 + color = 1 + foo = Color.red + println(color == 0) + _ = foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_cast.out b/v_windows/v/old/vlib/v/checker/tests/enum_cast.out new file mode 100644 index 0000000..053fe1b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_cast.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/enum_cast.vv:6:13: error: 12 does not represents a value of enum Color + 4 | println(Color(0)) + 5 | println(Color(10)) + 6 | println(Color(12)) + | ~~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_cast.vv b/v_windows/v/old/vlib/v/checker/tests/enum_cast.vv new file mode 100644 index 0000000..40e9ec7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_cast.vv @@ -0,0 +1,7 @@ +enum Color { red green = 10 blue } + +fn main() { + println(Color(0)) + println(Color(10)) + println(Color(12)) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_empty.out b/v_windows/v/old/vlib/v/checker/tests/enum_empty.out new file mode 100644 index 0000000..b2b432d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_empty.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/enum_empty.vv:1:1: error: enum cannot be empty + 1 | enum Empty {} + | ~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_empty.vv b/v_windows/v/old/vlib/v/checker/tests/enum_empty.vv new file mode 100644 index 0000000..7afdbc0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_empty.vv @@ -0,0 +1 @@ +enum Empty {} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_err.out b/v_windows/v/old/vlib/v/checker/tests/enum_err.out new file mode 100644 index 0000000..9256d7f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/enum_err.vv:4:13: error: default value for enum has to be an integer + 2 | + 3 | enum Color { + 4 | green = 'green' + | ~~~~~~~ + 5 | yellow = 1+1 + 6 | blue +vlib/v/checker/tests/enum_err.vv:5:14: error: default value for enum has to be an integer + 3 | enum Color { + 4 | green = 'green' + 5 | yellow = 1+1 + | ~~~ + 6 | blue + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_err.vv b/v_windows/v/old/vlib/v/checker/tests/enum_err.vv new file mode 100644 index 0000000..1710b84 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_err.vv @@ -0,0 +1,11 @@ +module main + +enum Color { + green = 'green' + yellow = 1+1 + blue +} + +fn main(){ + println('hello') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.out new file mode 100644 index 0000000..6f1de8d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/enum_field_name_duplicate_err.vv:5:2: error: field name `green` duplicate + 3 | yellow + 4 | blue + 5 | green + | ~~~~~ + 6 | } + 7 | diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.vv new file mode 100644 index 0000000..790d39d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_name_duplicate_err.vv @@ -0,0 +1,10 @@ +enum Color { + green + yellow + blue + green +} + +fn main(){ + println('hello') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.out b/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.out new file mode 100644 index 0000000..26f5843 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/enum_field_overflow.vv:4:2: error: enum value overflows + 2 | red + 3 | green = 2147483647 + 4 | blue + | ~~~~ + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.vv b/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.vv new file mode 100644 index 0000000..8c79d29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_overflow.vv @@ -0,0 +1,5 @@ +enum Color { + red + green = 2147483647 + blue +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.out b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.out new file mode 100644 index 0000000..ce72e69 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/enum_field_value_duplicate_a.vv:3:10: error: enum value `0` already exists + 1 | enum Color { + 2 | red + 3 | green = 0 + | ^ + 4 | blue = 1 + 5 | alpha = 1 +vlib/v/checker/tests/enum_field_value_duplicate_a.vv:5:10: error: enum value `1` already exists + 3 | green = 0 + 4 | blue = 1 + 5 | alpha = 1 + | ^ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.vv b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.vv new file mode 100644 index 0000000..49cf3c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_a.vv @@ -0,0 +1,6 @@ +enum Color { + red + green = 0 + blue = 1 + alpha = 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.out b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.out new file mode 100644 index 0000000..c1a9ae2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/enum_field_value_duplicate_b.vv:4:2: error: enum value `0` already exists + 2 | red // 0 + 3 | green = -1 + 4 | blue // -1 + 1 = 0 + | ~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.vv b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.vv new file mode 100644 index 0000000..232a265 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_duplicate_b.vv @@ -0,0 +1,5 @@ +enum Color { + red // 0 + green = -1 + blue // -1 + 1 = 0 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.out b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.out new file mode 100644 index 0000000..c6bb9c0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/enum_field_value_overflow.vv:3:10: error: enum value `2147483648` overflows int + 1 | enum Color { + 2 | red + 3 | green = 2147483648 + | ~~~~~~~~~~ + 4 | blue + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.vv b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.vv new file mode 100644 index 0000000..cb9fb9a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_field_value_overflow.vv @@ -0,0 +1,5 @@ +enum Color { + red + green = 2147483648 + blue +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_op_err.out b/v_windows/v/old/vlib/v/checker/tests/enum_op_err.out new file mode 100644 index 0000000..1392251 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_op_err.out @@ -0,0 +1,34 @@ +vlib/v/checker/tests/enum_op_err.vv:8:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed + 6 | + 7 | fn main() { + 8 | println(Color.red > Color.green) + | ^ + 9 | println(Color.red + Color.green) + 10 | println(Color.red && Color.green) +vlib/v/checker/tests/enum_op_err.vv:9:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed + 7 | fn main() { + 8 | println(Color.red > Color.green) + 9 | println(Color.red + Color.green) + | ^ + 10 | println(Color.red && Color.green) + 11 | println(Color.red | Color.green) +vlib/v/checker/tests/enum_op_err.vv:10:10: error: left operand for `&&` is not a boolean + 8 | println(Color.red > Color.green) + 9 | println(Color.red + Color.green) + 10 | println(Color.red && Color.green) + | ~~~~~~~~~ + 11 | println(Color.red | Color.green) + 12 | println(Color.red & Color.green) +vlib/v/checker/tests/enum_op_err.vv:11:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed + 9 | println(Color.red + Color.green) + 10 | println(Color.red && Color.green) + 11 | println(Color.red | Color.green) + | ^ + 12 | println(Color.red & Color.green) + 13 | } +vlib/v/checker/tests/enum_op_err.vv:12:20: error: only `==` and `!=` are defined on `enum`, use an explicit cast to `int` if needed + 10 | println(Color.red && Color.green) + 11 | println(Color.red | Color.green) + 12 | println(Color.red & Color.green) + | ^ + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_op_err.vv b/v_windows/v/old/vlib/v/checker/tests/enum_op_err.vv new file mode 100644 index 0000000..7fa48e4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_op_err.vv @@ -0,0 +1,13 @@ +enum Color { + red + blue + green +} + +fn main() { + println(Color.red > Color.green) + println(Color.red + Color.green) + println(Color.red && Color.green) + println(Color.red | Color.green) + println(Color.red & Color.green) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.out b/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.out new file mode 100644 index 0000000..fb3e228 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/enum_op_flag_err.vv:9:24: error: only `==`, `!=`, `|` and `&` are defined on `[flag]` tagged `enum`, use an explicit cast to `int` if needed + 7 | + 8 | fn main() { + 9 | println(FilePerm.read > FilePerm.write) + | ^ + 10 | println(FilePerm.write + FilePerm.exec) + 11 | println(FilePerm.write && FilePerm.exec) +vlib/v/checker/tests/enum_op_flag_err.vv:10:25: error: only `==`, `!=`, `|` and `&` are defined on `[flag]` tagged `enum`, use an explicit cast to `int` if needed + 8 | fn main() { + 9 | println(FilePerm.read > FilePerm.write) + 10 | println(FilePerm.write + FilePerm.exec) + | ^ + 11 | println(FilePerm.write && FilePerm.exec) + 12 | } +vlib/v/checker/tests/enum_op_flag_err.vv:11:10: error: left operand for `&&` is not a boolean + 9 | println(FilePerm.read > FilePerm.write) + 10 | println(FilePerm.write + FilePerm.exec) + 11 | println(FilePerm.write && FilePerm.exec) + | ~~~~~~~~~~~~~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.vv b/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.vv new file mode 100644 index 0000000..0701255 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_op_flag_err.vv @@ -0,0 +1,12 @@ +[flag] +enum FilePerm { + read + write + exec +} + +fn main() { + println(FilePerm.read > FilePerm.write) + println(FilePerm.write + FilePerm.exec) + println(FilePerm.write && FilePerm.exec) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.out b/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.out new file mode 100644 index 0000000..b509c5e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/enum_single_letter.vv:1:6: error: single letter capital names are reserved for generic template types. + 1 | enum E { + | ^ + 2 | v w + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.vv b/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.vv new file mode 100644 index 0000000..ef7bc65 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/enum_single_letter.vv @@ -0,0 +1,4 @@ +enum E { + v w +} +println(E.v) diff --git a/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.out new file mode 100644 index 0000000..d5f43cf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.out @@ -0,0 +1,139 @@ +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:12:10: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 10 | + 11 | fn main() { + 12 | println(Aaa{} == 10) + | ~~~~~~~~~~~ + 13 | println(10 == Aaa{}) + 14 | println(Aaa{} != 10) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:13:10: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 11 | fn main() { + 12 | println(Aaa{} == 10) + 13 | println(10 == Aaa{}) + | ~~~~~~~~~~~ + 14 | println(Aaa{} != 10) + 15 | println(10 != Aaa{}) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:14:10: error: infix expr: cannot use `int literal` (right expression) as `Aaa` + 12 | println(Aaa{} == 10) + 13 | println(10 == Aaa{}) + 14 | println(Aaa{} != 10) + | ~~~~~~~~~~~ + 15 | println(10 != Aaa{}) + 16 | +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:15:10: error: infix expr: cannot use `Aaa` (right expression) as `int literal` + 13 | println(10 == Aaa{}) + 14 | println(Aaa{} != 10) + 15 | println(10 != Aaa{}) + | ~~~~~~~~~~~ + 16 | + 17 | println(Aaa{0} == AAaa{0}) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:17:10: error: possible type mismatch of compared values of `==` operation + 15 | println(10 != Aaa{}) + 16 | + 17 | println(Aaa{0} == AAaa{0}) + | ~~~~~~~~~~~~~~~~~ + 18 | println(AAaa{0} == Aaa{0}) + 19 | println(AAaa{1} != Aaa{1}) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:18:10: error: possible type mismatch of compared values of `==` operation + 16 | + 17 | println(Aaa{0} == AAaa{0}) + 18 | println(AAaa{0} == Aaa{0}) + | ~~~~~~~~~~~~~~~~~ + 19 | println(AAaa{1} != Aaa{1}) + 20 | println(Aaa{1} != AAaa{1}) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:19:10: error: possible type mismatch of compared values of `!=` operation + 17 | println(Aaa{0} == AAaa{0}) + 18 | println(AAaa{0} == Aaa{0}) + 19 | println(AAaa{1} != Aaa{1}) + | ~~~~~~~~~~~~~~~~~ + 20 | println(Aaa{1} != AAaa{1}) + 21 | +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:20:10: error: possible type mismatch of compared values of `!=` operation + 18 | println(AAaa{0} == Aaa{0}) + 19 | println(AAaa{1} != Aaa{1}) + 20 | println(Aaa{1} != AAaa{1}) + | ~~~~~~~~~~~~~~~~~ + 21 | + 22 | arr := Arr([0]) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:23:10: error: possible type mismatch of compared values of `==` operation + 21 | + 22 | arr := Arr([0]) + 23 | println(arr == [0]) + | ~~~~~~~~~~ + 24 | println([1] == arr) + 25 | println(arr != [0]) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:24:10: error: possible type mismatch of compared values of `==` operation + 22 | arr := Arr([0]) + 23 | println(arr == [0]) + 24 | println([1] == arr) + | ~~~~~~~~~~ + 25 | println(arr != [0]) + 26 | println([1] != arr) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:25:10: error: possible type mismatch of compared values of `!=` operation + 23 | println(arr == [0]) + 24 | println([1] == arr) + 25 | println(arr != [0]) + | ~~~~~~~~~~ + 26 | println([1] != arr) + 27 | +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:26:10: error: possible type mismatch of compared values of `!=` operation + 24 | println([1] == arr) + 25 | println(arr != [0]) + 26 | println([1] != arr) + | ~~~~~~~~~~ + 27 | + 28 | arr_aaa := ArrAaa(arr) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:29:10: error: possible type mismatch of compared values of `==` operation + 27 | + 28 | arr_aaa := ArrAaa(arr) + 29 | println(arr_aaa == arr) + | ~~~~~~~~~~~~~~ + 30 | println(arr == arr_aaa) + 31 | println(arr_aaa != arr) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:30:10: error: possible type mismatch of compared values of `==` operation + 28 | arr_aaa := ArrAaa(arr) + 29 | println(arr_aaa == arr) + 30 | println(arr == arr_aaa) + | ~~~~~~~~~~~~~~ + 31 | println(arr_aaa != arr) + 32 | println(arr != arr_aaa) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:31:10: error: possible type mismatch of compared values of `!=` operation + 29 | println(arr_aaa == arr) + 30 | println(arr == arr_aaa) + 31 | println(arr_aaa != arr) + | ~~~~~~~~~~~~~~ + 32 | println(arr != arr_aaa) + 33 | +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:32:10: error: possible type mismatch of compared values of `!=` operation + 30 | println(arr == arr_aaa) + 31 | println(arr_aaa != arr) + 32 | println(arr != arr_aaa) + | ~~~~~~~~~~~~~~ + 33 | + 34 | println(arr_aaa == [0]) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:34:10: error: infix expr: cannot use `[]int` (right expression) as `ArrAaa` + 32 | println(arr != arr_aaa) + 33 | + 34 | println(arr_aaa == [0]) + | ~~~~~~~~~~~~~~ + 35 | println([1] == arr_aaa) + 36 | println(arr_aaa != [0]) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:35:10: error: infix expr: cannot use `ArrAaa` (right expression) as `[]int` + 33 | + 34 | println(arr_aaa == [0]) + 35 | println([1] == arr_aaa) + | ~~~~~~~~~~~~~~ + 36 | println(arr_aaa != [0]) + 37 | println([1] != arr_aaa) +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:36:10: error: infix expr: cannot use `[]int` (right expression) as `ArrAaa` + 34 | println(arr_aaa == [0]) + 35 | println([1] == arr_aaa) + 36 | println(arr_aaa != [0]) + | ~~~~~~~~~~~~~~ + 37 | println([1] != arr_aaa) + 38 | } +vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv:37:10: error: infix expr: cannot use `ArrAaa` (right expression) as `[]int` + 35 | println([1] == arr_aaa) + 36 | println(arr_aaa != [0]) + 37 | println([1] != arr_aaa) + | ~~~~~~~~~~~~~~ + 38 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv new file mode 100644 index 0000000..36e7d17 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/eq_ne_op_wrong_type_err.vv @@ -0,0 +1,38 @@ +struct Aaa { + i int +} + +type AAaa = Aaa + +type Arr = []int + +type ArrAaa = Aaa | Arr + +fn main() { + println(Aaa{} == 10) + println(10 == Aaa{}) + println(Aaa{} != 10) + println(10 != Aaa{}) + + println(Aaa{0} == AAaa{0}) + println(AAaa{0} == Aaa{0}) + println(AAaa{1} != Aaa{1}) + println(Aaa{1} != AAaa{1}) + + arr := Arr([0]) + println(arr == [0]) + println([1] == arr) + println(arr != [0]) + println([1] != arr) + + arr_aaa := ArrAaa(arr) + println(arr_aaa == arr) + println(arr == arr_aaa) + println(arr_aaa != arr) + println(arr != arr_aaa) + + println(arr_aaa == [0]) + println([1] == arr_aaa) + println(arr_aaa != [0]) + println([1] != arr_aaa) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.out b/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.out new file mode 100644 index 0000000..c4aceee --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/error_fn_with_0_args.vv:2:9: error: expected 1 arguments, but got 0 + 1 | fn abc() ? { + 2 | return error() + | ~~~~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.vv b/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.vv new file mode 100644 index 0000000..ebbfe47 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_fn_with_0_args.vv @@ -0,0 +1,3 @@ +fn abc() ? { + return error() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.out b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.out new file mode 100644 index 0000000..5e4630e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/error_with_comment_with_crlf_ending.vv:2:6: error: unexpected name `should` + 1 | // Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails + 2 | This should cause an error! + | ~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.vv b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.vv new file mode 100644 index 0000000..256462a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_crlf_ending.vv @@ -0,0 +1,2 @@ +// Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails
+This should cause an error!
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.out b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.out new file mode 100644 index 0000000..fcf3524 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/error_with_comment_with_lf_ending.vv:2:6: error: unexpected name `should` + 1 | // Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails + 2 | This should cause an error! + | ~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.vv b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.vv new file mode 100644 index 0000000..003d44e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_comment_with_lf_ending.vv @@ -0,0 +1,2 @@ +// Empty lines don't cause an issue but as soon as there's a comment with a CRLF ending, it fails +This should cause an error!
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out b/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out new file mode 100644 index 0000000..d1b88fa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:9:2: error: undefined ident: `a` (use `:=` to declare a variable) + 7 | fn main() { + 8 | func1() + 9 | a = 2 + | ^ + 10 | println('a is $a') + 11 | } +vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv:10:17: error: undefined ident: `a` + 8 | func1() + 9 | a = 2 + 10 | println('a is $a') + | ^ + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv b/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv new file mode 100644 index 0000000..09b22be --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_several_comments_with_crlf_ending.vv @@ -0,0 +1,11 @@ +// Comment line 1
+// Comment line 2
+fn func1() {
+ println('Inside func 1')
+}
+
+fn main() {
+ func1()
+ a = 2
+ println('a is $a')
+}
diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.out b/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.out new file mode 100644 index 0000000..78ea832 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.out @@ -0,0 +1,56 @@ +vlib/v/checker/tests/error_with_unicode.vv:5:17: error: cannot use `int literal` as `string` in argument 2 to `f1` + 3 | + 4 | fn main() { + 5 | f1('🐀🐈', 0) + | ^ + 6 | f2(0, '🐟🐧') + 7 | mut n := 0 +vlib/v/checker/tests/error_with_unicode.vv:6:8: error: cannot use `string` as `int` in argument 2 to `f2` + 4 | fn main() { + 5 | f1('🐀🐈', 0) + 6 | f2(0, '🐟🐧') + | ~~~~~~ + 7 | mut n := 0 + 8 | n = '漢字' +vlib/v/checker/tests/error_with_unicode.vv:8:6: error: cannot assign to `n`: expected `int`, not `string` + 6 | f2(0, '🐟🐧') + 7 | mut n := 0 + 8 | n = '漢字' + | ~~~~~~ + 9 | n = 'ひらがな' + 10 | n = '简体字' +vlib/v/checker/tests/error_with_unicode.vv:9:6: error: cannot assign to `n`: expected `int`, not `string` + 7 | mut n := 0 + 8 | n = '漢字' + 9 | n = 'ひらがな' + | ~~~~~~~~~~ + 10 | n = '简体字' + 11 | n = '繁體字' +vlib/v/checker/tests/error_with_unicode.vv:10:6: error: cannot assign to `n`: expected `int`, not `string` + 8 | n = '漢字' + 9 | n = 'ひらがな' + 10 | n = '简体字' + | ~~~~~~~~ + 11 | n = '繁體字' + 12 | n = '한글' +vlib/v/checker/tests/error_with_unicode.vv:11:6: error: cannot assign to `n`: expected `int`, not `string` + 9 | n = 'ひらがな' + 10 | n = '简体字' + 11 | n = '繁體字' + | ~~~~~~~~ + 12 | n = '한글' + 13 | n = 'Кириллица' +vlib/v/checker/tests/error_with_unicode.vv:12:6: error: cannot assign to `n`: expected `int`, not `string` + 10 | n = '简体字' + 11 | n = '繁體字' + 12 | n = '한글' + | ~~~~~~ + 13 | n = 'Кириллица' + 14 | _ = n +vlib/v/checker/tests/error_with_unicode.vv:13:6: error: cannot assign to `n`: expected `int`, not `string` + 11 | n = '繁體字' + 12 | n = '한글' + 13 | n = 'Кириллица' + | ~~~~~~~~~~~ + 14 | _ = n + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.vv b/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.vv new file mode 100644 index 0000000..8299e4e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/error_with_unicode.vv @@ -0,0 +1,15 @@ +fn f1(_ string, _ string) {} +fn f2(_ int, _ int) {} + +fn main() { + f1('🐀🐈', 0) + f2(0, '🐟🐧') + mut n := 0 + n = '漢字' + n = 'ひらがな' + n = '简体字' + n = '繁體字' + n = '한글' + n = 'Кириллица' + _ = n +} diff --git a/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.out b/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.out new file mode 100644 index 0000000..e150341 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/expression_should_return_an_option.vv:28:10: error: expression should return an option + 26 | } + 27 | // should be an checker error: + 28 | if x := return_string() { + | ~~~~~~~~~~~~~~~ + 29 | println('x: $x') + 30 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.vv b/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.vv new file mode 100644 index 0000000..6b25dbc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/expression_should_return_an_option.vv @@ -0,0 +1,31 @@ +fn return_optional(fail bool) ?string { + if fail { + return error('nope') + } + return 'foo' +} + +fn return_string() string { + return 'foo' +} + +fn main() { + // works + if r := return_optional(false) { + println(r) + } + // works + if r := return_optional(false) { + println(r) + } else { + println(err) + } + // works + return_optional(true) or { + println(err) + } + // should be an checker error: + if x := return_string() { + println('x: $x') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.out b/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.out new file mode 100644 index 0000000..e62f5db --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/filter_func_return_nonbool_err.vv:2:25: error: type mismatch, `stringsss` must return a bool + 1 | fn main() { + 2 | list := [1,2,3].filter(stringsss(it)) + | ~~~~~~~~~~~~~ + 3 | } + 4 | diff --git a/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.vv b/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.vv new file mode 100644 index 0000000..a6ecd7a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/filter_func_return_nonbool_err.vv @@ -0,0 +1,7 @@ +fn main() { + list := [1,2,3].filter(stringsss(it)) +} + +fn stringsss(arg int) string { + return '' +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.out b/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.out new file mode 100644 index 0000000..d01f0fd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/filter_on_non_arr_err.vv:2:14: error: unknown method or field: `string.filter` + 1 | fn main() { + 2 | _ := 'test'.filter(it == `t`) + | ~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.vv b/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.vv new file mode 100644 index 0000000..ee1bb7c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/filter_on_non_arr_err.vv @@ -0,0 +1,3 @@ +fn main() { + _ := 'test'.filter(it == `t`) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.out b/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.out new file mode 100644 index 0000000..211f4b5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.out @@ -0,0 +1,41 @@ +vlib/v/checker/tests/fixed_array_conv.vv:3:3: error: mismatched types `voidptr` and `[2]int` + 1 | arr := [2,3]! + 2 | mut p := voidptr(0) + 3 | p = arr + | ^ + 4 | mut ip := &int(0) + 5 | ip = arr +vlib/v/checker/tests/fixed_array_conv.vv:5:4: error: mismatched types `&int` and `[2]int` + 3 | p = arr + 4 | mut ip := &int(0) + 5 | ip = arr + | ^ + 6 | _ = &int(arr) + 7 | _ = p +vlib/v/checker/tests/fixed_array_conv.vv:6:5: error: cannot cast a fixed array (use e.g. `&arr[0]` instead) + 4 | mut ip := &int(0) + 5 | ip = arr + 6 | _ = &int(arr) + | ~~~~~~~~~ + 7 | _ = p + 8 | _ = ip +vlib/v/checker/tests/fixed_array_conv.vv:11:13: error: cannot use `[2]int` as `voidptr` in argument 1 to `memdup` + 9 | + 10 | unsafe { + 11 | _ = memdup(arr, 1) + | ~~~ + 12 | _ = tos(arr, 1) + 13 | fn (p &int){}(arr) +vlib/v/checker/tests/fixed_array_conv.vv:12:10: error: cannot use `[2]int` as `&byte` in argument 1 to `tos` + 10 | unsafe { + 11 | _ = memdup(arr, 1) + 12 | _ = tos(arr, 1) + | ~~~ + 13 | fn (p &int){}(arr) + 14 | } +vlib/v/checker/tests/fixed_array_conv.vv:13:16: error: cannot use `[2]int` as `&int` in argument 1 to `anon` + 11 | _ = memdup(arr, 1) + 12 | _ = tos(arr, 1) + 13 | fn (p &int){}(arr) + | ~~~ + 14 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.vv b/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.vv new file mode 100644 index 0000000..8c343c4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_conv.vv @@ -0,0 +1,14 @@ +arr := [2,3]! +mut p := voidptr(0) +p = arr +mut ip := &int(0) +ip = arr +_ = &int(arr) +_ = p +_ = ip + +unsafe { + _ = memdup(arr, 1) + _ = tos(arr, 1) + fn (p &int){}(arr) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.out b/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.out new file mode 100644 index 0000000..0734920 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/fixed_array_non_const_size_err.vv:4:12: error: non-constant array bound `size` + 2 | size := 2 + 3 | + 4 | array := [size]int{} + | ~~~~ + 5 | + 6 | println(array) diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.vv b/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.vv new file mode 100644 index 0000000..eada0cd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_non_const_size_err.vv @@ -0,0 +1,7 @@ +fn main() { + size := 2 + + array := [size]int{} + + println(array) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.out b/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.out new file mode 100644 index 0000000..8e3c9ea --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/fixed_array_size_err.vv:4:8: error: fixed size cannot be zero or negative (fixed_size: -1) + 2 | + 3 | fn main() { + 4 | a := [size]int{} + | ~~~~ + 5 | b := [0]byte{} + 6 | println(a) +vlib/v/checker/tests/fixed_array_size_err.vv:5:8: error: fixed size cannot be zero or negative (fixed_size: 0) + 3 | fn main() { + 4 | a := [size]int{} + 5 | b := [0]byte{} + | ^ + 6 | println(a) + 7 | println(b) diff --git a/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.vv b/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.vv new file mode 100644 index 0000000..eb27c2b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fixed_array_size_err.vv @@ -0,0 +1,8 @@ +const size = -1 + +fn main() { + a := [size]int{} + b := [0]byte{} + println(a) + println(b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.out b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.out new file mode 100644 index 0000000..8d7b1d8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/float_lit_exp_not_integer_err.vv:2:17: error: exponential part should be integer + 1 | fn main() { + 2 | println(45e2.5) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.vv b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.vv new file mode 100644 index 0000000..a1bd559 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_not_integer_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(45e2.5) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.out new file mode 100644 index 0000000..c5be9e2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/float_lit_exp_without_digit_err.vv:2:14: error: exponent has no digits + 1 | fn main() { + 2 | println(2E) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.vv new file mode 100644 index 0000000..6d3d9f1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_exp_without_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(2E) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.out b/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.out new file mode 100644 index 0000000..cbf085b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/float_lit_too_many_points_err.vv:2:19: error: too many decimal points in number + 1 | fn main() { + 2 | println(123.45.67) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.vv b/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.vv new file mode 100644 index 0000000..e787cab --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_lit_too_many_points_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(123.45.67) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.out b/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.out new file mode 100644 index 0000000..a3ee9bf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/float_modulo_err.vv:2:13: error: float modulo not allowed, use math.fmod() instead + 1 | fn main() { + 2 | println(3.0 % 2.0) + | ~~~ + 3 | println(f32(3.0) % f32(2.0)) + 4 | } +vlib/v/checker/tests/float_modulo_err.vv:3:13: error: float modulo not allowed, use math.fmod() instead + 1 | fn main() { + 2 | println(3.0 % 2.0) + 3 | println(f32(3.0) % f32(2.0)) + | ~~~~~~~~ + 4 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.vv b/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.vv new file mode 100644 index 0000000..6a4d87d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/float_modulo_err.vv @@ -0,0 +1,4 @@ +fn main() { + println(3.0 % 2.0) + println(f32(3.0) % f32(2.0)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_args.out b/v_windows/v/old/vlib/v/checker/tests/fn_args.out new file mode 100644 index 0000000..2df630b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_args.out @@ -0,0 +1,35 @@ +vlib/v/checker/tests/fn_args.vv:9:6: error: cannot use `&int` as `byte` in argument 1 to `uu8` + 7 | fn basic() { + 8 | v := 4 + 9 | uu8(&v) + | ~~ + 10 | arr([5]!) + 11 | fun(fn (i &int) {}) +vlib/v/checker/tests/fn_args.vv:10:6: error: cannot use `[1]int` as `[]int` in argument 1 to `arr` + 8 | v := 4 + 9 | uu8(&v) + 10 | arr([5]!) + | ~~~~ + 11 | fun(fn (i &int) {}) + 12 | fun(fn (ii ...int) {}) +vlib/v/checker/tests/fn_args.vv:11:6: error: cannot use `fn (&int)` as `fn (int)` in argument 1 to `fun` + 9 | uu8(&v) + 10 | arr([5]!) + 11 | fun(fn (i &int) {}) + | ~~~~~~~~~~~~~~ + 12 | fun(fn (ii ...int) {}) + 13 | } +Details: ``'s expected fn argument: `` is NOT a pointer, but the passed fn argument: `i` is a pointer +vlib/v/checker/tests/fn_args.vv:12:6: error: cannot use `fn (...int)` as `fn (int)` in argument 1 to `fun` + 10 | arr([5]!) + 11 | fun(fn (i &int) {}) + 12 | fun(fn (ii ...int) {}) + | ~~~~~~~~~~~~~~~~~ + 13 | } + 14 | +vlib/v/checker/tests/fn_args.vv:22:4: error: cannot use `int` as `&S1` in argument 1 to `f` + 20 | fn ptr() { + 21 | v := 4 + 22 | f(v) + | ^ + 23 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_args.vv b/v_windows/v/old/vlib/v/checker/tests/fn_args.vv new file mode 100644 index 0000000..5cfdff5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_args.vv @@ -0,0 +1,23 @@ +fn uu8(a byte) {} + +fn arr(a []int) {} + +fn fun(a fn (int)) {} + +fn basic() { + v := 4 + uu8(&v) + arr([5]!) + fun(fn (i &int) {}) + fun(fn (ii ...int) {}) +} + +struct S1 { +} + +fn f(p &S1) {} + +fn ptr() { + v := 4 + f(v) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.out b/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.out new file mode 100644 index 0000000..376fc56 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/fn_call_no_body.vv:7:9: error: cannot call a method that does not have a body + 5 | + 6 | fn main() { + 7 | Foo(0).f() + | ~~~ + 8 | f() + 9 | } +vlib/v/checker/tests/fn_call_no_body.vv:8:2: error: cannot call a function that does not have a body + 6 | fn main() { + 7 | Foo(0).f() + 8 | f() + | ~~~ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.vv b/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.vv new file mode 100644 index 0000000..1058977 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_call_no_body.vv @@ -0,0 +1,9 @@ +type Foo = int +fn (_ Foo) f() + +fn f() + +fn main() { + Foo(0).f() + f() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.out b/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.out new file mode 100644 index 0000000..3cf949c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.out @@ -0,0 +1,13 @@ +redefinition of function `main.f` +vlib/v/checker/tests/fn_duplicate.vv:1:1: conflicting declaration: fn f() + 1 | fn f() { + | ~~~~~~ + 2 | + 3 | } +vlib/v/checker/tests/fn_duplicate.vv:5:1: conflicting declaration: fn f(i int) + 3 | } + 4 | + 5 | fn f(i int) { + | ~~~~~~~~~~~ + 6 | + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.vv b/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.vv new file mode 100644 index 0000000..08c1dfb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_duplicate.vv @@ -0,0 +1,7 @@ +fn f() { + +} + +fn f(i int) { + +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.out b/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.out new file mode 100644 index 0000000..08cb17b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/fn_init_sig.vv:1:1: error: fn `init` cannot have a return type + 1 | fn init() int { + | ~~~~~~~~~~~~~ + 2 | return 1 + 3 | } +vlib/v/checker/tests/fn_init_sig.vv:4:1: error: fn `init` must not be public + 2 | return 1 + 3 | } + 4 | pub fn init() int { + | ~~~~~~~~~~~~~~~~~ + 5 | return 1 + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.vv b/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.vv new file mode 100644 index 0000000..bff6d49 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_init_sig.vv @@ -0,0 +1,6 @@ +fn init() int { + return 1 +} +pub fn init() int { + return 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.out b/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.out new file mode 100644 index 0000000..ebb4494 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/fn_return_or_err.vv:6:17: error: unexpected `or` block, the function `pop` does not return an optional + 4 | + 5 | pub fn next(mut v []Typ) Typ { + 6 | return v.pop() or { Typ{} } + | ~~~~~~~~~~~~ + 7 | } + 8 | diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.vv b/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.vv new file mode 100644 index 0000000..c303b0a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_return_or_err.vv @@ -0,0 +1,13 @@ +module main + +pub struct Typ {} + +pub fn next(mut v []Typ) Typ { + return v.pop() or { Typ{} } +} + +fn main() { + mut v := [Typ{}] + last := next(mut v) + println('$last') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.out b/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.out new file mode 100644 index 0000000..c6aa40f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.out @@ -0,0 +1,10 @@ +vlib/v/checker/tests/fn_type_exists.vv:1:34: error: unknown type `Pants` + 1 | type PantsCreator = fn (a Shirt) Pants + | ~~~~~ + 2 | + 3 | type PantsConsumer = fn (p Pants) +vlib/v/checker/tests/fn_type_exists.vv:3:28: error: unknown type `Pants` + 1 | type PantsCreator = fn (a Shirt) Pants + 2 | + 3 | type PantsConsumer = fn (p Pants) + | ~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.vv b/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.vv new file mode 100644 index 0000000..04ead19 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_type_exists.vv @@ -0,0 +1,3 @@ +type PantsCreator = fn (a Shirt) Pants + +type PantsConsumer = fn (p Pants) diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_var.out b/v_windows/v/old/vlib/v/checker/tests/fn_var.out new file mode 100644 index 0000000..d3487a1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_var.out @@ -0,0 +1,23 @@ +vlib/v/checker/tests/fn_var.vv:1:10: error: missing return at the end of an anonymous function + 1 | mut f := fn(i int) byte {} + | ~~~~~~~~~~~~~~~~~ + 2 | f = 4 + 3 | mut p := &f +vlib/v/checker/tests/fn_var.vv:2:5: error: cannot assign to `f`: expected `fn (int) byte`, not `int literal` + 1 | mut f := fn(i int) byte {} + 2 | f = 4 + | ^ + 3 | mut p := &f + 4 | p = &[f] +vlib/v/checker/tests/fn_var.vv:4:5: error: cannot assign to `p`: expected `&fn (int) byte`, not `&[]fn (int) byte` + 2 | f = 4 + 3 | mut p := &f + 4 | p = &[f] + | ^ + 5 | _ = p + 6 | i := 0 +vlib/v/checker/tests/fn_var.vv:8:31: error: undefined ident: `i` + 6 | i := 0 + 7 | println(i) + 8 | f = fn(mut a []int) { println(i) } + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_var.vv b/v_windows/v/old/vlib/v/checker/tests/fn_var.vv new file mode 100644 index 0000000..0a48b5d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_var.vv @@ -0,0 +1,8 @@ +mut f := fn(i int) byte {} +f = 4 +mut p := &f +p = &[f] +_ = p +i := 0 +println(i) +f = fn(mut a []int) { println(i) } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_variadic.out b/v_windows/v/old/vlib/v/checker/tests/fn_variadic.out new file mode 100644 index 0000000..f14183a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_variadic.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/fn_variadic.vv:3:8: error: when forwarding a variadic variable, it must be the final argument + 1 | fn f(vi ...int) int { + 2 | _ = f(...vi) // OK + 3 | _ = f(...vi, 2) + | ~~~~~ + 4 | return 0 + 5 | } +vlib/v/checker/tests/fn_variadic.vv:11:10: error: when forwarding a variadic variable, it must be the final argument + 9 | fn (s S1) m(vi ...int) int { + 10 | _ = s.m(...vi) // OK + 11 | _ = s.m(...vi, 2) + | ~~~~~ + 12 | return 0 + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/fn_variadic.vv b/v_windows/v/old/vlib/v/checker/tests/fn_variadic.vv new file mode 100644 index 0000000..b7faad7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/fn_variadic.vv @@ -0,0 +1,13 @@ +fn f(vi ...int) int { + _ = f(...vi) // OK + _ = f(...vi, 2) + return 0 +} + +struct S1 {} + +fn (s S1) m(vi ...int) int { + _ = s.m(...vi) // OK + _ = s.m(...vi, 2) + return 0 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.out b/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.out new file mode 100644 index 0000000..bbab32a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/for_in_index_optional.vv:3:18: error: for in: cannot index `?[]string` + 1 | import os + 2 | fn main() { + 3 | for file in os.ls('.') { + | ~~~~~~~ + 4 | println(file) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.vv new file mode 100644 index 0000000..c384c79 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_index_optional.vv @@ -0,0 +1,6 @@ +import os +fn main() { + for file in os.ls('.') { + println(file) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.out b/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.out new file mode 100644 index 0000000..376ba73 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/for_in_index_type.vv:2:11: error: for in: cannot index `int literal` + 1 | fn main() { + 2 | for a in 52 { + | ~~ + 3 | println(a) + 4 | } +vlib/v/checker/tests/for_in_index_type.vv:3:3: error: `println` can not print void expressions + 1 | fn main() { + 2 | for a in 52 { + 3 | println(a) + | ~~~~~~~~~~ + 4 | } + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.vv new file mode 100644 index 0000000..cbc26ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_index_type.vv @@ -0,0 +1,5 @@ +fn main() { + for a in 52 { + println(a) + } +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.out b/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.out new file mode 100644 index 0000000..d7c6579 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.out @@ -0,0 +1,8 @@ +vlib/v/checker/tests/for_in_map_one_variable_err.vv:3:6: error: declare a key and a value variable when ranging a map: `for key, val in map {` +use `_` if you do not need the variable + 1 | fn main() { + 2 | kvs := map{'foo':'bar'} + 3 | for k in kvs { + | ^ + 4 | println('$k') + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.vv new file mode 100644 index 0000000..9297280 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_map_one_variable_err.vv @@ -0,0 +1,6 @@ +fn main() { + kvs := map{'foo':'bar'} + for k in kvs { + println('$k') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.out b/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.out new file mode 100644 index 0000000..d898cf7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/for_in_mut_val_type.vv:3:15: error: `a1` is immutable, it cannot be changed + 1 | fn main() { + 2 | a1 := [1, 2, 3] + 3 | for mut j in a1 { + | ~~ + 4 | j *= 2 + 5 | } +vlib/v/checker/tests/for_in_mut_val_type.vv:7:15: error: `a2` is immutable, it cannot be changed + 5 | } + 6 | a2 := [1, 2, 3]! + 7 | for mut j in a2 { + | ~~ + 8 | j *= 2 + 9 | } +vlib/v/checker/tests/for_in_mut_val_type.vv:11:18: error: `m` is immutable, it cannot be changed + 9 | } + 10 | m := map{'aa': 1, 'bb': 2} + 11 | for _, mut j in m { + | ^ + 12 | j *= 2 + 13 | } +vlib/v/checker/tests/for_in_mut_val_type.vv:14:15: error: array literal is immutable, it cannot be changed + 12 | j *= 2 + 13 | } + 14 | for mut j in [1, 2, 3] { + | ~~~~~~~~~ + 15 | j *= 2 + 16 | } +vlib/v/checker/tests/for_in_mut_val_type.vv:17:15: error: array literal is immutable, it cannot be changed + 15 | j *= 2 + 16 | } + 17 | for mut j in [1, 2, 3]! { + | ~~~~~~~~~~ + 18 | j *= 2 + 19 | } +vlib/v/checker/tests/for_in_mut_val_type.vv:20:21: error: map literal is immutable, it cannot be changed + 18 | j *= 2 + 19 | } + 20 | for _, mut j in map{'aa': 1, 'bb': 2} { + | ~~~~~~~~~~~~~~~~~~ + 21 | j *= 2 + 22 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.vv new file mode 100644 index 0000000..664fb66 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_mut_val_type.vv @@ -0,0 +1,23 @@ +fn main() { + a1 := [1, 2, 3] + for mut j in a1 { + j *= 2 + } + a2 := [1, 2, 3]! + for mut j in a2 { + j *= 2 + } + m := map{'aa': 1, 'bb': 2} + for _, mut j in m { + j *= 2 + } + for mut j in [1, 2, 3] { + j *= 2 + } + for mut j in [1, 2, 3]! { + j *= 2 + } + for _, mut j in map{'aa': 1, 'bb': 2} { + j *= 2 + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.out b/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.out new file mode 100644 index 0000000..d969830 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/for_in_range_not_match_type.vv:2:11: error: range types do not match + 1 | fn main() { + 2 | for i in 10..10.5 { + | ~~ + 3 | println(i) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.vv new file mode 100644 index 0000000..8b15863 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_range_not_match_type.vv @@ -0,0 +1,5 @@ +fn main() { + for i in 10..10.5 { + println(i) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.out b/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.out new file mode 100644 index 0000000..4d3d531 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/for_in_range_string_type.vv:2:11: error: range type can not be string + 1 | fn main() { + 2 | for i in 'a'..'b' { + | ~~~ + 3 | println(i) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.vv b/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.vv new file mode 100644 index 0000000..a459398 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_in_range_string_type.vv @@ -0,0 +1,5 @@ +fn main() { + for i in 'a'..'b' { + println(i) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/for_match_err.out b/v_windows/v/old/vlib/v/checker/tests/for_match_err.out new file mode 100644 index 0000000..9c90a9e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_match_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/for_match_err.vv:3:7: error: cannot use `match` in `for` loop + 1 | fn main() { + 2 | mut a := 2 + 3 | for match a { + | ~~~~~ + 4 | 2 { + 5 | println('a == 2') diff --git a/v_windows/v/old/vlib/v/checker/tests/for_match_err.vv b/v_windows/v/old/vlib/v/checker/tests/for_match_err.vv new file mode 100644 index 0000000..910f39f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/for_match_err.vv @@ -0,0 +1,15 @@ +fn main() { + mut a := 2 + for match a { + 2 { + println('a == 2') + a = 0 + } + 0 { + println('a == 0') + } + else { + println('unexpected branch') + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.out b/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.out new file mode 100644 index 0000000..e676a78 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/function_arg_mutable_err.vv:1:18: error: mutable arguments are only allowed for arrays, interfaces, maps, pointers, structs or their aliases +return values instead: `fn foo(mut n int) {` => `fn foo(n int) int {` + 1 | fn mod_ptr(mut a int) { + | ~~~ + 2 | a = 77 + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.vv b/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.vv new file mode 100644 index 0000000..30165cb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_arg_mutable_err.vv @@ -0,0 +1,8 @@ +fn mod_ptr(mut a int) { + a = 77 +} + +fn main() { + println('hello') +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.out b/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.out new file mode 100644 index 0000000..e540131 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/function_arg_redefinition.vv:1:17: error: redefinition of parameter `para1` + 1 | fn f(para1 int, para1 f32) int { + | ~~~~~ + 2 | return para1 + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.vv b/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.vv new file mode 100644 index 0000000..0618fba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_arg_redefinition.vv @@ -0,0 +1,7 @@ +fn f(para1 int, para1 f32) int { + return para1 +} + +fn main() { + a := f(11, 1.1) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.out b/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.out new file mode 100644 index 0000000..d9ad12e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/function_count_of_args_mismatch_err.vv:8:13: error: expected 1 arguments, but got 3 + 6 | + 7 | fn main() { + 8 | test(true, false, 1) + | ~~~~~~~~ + 9 | test() + 10 | test2(true, false, 1) +vlib/v/checker/tests/function_count_of_args_mismatch_err.vv:9:2: error: expected 1 arguments, but got 0 + 7 | fn main() { + 8 | test(true, false, 1) + 9 | test() + | ~~~~~~ + 10 | test2(true, false, 1) + 11 | test2(true) +vlib/v/checker/tests/function_count_of_args_mismatch_err.vv:10:21: error: expected 2 arguments, but got 3 + 8 | test(true, false, 1) + 9 | test() + 10 | test2(true, false, 1) + | ^ + 11 | test2(true) + 12 | } +vlib/v/checker/tests/function_count_of_args_mismatch_err.vv:11:2: error: expected 2 arguments, but got 1 + 9 | test() + 10 | test2(true, false, 1) + 11 | test2(true) + | ~~~~~~~~~~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.vv b/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.vv new file mode 100644 index 0000000..00fe212 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_count_of_args_mismatch_err.vv @@ -0,0 +1,12 @@ +fn test(b bool) { +} + +fn test2<T>(b bool, v T) { +} + +fn main() { + test(true, false, 1) + test() + test2(true, false, 1) + test2(true) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.out b/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.out new file mode 100644 index 0000000..73292af --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/function_missing_return_type.vv:1:1: error: missing return at end of function `h` + 1 | fn h() int { + | ~~~~~~~~~~ + 2 | } + 3 | +vlib/v/checker/tests/function_missing_return_type.vv:12:1: error: missing return at end of function `abc` + 10 | } + 11 | + 12 | fn (s Abc) abc() &int { + | ~~~~~~~~~~~~~~~~~~~~~ + 13 | if true { + 14 | return &s.x diff --git a/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.vv b/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.vv new file mode 100644 index 0000000..74d8cc1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_missing_return_type.vv @@ -0,0 +1,22 @@ +fn h() int { +} + +struct Abc { + x int +} + +fn (s Abc) panic(message string) { + println('called ${@METHOD} with message: $message') +} + +fn (s Abc) abc() &int { + if true { + return &s.x + } + s.panic(@FN) +} + +fn main() { + d := h() + println('$d') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.out b/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.out new file mode 100644 index 0000000..f72b6e0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/function_variadic_arg_array_decompose.vv:11:10: error: too many arguments in call to `sum` + 9 | fn main() { + 10 | b := [5, 6, 7] + 11 | println(sum(1, 2, ...b)) + | ~~~~~~~~~~~~~~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.vv b/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.vv new file mode 100644 index 0000000..27fa0c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_variadic_arg_array_decompose.vv @@ -0,0 +1,12 @@ +fn sum(a ...int) int { + mut total := 0 + for x in a { + total += x + } + return total +} + +fn main() { + b := [5, 6, 7] + println(sum(1, 2, ...b)) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.out b/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.out new file mode 100644 index 0000000..07e4fc8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/function_wrong_arg_type.vv:7:9: error: cannot use `f64` as `int` in argument 1 to `f` + 5 | fn main() { + 6 | a := 12.3 + 7 | q := f(a) + | ^ + 8 | println('$q') + 9 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.vv b/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.vv new file mode 100644 index 0000000..6cd3fbb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_wrong_arg_type.vv @@ -0,0 +1,9 @@ +fn f(x int) int { + return x+x +} + +fn main() { + a := 12.3 + q := f(a) + println('$q') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.out b/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.out new file mode 100644 index 0000000..070d573 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/function_wrong_return_type.vv:2:9: error: cannot use `float literal` as type `int` in return argument + 1 | fn h() int { + 2 | return 3.14 + | ~~~~ + 3 | } + 4 | diff --git a/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.vv b/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.vv new file mode 100644 index 0000000..0c47628 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/function_wrong_return_type.vv @@ -0,0 +1,8 @@ +fn h() int { + return 3.14 +} + +fn main() { + d := h() + println('$d') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out b/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out new file mode 100644 index 0000000..502f2b8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:26:1: error: generic function declaration must specify generic type names, e.g. foo<T> + 24 | } + 25 | + 26 | fn g_worker(g Generic<T>) { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 27 | t := <-g.ch + 28 | handle(t) +vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv:32:1: error: generic function declaration must specify generic type names, e.g. foo<T> + 30 | } + 31 | + 32 | fn handle(t T) { + | ~~~~~~~~~~~~~~ + 33 | println("hi") + 34 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv b/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv new file mode 100644 index 0000000..cc001e9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_fn_decl_without_generic_names_err.vv @@ -0,0 +1,34 @@ +struct Generic<T> { + ch chan T +} + +struct Concrete { + msg string +} + +fn main() { + g := create_generic_t<Concrete>() + g.ch <- Concrete{ + msg: 'hello' + } +} + +fn create_generic_t<T>() Generic<T> { + g := Generic{ + ch: chan T{} + } + + go g_worker(g) + + return g +} + +fn g_worker(g Generic<T>) { + t := <-g.ch + handle(t) + // println("${t.msg}") +} + +fn handle(t T) { + println("hi") +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.out b/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.out new file mode 100644 index 0000000..eb4ee7c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/generic_param_used_as_an_array_err.vv:2:10: error: generic type T does not support indexing, pass an array, or a reference instead, e.g. []T or &T + 1 | fn test<T>(arr T) { + 2 | a := arr[1] + | ~~~ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.vv b/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.vv new file mode 100644 index 0000000..f545b77 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_param_used_as_an_array_err.vv @@ -0,0 +1,12 @@ +fn test<T>(arr T) { + a := arr[1] + println(a) +} + +fn main() { + a := [1, 2, 3]! + test(a) + + b := ['a', 'b', 'c']! + test(b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.out b/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.out new file mode 100644 index 0000000..c82df9e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/generic_sumtype_invalid_variant.vv:5:7: error: `MultiGeneric<bool,int,string>` has no variant `u64` + 3 | fn main() { + 4 | mut m := MultiGeneric<bool, int, string>(true) + 5 | if m is u64 { + | ~~ + 6 | println('hi') + 7 | } +vlib/v/checker/tests/generic_sumtype_invalid_variant.vv:8:7: error: `MultiGeneric<bool,int,string>` has no variant `X` + 6 | println('hi') + 7 | } + 8 | if m is X { + | ~~ + 9 | println('hi again') + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.vv b/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.vv new file mode 100644 index 0000000..3cde35b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generic_sumtype_invalid_variant.vv @@ -0,0 +1,11 @@ +type MultiGeneric<X, Y, Z> = X | Y | Z + +fn main() { + mut m := MultiGeneric<bool, int, string>(true) + if m is u64 { + println('hi') + } + if m is X { + println('hi again') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.out new file mode 100644 index 0000000..f6913f5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv:6:15: error: cannot use `int literal` as `bool` in argument 1 to `foo` + 4 | + 5 | fn main() { + 6 | foo<bool>(1) + | ^ + 7 | foo<bool>(2.2) + 8 | foo<string>(true) +vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv:7:15: error: cannot use `float literal` as `bool` in argument 1 to `foo` + 5 | fn main() { + 6 | foo<bool>(1) + 7 | foo<bool>(2.2) + | ~~~ + 8 | foo<string>(true) + 9 | foo<int>('aaa') +vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv:8:17: error: cannot use `bool` as `string` in argument 1 to `foo` + 6 | foo<bool>(1) + 7 | foo<bool>(2.2) + 8 | foo<string>(true) + | ~~~~ + 9 | foo<int>('aaa') + 10 | } +vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv:9:14: error: cannot use `string` as `int` in argument 1 to `foo` + 7 | foo<bool>(2.2) + 8 | foo<string>(true) + 9 | foo<int>('aaa') + | ~~~~~ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv new file mode 100644 index 0000000..1960a54 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_arg_mismatch.vv @@ -0,0 +1,10 @@ +fn foo<T>(b T) { + println(b) +} + +fn main() { + foo<bool>(1) + foo<bool>(2.2) + foo<string>(true) + foo<int>('aaa') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.out new file mode 100644 index 0000000..3f23d6b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv:3:13: error: cannot use `[]rune` as `string` in argument 2 to `foo_str` + 1 | fn main() { + 2 | x := 'ab'.runes()[..1] + 3 | foo_str(1, x) + | ^ + 4 | + 5 | foo := Foo<int>{} +vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv:6:11: error: cannot use `[]rune` as `string` in argument 1 to `Foo<int>.info` + 4 | + 5 | foo := Foo<int>{} + 6 | foo.info(x) + | ^ + 7 | } + 8 | diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv new file mode 100644 index 0000000..fdbdf4d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_multi_args_mismatch.vv @@ -0,0 +1,17 @@ +fn main() { + x := 'ab'.runes()[..1] + foo_str(1, x) + + foo := Foo<int>{} + foo.info(x) +} + +fn foo_str<T>(b T, a string) { +} + +struct Foo<T> { + t T +} + +fn (f Foo<T>) info(a string) { +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.out new file mode 100644 index 0000000..4212808 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/generics_fn_called_no_arg_err.vv:13:10: error: no argument generic function must add concrete types, e.g. foo<int>() + 11 | + 12 | fn main() { + 13 | q := new_queue() + | ~~~~~~~~~~~ + 14 | println(q) + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.vv new file mode 100644 index 0000000..a05e1d5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_no_arg_err.vv @@ -0,0 +1,15 @@ +struct Queue<T>{ + buffer []T +} + +fn new_queue<T>() Queue<T> { + q := Queue<T>{ + buffer: []T{cap: 1024} + } + return q +} + +fn main() { + q := new_queue() + println(q) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.out new file mode 100644 index 0000000..ec84b67 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.vv:4:2: error: generic fn using generic types cannot be called outside of generic fn + 2 | + 3 | fn main() { + 4 | foo<T>() + | ~~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.vv new file mode 100644 index 0000000..c8b72c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_outside_of_generic_fn.vv @@ -0,0 +1,5 @@ +fn foo<T>() {} + +fn main() { + foo<T>() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.out new file mode 100644 index 0000000..cf4d3b2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.vv:12:11: error: cannot use `[]int` as `int` in argument 1 to `max` + 10 | + 11 | fn main() { + 12 | a := max([1, 2, 3, 4]) + | ~~~~~~~~~~~~ + 13 | println(a) + 14 | +vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.vv:15:16: error: cannot use `[]int` as `int` in argument 1 to `max` + 13 | println(a) + 14 | + 15 | b := max<int>([1, 2, 3, 4]) + | ~~~~~~~~~~~~ + 16 | println(b) + 17 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.vv new file mode 100644 index 0000000..e322a64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_called_variadic_arg_mismatch.vv @@ -0,0 +1,17 @@ +fn max<T>(a ...T) T { + mut max := a[0] + for item in a[1..] { + if max < item { + max = item + } + } + return max +} + +fn main() { + a := max([1, 2, 3, 4]) + println(a) + + b := max<int>([1, 2, 3, 4]) + println(b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out b/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out new file mode 100644 index 0000000..b6efe45 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:13:32: error: return generic struct in fn declaration must specify the generic type names, e.g. Foo<T> + 11 | } + 12 | + 13 | pub fn new_channel_struct<T>() GenericChannelStruct { + | ~~~~~~~~~~~~~~~~~~~~ + 14 | d := GenericChannelStruct{ + 15 | ch: chan T{} +vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv:17:9: error: cannot use `GenericChannelStruct<Simple>` as type `GenericChannelStruct` in return argument + 15 | ch: chan T{} + 16 | } + 17 | return d + | ^ + 18 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv b/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv new file mode 100644 index 0000000..0f9a5d5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_fn_return_generic_struct_err.vv @@ -0,0 +1,18 @@ +struct GenericChannelStruct<T> { + ch chan T +} + +struct Simple { + msg string +} + +fn main() { + new_channel_struct<Simple>() +} + +pub fn new_channel_struct<T>() GenericChannelStruct { + d := GenericChannelStruct{ + ch: chan T{} + } + return d +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.out b/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.out new file mode 100644 index 0000000..1a8b84d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/generics_method_receiver_type_err.vv:6:11: error: receiver must specify the generic type names, e.g. Foo<T> + 4 | } + 5 | + 6 | pub fn (x Node) str() string { + | ~~~~ + 7 | return 'Value is : ${u16(x.val)}\nName is : $x.name' + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.vv new file mode 100644 index 0000000..8a6763c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_method_receiver_type_err.vv @@ -0,0 +1,16 @@ +struct Node<T> { + val T + name string +} + +pub fn (x Node) str() string { + return 'Value is : ${u16(x.val)}\nName is : $x.name' +} + +fn main() { + xx := Node<u16>{ + val: u16(11) + name: 'man' + } + println(xx.str()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.out b/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.out new file mode 100644 index 0000000..0c2c68e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv:4:15: error: a non generic function called like a generic one + 2 | + 3 | fn main() { + 4 | x := math.sin<f64>(1.0) + | ~~~~~ + 5 | println(x) + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv b/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv new file mode 100644 index 0000000..d25ddd1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_non_generic_fn_called_like_a_generic_one.vv @@ -0,0 +1,6 @@ +import math + +fn main() { + x := math.sin<f64>(1.0) + println(x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.out b/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.out new file mode 100644 index 0000000..bd3b2c3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/generics_struct_declaration_err.vv:5:1: error: generic struct declaration must specify the generic type names, e.g. Foo<T> + 3 | } + 4 | + 5 | struct MyGenericChannelStruct { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | GenericChannelStruct<T> + 7 | msg string diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.vv b/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.vv new file mode 100644 index 0000000..4828ea3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_struct_declaration_err.vv @@ -0,0 +1,24 @@ +struct GenericChannelStruct<T> { + ch chan T +} + +struct MyGenericChannelStruct { + GenericChannelStruct<T> + msg string +} + +struct Simple { + msg string +} + +fn main() { + new_channel_struct<Simple>() +} + +pub fn new_channel_struct<T>() GenericChannelStruct<T> { + d := GenericChannelStruct{ + ch: chan T{} + } + + return d +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.out b/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.out new file mode 100644 index 0000000..c55c336 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/generics_struct_init_err.vv:58:8: error: generic struct init must specify type parameter, e.g. Foo<int> + 56 | ret = holder_call_12(neg, 3) + 57 | assert ret == -3 + 58 | ret = FnHolder1{neg}.call(4) + | ~~~~~~~~~~~~~~ + 59 | assert ret == -4 + 60 | +vlib/v/checker/tests/generics_struct_init_err.vv:67:8: error: generic struct init must specify type parameter, e.g. Foo<int> + 65 | ret = holder_call_22(neg, 5) + 66 | assert ret == -5 + 67 | ret = FnHolder2{neg}.call(6) + | ~~~~~~~~~~~~~~ + 68 | assert ret == -6 + 69 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.vv b/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.vv new file mode 100644 index 0000000..4116799 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_struct_init_err.vv @@ -0,0 +1,69 @@ +fn neg(a int) int { + return -a +} + +struct FnHolder1<T> { + func T +} + +fn (self FnHolder1<T>) call(a int) int { + return self.func(a) +} + +struct FnHolder2<T> { + func fn (int) int +} + +fn (self FnHolder2<T>) call(a int) int { + return self.func(a) +} + +fn holder_call_1<T>(func T, a int) int { + h := FnHolder1{func} + return h.call(a) +} + +fn holder_call_2<T>(func T, a int) int { + h := FnHolder2{func} + return h.call(a) +} + +fn holder_call_11<T>(func T, a int) int { + f := func + h := FnHolder1{f} + return h.call(a) +} + +fn holder_call_21<T>(func T, a int) int { + f := func + h := FnHolder2{f} + return h.call(a) +} + +fn holder_call_12<T>(func T, a int) int { + return FnHolder1{func}.call(a) +} + +fn holder_call_22<T>(func T, a int) int { + return FnHolder2{func}.call(a) +} + +fn main() { + mut ret := holder_call_1(neg, 1) + assert ret == -1 + ret = holder_call_11(neg, 2) + assert ret == -2 + ret = holder_call_12(neg, 3) + assert ret == -3 + ret = FnHolder1{neg}.call(4) + assert ret == -4 + + ret = holder_call_2(neg, 3) + assert ret == -3 + ret = holder_call_21(neg, 4) + assert ret == -4 + ret = holder_call_22(neg, 5) + assert ret == -5 + ret = FnHolder2{neg}.call(6) + assert ret == -6 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.out b/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.out new file mode 100644 index 0000000..caea12a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/generics_too_many_parameters.vv:6:8: error: too many generic parameters got 5, expected 1 + 4 | + 5 | fn main() { + 6 | foo<bool, int, bool, bool, int>(1) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.vv b/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.vv new file mode 100644 index 0000000..980e1ff --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_too_many_parameters.vv @@ -0,0 +1,7 @@ +fn foo<T>(b T) { + println(b) +} + +fn main() { + foo<bool, int, bool, bool, int>(1) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.out b/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.out new file mode 100644 index 0000000..affad87 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/generics_type_ambiguous.vv:7:19: error: inferred generic type `B` is ambiguous: got `int`, expected `string` + 5 | + 6 | fn main() { + 7 | test(2, 2, "2", 2) + | ^ + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.vv b/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.vv new file mode 100644 index 0000000..9eb0f39 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/generics_type_ambiguous.vv @@ -0,0 +1,8 @@ +fn test<T, B> (a T, b T, c B, d B) { + println("$a $b $c $d") +} + + +fn main() { + test(2, 2, "2", 2) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.out b/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.out new file mode 100644 index 0000000..2c3865e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/globals/assign_no_value.vv:1:19: error: undefined ident: `int` + 1 | __global ( test = int ) + | ~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.vv b/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.vv new file mode 100644 index 0000000..352847e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/assign_no_value.vv @@ -0,0 +1 @@ +__global ( test = int )
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.out b/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.out new file mode 100644 index 0000000..05d2e26 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/globals/incorrect_name_global.vv:1:12: error: global name `A` cannot contain uppercase letters, use snake_case instead + 1 | __global ( A = int(1) ) + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.vv b/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.vv new file mode 100644 index 0000000..c9550d8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/incorrect_name_global.vv @@ -0,0 +1 @@ +__global ( A = int(1) ) diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/no_type.out b/v_windows/v/old/vlib/v/checker/tests/globals/no_type.out new file mode 100644 index 0000000..71899d9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/no_type.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/globals/no_type.vv:1:17: error: expecting type declaration + 1 | __global ( test ) + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/no_type.vv b/v_windows/v/old/vlib/v/checker/tests/globals/no_type.vv new file mode 100644 index 0000000..264ed9d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/no_type.vv @@ -0,0 +1 @@ +__global ( test ) diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.out b/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.out new file mode 100644 index 0000000..f0a6cbc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/globals/unexpected_eof.vv:3:1: error: unexpected eof, expecting ´)´ + 1 | __global ( + 2 | x string diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.vv b/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.vv new file mode 100644 index 0000000..ab9c9c6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/unexpected_eof.vv @@ -0,0 +1,2 @@ +__global ( + x string diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.out b/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.out new file mode 100644 index 0000000..60b44bb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.out @@ -0,0 +1,11 @@ +vlib/v/checker/tests/globals/unknown_typ.vv:1:12: error: unknown type `foo` + 1 | __global x foo + | ~~~ + 2 | __global ( + 3 | y = float(5.0) +vlib/v/checker/tests/globals/unknown_typ.vv:3:6: error: unknown function: float + 1 | __global x foo + 2 | __global ( + 3 | y = float(5.0) + | ~~~~~~~~~~ + 4 | ) diff --git a/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.vv b/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.vv new file mode 100644 index 0000000..9d7fdd1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals/unknown_typ.vv @@ -0,0 +1,4 @@ +__global x foo +__global ( + y = float(5.0) +) diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_error.out b/v_windows/v/old/vlib/v/checker/tests/globals_error.out new file mode 100644 index 0000000..1dcbb36 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_error.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/globals_error.vv:2:1: error: use `v -enable-globals ...` to enable globals + 1 | + 2 | __global ( rfcnt int ) + | ~~~~~~~~ + 3 | + 4 | fn abc(){ diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_error.run.out b/v_windows/v/old/vlib/v/checker/tests/globals_error.run.out new file mode 100644 index 0000000..525f325 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_error.run.out @@ -0,0 +1 @@ +rfcnt: 2 diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_error.vv b/v_windows/v/old/vlib/v/checker/tests/globals_error.vv new file mode 100644 index 0000000..51048dc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_error.vv @@ -0,0 +1,12 @@ + +__global ( rfcnt int ) + +fn abc(){ + rfcnt = 2 +} + +fn main(){ + rfcnt = 1 + abc() + println('rfcnt: $rfcnt') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.run.out b/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.run.out new file mode 100644 index 0000000..586eac7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.run.out @@ -0,0 +1,4 @@ +[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:14] voidptr(main.abc) == voidptr(cpu_get_id): true +[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:15] main.cpu_get_id(): 123 +[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:16] abc(): 123 +[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:17] abc() == main.cpu_get_id(): true diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.vv b/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.vv new file mode 100644 index 0000000..e74825e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_run/function_stored_in_global.vv @@ -0,0 +1,20 @@ +__global ( + cpu_get_id fn () u64 +) +fn current() u64 { + return cpu_get_id() +} + +fn abc() u64 { + return 123 +} + +fn main() { + cpu_get_id = abc + dump(voidptr(abc) == voidptr(cpu_get_id)) + dump(cpu_get_id()) + dump(abc()) + dump(abc() == cpu_get_id()) + assert abc() == cpu_get_id() + assert voidptr(abc) == voidptr(cpu_get_id) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.run.out b/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.run.out new file mode 100644 index 0000000..7968dd1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.run.out @@ -0,0 +1,3 @@ +[vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv:30] cpu_locals.map(it.x): [123, 456] +[vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv:33] x.x: 123 +[vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv:36] y.x: 456 diff --git a/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv b/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv new file mode 100644 index 0000000..272df4c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/globals_run/global_array_indexed_by_global_fn.vv @@ -0,0 +1,40 @@ +struct Local { + x int +} + +__global ( + cpu_locals []&Local +) + +__global ( + cpu_get_id fn () u64 + cpu_set_id fn (u64) +) + +fn abc0() u64 { + return 0 +} + +fn abc1() u64 { + return 1 +} + +pub fn current() &Local { + return cpu_locals[cpu_get_id()] +} + +fn main() { + cpu_locals = []&Local{} + cpu_locals << &Local{123} + cpu_locals << &Local{456} + dump(cpu_locals.map(it.x)) + cpu_get_id = abc0 + x := current() + dump(x.x) + cpu_get_id = abc1 + y := current() + dump(y.x) + assert x != y + assert x.x == 123 + assert y.x == 456 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/go_expr.out b/v_windows/v/old/vlib/v/checker/tests/go_expr.out new file mode 100644 index 0000000..e19c961 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_expr.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/go_expr.vv:2:5: error: expression in `go` must be a function call + 1 | fn main() { + 2 | go 1 + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/go_expr.vv b/v_windows/v/old/vlib/v/checker/tests/go_expr.vv new file mode 100644 index 0000000..969b29d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_expr.vv @@ -0,0 +1,3 @@ +fn main() { + go 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.out b/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.out new file mode 100644 index 0000000..70271b1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/go_mut_arg.vv:14:16: error: function in `go` statement cannot contain mutable non-reference arguments + 12 | a: 0 + 13 | } + 14 | go change(mut x) + | ^ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.vv b/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.vv new file mode 100644 index 0000000..af86f15 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_mut_arg.vv @@ -0,0 +1,15 @@ +struct St { +mut: + a int +} + +fn change(mut a St) { + a.a++ +} + +fn main() { + mut x := St{ + a: 0 + } + go change(mut x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.out b/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.out new file mode 100644 index 0000000..f8b2681 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/go_mut_receiver.vv:14:5: error: method in `go` statement cannot have non-reference mutable receiver + 12 | a: 0 + 13 | } + 14 | go x.change() + | ^ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.vv b/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.vv new file mode 100644 index 0000000..0b64d51 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_mut_receiver.vv @@ -0,0 +1,15 @@ +struct St { +mut: + a int +} + +fn (mut a St) change() { + a.a++ +} + +fn main() { + mut x := St{ + a: 0 + } + go x.change() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/go_wait_or.out b/v_windows/v/old/vlib/v/checker/tests/go_wait_or.out new file mode 100644 index 0000000..146f4fb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_wait_or.out @@ -0,0 +1,69 @@ +vlib/v/checker/tests/go_wait_or.vv:11:17: error: unexpected `?`, the function `wait` does not return an optional + 9 | go d(1) + 10 | ] + 11 | r := tg.wait() ? + | ^ + 12 | println(r) + 13 | s := tg[0].wait() or { panic('problem') } +vlib/v/checker/tests/go_wait_or.vv:13:20: error: unexpected `or` block, the function `wait` does not return an optional + 11 | r := tg.wait() ? + 12 | println(r) + 13 | s := tg[0].wait() or { panic('problem') } + | ~~~~~~~~~~~~~~~~~~~~~~~ + 14 | println(s) + 15 | tg2 := [ +vlib/v/checker/tests/go_wait_or.vv:19:13: error: unexpected `or` block, the function `wait` does not return an optional + 17 | go e(1) + 18 | ] + 19 | tg2.wait() or { panic('problem') } + | ~~~~~~~~~~~~~~~~~~~~~~~ + 20 | tg2[0].wait() ? + 21 | tg3 := [ +vlib/v/checker/tests/go_wait_or.vv:20:16: error: unexpected `?`, the function `wait` does not return an optional + 18 | ] + 19 | tg2.wait() or { panic('problem') } + 20 | tg2[0].wait() ? + | ^ + 21 | tg3 := [ + 22 | go f(0) +vlib/v/checker/tests/go_wait_or.vv:25:6: error: `.wait()` cannot be called for an array when thread functions return optionals. Iterate over the arrays elements instead and handle each returned optional with `or`. + 23 | go f(1) + 24 | ] + 25 | tg3.wait() or { panic('problem') } + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 26 | for t in tg3 { + 27 | a := t.wait() +vlib/v/checker/tests/go_wait_or.vv:27:10: error: wait() returns an option, so it should have either an `or {}` block, or `?` at the end + 25 | tg3.wait() or { panic('problem') } + 26 | for t in tg3 { + 27 | a := t.wait() + | ~~~~~~ + 28 | println(a) + 29 | } +vlib/v/checker/tests/go_wait_or.vv:31:15: error: wait() returns an option, so it should have either an `or {}` block, or `?` at the end + 29 | } + 30 | for i, _ in tg3 { + 31 | a := tg3[i].wait() + | ~~~~~~ + 32 | println(a) + 33 | } +vlib/v/checker/tests/go_wait_or.vv:38:6: error: `.wait()` cannot be called for an array when thread functions return optionals. Iterate over the arrays elements instead and handle each returned optional with `or`. + 36 | go g(1) + 37 | ] + 38 | tg4.wait() + | ~~~~~~ + 39 | tg4[0].wait() + 40 | go g(3) or { panic('problem') } +vlib/v/checker/tests/go_wait_or.vv:39:9: error: wait() returns an option, so it should have either an `or {}` block, or `?` at the end + 37 | ] + 38 | tg4.wait() + 39 | tg4[0].wait() + | ~~~~~~ + 40 | go g(3) or { panic('problem') } + 41 | } +vlib/v/checker/tests/go_wait_or.vv:40:10: error: optional handling cannot be done in `go` call. Do it when calling `.wait()` + 38 | tg4.wait() + 39 | tg4[0].wait() + 40 | go g(3) or { panic('problem') } + | ~~~~~~~~~~~~~~~~~~~~~~~ + 41 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/go_wait_or.vv b/v_windows/v/old/vlib/v/checker/tests/go_wait_or.vv new file mode 100644 index 0000000..3522f90 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/go_wait_or.vv @@ -0,0 +1,41 @@ +fn d(n int) f64 { return f64(n) } +fn e(n int) { } +fn f(n int) ?f64 { return f64(n) } +fn g(n int) ? { } + +fn main() { + tg := [ + go d(0) + go d(1) + ] + r := tg.wait() ? + println(r) + s := tg[0].wait() or { panic('problem') } + println(s) + tg2 := [ + go e(0) + go e(1) + ] + tg2.wait() or { panic('problem') } + tg2[0].wait() ? + tg3 := [ + go f(0) + go f(1) + ] + tg3.wait() or { panic('problem') } + for t in tg3 { + a := t.wait() + println(a) + } + for i, _ in tg3 { + a := tg3[i].wait() + println(a) + } + tg4 := [ + go g(0) + go g(1) + ] + tg4.wait() + tg4[0].wait() + go g(3) or { panic('problem') } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/goto_label.out b/v_windows/v/old/vlib/v/checker/tests/goto_label.out new file mode 100644 index 0000000..9312085 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/goto_label.out @@ -0,0 +1,63 @@ +vlib/v/checker/tests/goto_label.vv:5:7: error: unknown label `a1` + 3 | goto f2 + 4 | f1: + 5 | goto a1 + | ~~ + 6 | _ = fn(){ + 7 | goto f1 +vlib/v/checker/tests/goto_label.vv:7:8: error: unknown label `f1` + 5 | goto a1 + 6 | _ = fn(){ + 7 | goto f1 + | ~~ + 8 | goto f2 + 9 | goto a1 +vlib/v/checker/tests/goto_label.vv:8:8: error: unknown label `f2` + 6 | _ = fn(){ + 7 | goto f1 + 8 | goto f2 + | ~~ + 9 | goto a1 + 10 | a1: +vlib/v/checker/tests/goto_label.vv:9:8: error: `goto` requires `unsafe` (consider using labelled break/continue) + 7 | goto f1 + 8 | goto f2 + 9 | goto a1 + | ~~ + 10 | a1: + 11 | goto a1 +vlib/v/checker/tests/goto_label.vv:11:8: error: `goto` requires `unsafe` (consider using labelled break/continue) + 9 | goto a1 + 10 | a1: + 11 | goto a1 + | ~~ + 12 | } + 13 | f2: +vlib/v/checker/tests/goto_label.vv:14:7: error: unknown label `a1` + 12 | } + 13 | f2: + 14 | goto a1 + | ~~ + 15 | goto f1 // back + 16 | goto f2 +vlib/v/checker/tests/goto_label.vv:22:7: error: unknown label `f1` + 20 | goto g1 // forward + 21 | g1: + 22 | goto f1 + | ~~ + 23 | goto a1 + 24 | goto g1 // back +vlib/v/checker/tests/goto_label.vv:23:7: error: unknown label `a1` + 21 | g1: + 22 | goto f1 + 23 | goto a1 + | ~~ + 24 | goto g1 // back + 25 | goto undefined +vlib/v/checker/tests/goto_label.vv:25:7: error: unknown label `undefined` + 23 | goto a1 + 24 | goto g1 // back + 25 | goto undefined + | ~~~~~~~~~ + 26 | }} + 27 | diff --git a/v_windows/v/old/vlib/v/checker/tests/goto_label.vv b/v_windows/v/old/vlib/v/checker/tests/goto_label.vv new file mode 100644 index 0000000..23b2cd7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/goto_label.vv @@ -0,0 +1,33 @@ +fn f() {unsafe { + goto f1 // forward + goto f2 + f1: + goto a1 + _ = fn(){ + goto f1 + goto f2 + goto a1 + a1: + goto a1 + } + f2: + goto a1 + goto f1 // back + goto f2 +}} + +fn g() {unsafe { + goto g1 // forward + g1: + goto f1 + goto a1 + goto g1 // back + goto undefined +}} + +// implicit main +unsafe { + goto m1 + m1: + goto m1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.out new file mode 100644 index 0000000..f6407ba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/hex_lit_without_digit_err.vv:2:14: error: number part of this hexadecimal is not provided + 1 | fn main() { + 2 | println(0x) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.vv new file mode 100644 index 0000000..7063035 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_lit_without_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.out new file mode 100644 index 0000000..16ebb52 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/hex_lit_wrong_digit_err.vv:2:18: error: this hexadecimal number has unsuitable digit `g` + 1 | fn main() { + 2 | println(0x111ghi) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.vv new file mode 100644 index 0000000..1b7b07d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_lit_wrong_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0x111ghi) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.out b/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.out new file mode 100644 index 0000000..9475150 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.out @@ -0,0 +1,18 @@ +vlib/v/checker/tests/hex_literal_overflow.vv:1:7: error: hex character literal overflows string + 1 | a := '\x11ffff' + | ~~~~~~~~ + 2 | b := '\x20ffff' + 3 | c := '\x10fffff' +vlib/v/checker/tests/hex_literal_overflow.vv:2:7: error: hex character literal overflows string + 1 | a := '\x11ffff' + 2 | b := '\x20ffff' + | ~~~~~~~~ + 3 | c := '\x10fffff' + 4 | println(a) +vlib/v/checker/tests/hex_literal_overflow.vv:3:7: error: hex character literal overflows string + 1 | a := '\x11ffff' + 2 | b := '\x20ffff' + 3 | c := '\x10fffff' + | ~~~~~~~~~ + 4 | println(a) + 5 | println(b) diff --git a/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.vv b/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.vv new file mode 100644 index 0000000..60903f8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/hex_literal_overflow.vv @@ -0,0 +1,6 @@ +a := '\x11ffff' +b := '\x20ffff' +c := '\x10fffff' +println(a) +println(b) +println(c) diff --git a/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.out b/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.out new file mode 100644 index 0000000..60d6483 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/ierror_in_return_tuple.vv:1:29: error: type `IError` cannot be used in multi-return, return an option instead + 1 | fn return_ierror_in_tuple() (bool, IError) { + | ~~~~~~~~~~~~~~ + 2 | return false, error('') + 3 | } +vlib/v/checker/tests/ierror_in_return_tuple.vv:5:29: error: option cannot be used in multi-return, return an option instead + 3 | } + 4 | + 5 | fn return_option_in_tuple() (bool, ?bool) { + | ~~~~~~~~~~~~~ + 6 | return false, error('') + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.vv b/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.vv new file mode 100644 index 0000000..4717528 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ierror_in_return_tuple.vv @@ -0,0 +1,7 @@ +fn return_ierror_in_tuple() (bool, IError) { + return false, error('') +} + +fn return_option_in_tuple() (bool, ?bool) { + return false, error('') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.out b/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.out new file mode 100644 index 0000000..2fdeabc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/if_expr_last_stmt.vv:4:7: error: `if` expression requires an expression as the last statement of every branch + 2 | _ = if true { + 3 | 1 + 4 | } else if false { + | ~~~~~~~~~~~~~ + 5 | } else { + 6 | } +vlib/v/checker/tests/if_expr_last_stmt.vv:5:7: error: `if` expression requires an expression as the last statement of every branch + 3 | 1 + 4 | } else if false { + 5 | } else { + | ~~~~ + 6 | } + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.vv b/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.vv new file mode 100644 index 0000000..eb5dd0c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_last_stmt.vv @@ -0,0 +1,7 @@ +fn main() { + _ = if true { + 1 + } else if false { + } else { + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.out new file mode 100644 index 0000000..0c45b88 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/if_expr_mismatch.vv:2:7: error: mismatched types `string` and `int literal` + 1 | fn main() { + 2 | s := if true { '12' } else { 12 } + | ~~ + 3 | println(s) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.vv new file mode 100644 index 0000000..597135b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_mismatch.vv @@ -0,0 +1,4 @@ +fn main() { + s := if true { '12' } else { 12 } + println(s) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.out b/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.out new file mode 100644 index 0000000..87fb3e7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/if_expr_no_else.vv:2:9: error: `if` expression needs `else` clause + 1 | fn main() { + 2 | _ = if true { 1 } + | ~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.vv b/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.vv new file mode 100644 index 0000000..d416cc9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_no_else.vv @@ -0,0 +1,3 @@ +fn main() { + _ = if true { 1 } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.out b/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.out new file mode 100644 index 0000000..9adbc4a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/if_expr_optional_err.vv:7:5: error: non-bool type `?bool` used as if condition + 5 | fn main() { + 6 | + 7 | if get_bool() { + | ~~~~~~~~~~ + 8 | println("Using plain lists") + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.vv b/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.vv new file mode 100644 index 0000000..88d617d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_expr_optional_err.vv @@ -0,0 +1,10 @@ +fn get_bool() ?bool { + return true +} + +fn main() { + + if get_bool() { + println("Using plain lists") + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_expr.out b/v_windows/v/old/vlib/v/checker/tests/if_match_expr.out new file mode 100644 index 0000000..9c65976 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_expr.out @@ -0,0 +1,49 @@ +vlib/v/checker/tests/if_match_expr.vv:8:6: error: `if` expression branch has unsupported statement (`v.ast.ForStmt`) + 6 | if true {1} else {-1} // result + 7 | } else { + 8 | for {break} + | ^ + 9 | {} + 10 | match true {true {} else {}} // statement not expression +vlib/v/checker/tests/if_match_expr.vv:9:2: error: `if` expression branch has unsupported statement (`v.ast.Block`) + 7 | } else { + 8 | for {break} + 9 | {} + | ^ + 10 | match true {true {} else {}} // statement not expression + 11 | _ = match true {true {1} else {-1}} // OK +vlib/v/checker/tests/if_match_expr.vv:10:2: error: `if` expression branch has unsupported statement (`v.ast.MatchExpr`) + 8 | for {break} + 9 | {} + 10 | match true {true {} else {}} // statement not expression + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 11 | _ = match true {true {1} else {-1}} // OK + 12 | match true {true {1} else {-1}} // result +vlib/v/checker/tests/if_match_expr.vv:17:3: error: `match` expression branch has unsupported statement (`v.ast.IfExpr`) + 15 | _ = match true { + 16 | true { + 17 | if true {} // statement not expression + | ~~ + 18 | _ = if true {1} else {-1} // OK + 19 | if true {1} else {-1} // result +vlib/v/checker/tests/if_match_expr.vv:22:10: error: `match` expression branch has unsupported statement (`v.ast.AssertStmt`) + 20 | } + 21 | else { + 22 | assert true + | ~~~~ + 23 | match true {true {} else {}} // statement not expression + 24 | _ = match true {true {1} else {-1}} // OK +vlib/v/checker/tests/if_match_expr.vv:23:3: error: `match` expression branch has unsupported statement (`v.ast.MatchExpr`) + 21 | else { + 22 | assert true + 23 | match true {true {} else {}} // statement not expression + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 24 | _ = match true {true {1} else {-1}} // OK + 25 | match true {true {1} else {-1}} // result +vlib/v/checker/tests/if_match_expr.vv:25:3: error: return type mismatch, it should be `int` + 23 | match true {true {} else {}} // statement not expression + 24 | _ = match true {true {1} else {-1}} // OK + 25 | match true {true {1} else {-1}} // result + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 26 | } + 27 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_expr.vv b/v_windows/v/old/vlib/v/checker/tests/if_match_expr.vv new file mode 100644 index 0000000..655f25a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_expr.vv @@ -0,0 +1,27 @@ +// only C expressions are allowed for each statement + +_ = if true { + if true {} // FIXME should error, if statement + _ = if true {1} else {-1} // OK + if true {1} else {-1} // result +} else { + for {break} + {} + match true {true {} else {}} // statement not expression + _ = match true {true {1} else {-1}} // OK + match true {true {1} else {-1}} // result +} + +_ = match true { + true { + if true {} // statement not expression + _ = if true {1} else {-1} // OK + if true {1} else {-1} // result + } + else { + assert true + match true {true {} else {}} // statement not expression + _ = match true {true {1} else {-1}} // OK + match true {true {1} else {-1}} // result + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.out b/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.out new file mode 100644 index 0000000..2c16775 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/if_match_expr_err.vv:3:8: error: cannot use `match` with `if` statements + 1 | fn main() { + 2 | a := 0 + 3 | if match a { + | ~~~~~ + 4 | 0 { + 5 | println('a is zero') diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.vv b/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.vv new file mode 100644 index 0000000..511bbc7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_expr_err.vv @@ -0,0 +1,13 @@ +fn main() { + a := 0 + if match a { + 0 { + println('a is zero') + } + else { + println('unreachable branch') + } + } 5 < 7 { + println('5 is less than 7') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_result.out b/v_windows/v/old/vlib/v/checker/tests/if_match_result.out new file mode 100644 index 0000000..53a154e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_result.out @@ -0,0 +1,34 @@ +vlib/v/checker/tests/if_match_result.vv:2:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 1 | // missing results + 2 | _ = match 4 { + | ^ + 3 | 1 {} + 4 | else {} +vlib/v/checker/tests/if_match_result.vv:6:5: error: `if` expression requires an expression as the last statement of every branch + 4 | else {} + 5 | } + 6 | _ = if true { + | ~~~~~~~ + 7 | } else { + 8 | } +vlib/v/checker/tests/if_match_result.vv:7:3: error: `if` expression requires an expression as the last statement of every branch + 5 | } + 6 | _ = if true { + 7 | } else { + | ~~~~ + 8 | } + 9 | +vlib/v/checker/tests/if_match_result.vv:11:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 9 | + 10 | // void results + 11 | _ = match 4 { + | ^ + 12 | 1 {println('')} + 13 | else {exit(0)} +vlib/v/checker/tests/if_match_result.vv:15:3: error: assignment mismatch: 1 variable(s) 0 value(s) + 13 | else {exit(0)} + 14 | } + 15 | _ = if true { + | ^ + 16 | println('') + 17 | } else { diff --git a/v_windows/v/old/vlib/v/checker/tests/if_match_result.vv b/v_windows/v/old/vlib/v/checker/tests/if_match_result.vv new file mode 100644 index 0000000..ad85b13 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_match_result.vv @@ -0,0 +1,19 @@ +// missing results +_ = match 4 { + 1 {} + else {} +} +_ = if true { +} else { +} + +// void results +_ = match 4 { + 1 {println('')} + else {exit(0)} +} +_ = if true { + println('') +} else { + exit(0) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.out b/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.out new file mode 100644 index 0000000..08c9765 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/if_non_bool_cond.vv:2:5: error: non-bool type `string` used as if condition + 1 | fn main() { + 2 | if '10' { + | ~~~~ + 3 | println('10') + 4 | } +vlib/v/checker/tests/if_non_bool_cond.vv:6:5: error: non-bool type `int literal` used as if condition + 4 | } + 5 | + 6 | if 5 { + | ^ + 7 | println(5) + 8 | } +vlib/v/checker/tests/if_non_bool_cond.vv:10:5: error: non-bool type `void` used as if condition + 8 | } + 9 | + 10 | if println('v') { + | ~~~~~~~~~~~~ + 11 | println('println') + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.vv b/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.vv new file mode 100644 index 0000000..626aafe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/if_non_bool_cond.vv @@ -0,0 +1,13 @@ +fn main() { + if '10' { + println('10') + } + + if 5 { + println(5) + } + + if println('v') { + println('println') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_arg.out b/v_windows/v/old/vlib/v/checker/tests/immutable_arg.out new file mode 100644 index 0000000..6f46625 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_arg.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_arg.vv:13:8: error: `a` is immutable, declare it with `mut` to make it mutable + 11 | fn main() { + 12 | a := St{e: 2} + 13 | f(mut a) + | ^ + 14 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_arg.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_arg.vv new file mode 100644 index 0000000..08e799d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_arg.vv @@ -0,0 +1,14 @@ +struct St { +mut: + e int +} + +fn f(mut x St) { + x.e++ + println(x) +} + +fn main() { + a := St{e: 2} + f(mut a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.out b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.out new file mode 100644 index 0000000..b091e67 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_array_field_assign.vv:9:4: error: field `i` of struct `Aaa` is immutable + 7 | i: [0] + 8 | } + 9 | a.i[0] = 3 + | ^ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.vv new file mode 100644 index 0000000..adadfd6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_assign.vv @@ -0,0 +1,10 @@ +struct Aaa { + i []int +} + +fn main() { + mut a := Aaa{ + i: [0] + } + a.i[0] = 3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.out b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.out new file mode 100644 index 0000000..ec34ee2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_array_field_shift.vv:14:4: error: field `a` of struct `Bbb` is immutable + 12 | a: Aaa{} + 13 | } + 14 | b.a.i << 3 + | ^ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.vv new file mode 100644 index 0000000..f04054b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_field_shift.vv @@ -0,0 +1,15 @@ +struct Aaa { +mut: + i []int +} + +struct Bbb { + a Aaa +} + +fn main() { + mut b := Bbb{ + a: Aaa{} + } + b.a.i << 3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.out b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.out new file mode 100644 index 0000000..3675fe2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_array_struct_assign.vv:8:2: error: `a` is immutable, declare it with `mut` to make it mutable + 6 | fn main() { + 7 | a := Aaa{} + 8 | a.i[0] += 3 + | ^ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.vv new file mode 100644 index 0000000..b150d9d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_assign.vv @@ -0,0 +1,9 @@ +struct Aaa { +pub mut: + i []int +} + +fn main() { + a := Aaa{} + a.i[0] += 3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.out b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.out new file mode 100644 index 0000000..b9a25fc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_array_struct_shift.vv:8:2: error: `a` is immutable, declare it with `mut` to make it mutable + 6 | fn main() { + 7 | a := []Aaa{} + 8 | a[0].i << 3 + | ^ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.vv new file mode 100644 index 0000000..89e4d6c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_struct_shift.vv @@ -0,0 +1,9 @@ +struct Aaa { +pub mut: + i []int +} + +fn main() { + a := []Aaa{} + a[0].i << 3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.out b/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.out new file mode 100644 index 0000000..6e45b41 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_array_var.vv:3:2: error: `a` is immutable, declare it with `mut` to make it mutable + 1 | fn main() { + 2 | a := [1, 2] + 3 | a << 3 + | ^ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.vv new file mode 100644 index 0000000..1afa343 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_array_var.vv @@ -0,0 +1,4 @@ +fn main() { + a := [1, 2] + a << 3 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.out b/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.out new file mode 100644 index 0000000..059e3bc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.out @@ -0,0 +1,11 @@ +vlib/v/checker/tests/immutable_builtin_modify.vv:2:3: error: `string` can not be modified + 1 | s := '' + 2 | s.len = 123 + | ~~~ + 3 | // + 4 | b := []byte{} +vlib/v/checker/tests/immutable_builtin_modify.vv:5:3: error: `array` can not be modified + 3 | // + 4 | b := []byte{} + 5 | b.len = 34 + | ~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.vv new file mode 100644 index 0000000..e6cb706 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_builtin_modify.vv @@ -0,0 +1,5 @@ +s := '' +s.len = 123 +// +b := []byte{} +b.len = 34 diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_field.out b/v_windows/v/old/vlib/v/checker/tests/immutable_field.out new file mode 100644 index 0000000..05b6214 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_field.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_field.vv:8:4: error: field `i1` of struct `Aaa` is immutable + 6 | fn main() { + 7 | a := Aaa{1} + 8 | a.i1 = 2 + | ~~ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_field.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_field.vv new file mode 100644 index 0000000..487d913 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_field.vv @@ -0,0 +1,9 @@ +struct Aaa { +pub: + i1 int +} + +fn main() { + a := Aaa{1} + a.i1 = 2 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.out b/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.out new file mode 100644 index 0000000..fb2c4d8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/immutable_field_postfix.vv:7:4: error: field `i` of struct `Aaa` is immutable + 5 | fn main() { + 6 | mut a := Aaa{} + 7 | a.i++ + | ^ + 8 | a.i-- + 9 | } +vlib/v/checker/tests/immutable_field_postfix.vv:8:4: error: field `i` of struct `Aaa` is immutable + 6 | mut a := Aaa{} + 7 | a.i++ + 8 | a.i-- + | ^ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.vv new file mode 100644 index 0000000..0689c70 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_field_postfix.vv @@ -0,0 +1,9 @@ +struct Aaa { + i int +} + +fn main() { + mut a := Aaa{} + a.i++ + a.i-- +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.out b/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.out new file mode 100644 index 0000000..0e421af --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/immutable_interface_field.vv:10:4: error: field `i1` of interface `&Bbb` is immutable + 8 | + 9 | fn mutate_interface(mut b Bbb) { + 10 | b.i1 = 2 + | ~~ + 11 | } + 12 |
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.vv new file mode 100644 index 0000000..c3aabef --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_interface_field.vv @@ -0,0 +1,16 @@ +struct Aaa { + i1 int +} + +interface Bbb { + i1 int +} + +fn mutate_interface(mut b Bbb) { + b.i1 = 2 +} + +fn main() { + mut a := Aaa{1} + mutate_interface(mut a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_map.out b/v_windows/v/old/vlib/v/checker/tests/immutable_map.out new file mode 100644 index 0000000..3c5f7e3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_map.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/immutable_map.vv:3:2: error: `m` is immutable, declare it with `mut` to make it mutable + 1 | fn main() { + 2 | m := map[string]int + 3 | m['test']++ + | ^ + 4 | m['test']-- + 5 | _ = m.move() +vlib/v/checker/tests/immutable_map.vv:4:2: error: `m` is immutable, declare it with `mut` to make it mutable + 2 | m := map[string]int + 3 | m['test']++ + 4 | m['test']-- + | ^ + 5 | _ = m.move() + 6 | m.delete('s') +vlib/v/checker/tests/immutable_map.vv:5:6: error: `m` is immutable, declare it with `mut` to make it mutable + 3 | m['test']++ + 4 | m['test']-- + 5 | _ = m.move() + | ^ + 6 | m.delete('s') + 7 | } +vlib/v/checker/tests/immutable_map.vv:6:2: error: `m` is immutable, declare it with `mut` to make it mutable + 4 | m['test']-- + 5 | _ = m.move() + 6 | m.delete('s') + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_map.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_map.vv new file mode 100644 index 0000000..f3e0008 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_map.vv @@ -0,0 +1,7 @@ +fn main() { + m := map[string]int + m['test']++ + m['test']-- + _ = m.move() + m.delete('s') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_rec.out b/v_windows/v/old/vlib/v/checker/tests/immutable_rec.out new file mode 100644 index 0000000..4c76ed4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_rec.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/immutable_rec.vv:13:2: error: `a` is immutable, declare it with `mut` to make it mutable + 11 | fn main() { + 12 | a := St{e: 2} + 13 | a.f() + | ^ + 14 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_rec.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_rec.vv new file mode 100644 index 0000000..acbc007 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_rec.vv @@ -0,0 +1,14 @@ +struct St { +mut: + e int +} + +fn (mut x St) f() { + x.e++ + println(x) +} + +fn main() { + a := St{e: 2} + a.f() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.out b/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.out new file mode 100644 index 0000000..86c87c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/immutable_struct_postfix.vv:8:2: error: `a` is immutable, declare it with `mut` to make it mutable + 6 | fn main() { + 7 | a := Aaa{} + 8 | a.i++ + | ^ + 9 | a.i-- + 10 | } +vlib/v/checker/tests/immutable_struct_postfix.vv:9:2: error: `a` is immutable, declare it with `mut` to make it mutable + 7 | a := Aaa{} + 8 | a.i++ + 9 | a.i-- + | ^ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.vv new file mode 100644 index 0000000..dbd3e78 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_struct_postfix.vv @@ -0,0 +1,10 @@ +struct Aaa { +mut: + i int +} + +fn main() { + a := Aaa{} + a.i++ + a.i-- +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_var.out b/v_windows/v/old/vlib/v/checker/tests/immutable_var.out new file mode 100644 index 0000000..012ef94 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_var.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/immutable_var.vv:3:2: error: `a` is immutable, declare it with `mut` to make it mutable + 1 | fn main() { + 2 | a := 1 + 3 | a = 2 + | ^ + 4 | _ = a + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_var.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_var.vv new file mode 100644 index 0000000..aeeaef1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_var.vv @@ -0,0 +1,5 @@ +fn main() { + a := 1 + a = 2 + _ = a +} diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.out b/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.out new file mode 100644 index 0000000..ca05696 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/immutable_var_postfix.vv:3:2: error: `a` is immutable, declare it with `mut` to make it mutable + 1 | fn main() { + 2 | a := 1 + 3 | a++ + | ^ + 4 | a-- + 5 | } +vlib/v/checker/tests/immutable_var_postfix.vv:4:2: error: `a` is immutable, declare it with `mut` to make it mutable + 2 | a := 1 + 3 | a++ + 4 | a-- + | ^ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.vv b/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.vv new file mode 100644 index 0000000..ff1e94d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/immutable_var_postfix.vv @@ -0,0 +1,5 @@ +fn main() { + a := 1 + a++ + a-- +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.out new file mode 100644 index 0000000..3c04980 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/import_duplicate_err.vv:2:8: error: `time` was already imported on line 1 + 1 | import time + 2 | import time + | ~~~~ + 3 | fn main() { + 4 | println(time.now().unix_time()) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.vv new file mode 100644 index 0000000..f0f7d8d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_duplicate_err.vv @@ -0,0 +1,5 @@ +import time +import time +fn main() { + println(time.now().unix_time()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_middle_err.out b/v_windows/v/old/vlib/v/checker/tests/import_middle_err.out new file mode 100644 index 0000000..81c6639 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_middle_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/import_middle_err.vv:5:1: error: `import x` can only be declared at the beginning of the file + 3 | println('hello, world') + 4 | } + 5 | import os + | ~~~~~~ + 6 | fn main() { + 7 | println(time.now()) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_middle_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_middle_err.vv new file mode 100644 index 0000000..f38e462 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_middle_err.vv @@ -0,0 +1,8 @@ +import time +fn show() { + println('hello, world') +} +import os +fn main() { + println(time.now()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.out b/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.out new file mode 100644 index 0000000..5a5315b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_mod_as_mod_err.vv:1:16: error: import alias `math as math` is redundant + 1 | import math as math + | ~~~~ + 2 | + 3 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.vv new file mode 100644 index 0000000..2a12534 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_mod_as_mod_err.vv @@ -0,0 +1,5 @@ +import math as math + +fn main() { + println(math.e) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.out b/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.out new file mode 100644 index 0000000..4caef12 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_mod_sub_as_sub_err.vv:1:25: error: import alias `encoding.utf8 as utf8` is redundant + 1 | import encoding.utf8 as utf8 + | ~~~~ + 2 | + 3 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.vv new file mode 100644 index 0000000..81846bf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_mod_sub_as_sub_err.vv @@ -0,0 +1,5 @@ +import encoding.utf8 as utf8 + +fn main() { + println(utf8.validate_str('añçá')) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.out b/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.out new file mode 100644 index 0000000..7688794 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_multiple_modules_err.vv:1:13: error: cannot import multiple modules at a time + 1 | import time math + | ~~~~ + 2 | fn main() { + 3 | println(time.now().unix_time()) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.vv new file mode 100644 index 0000000..d5d8033 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_multiple_modules_err.vv @@ -0,0 +1,4 @@ +import time math +fn main() { + println(time.now().unix_time()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.out b/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.out new file mode 100644 index 0000000..a41edfc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_not_found_err.vv:1:1: builder error: cannot import module "notexist" (not found) + 1 | import notexist + | ~~~~~~~~~~~~~~~ + 2 | fn main() { + 3 | println(notexist.name) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.vv new file mode 100644 index 0000000..5e89bde --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_not_found_err.vv @@ -0,0 +1,4 @@ +import notexist +fn main() { + println(notexist.name) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.out b/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.out new file mode 100644 index 0000000..14a935e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/import_not_same_line_err.vv:2:2: error: `import` statements must be a single line + 1 | import + 2 | time + | ~~~~ + 3 | fn main() { + 4 | println(time.now()) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.vv new file mode 100644 index 0000000..ad6401e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_not_same_line_err.vv @@ -0,0 +1,5 @@ +import + time +fn main() { + println(time.now()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.out new file mode 100644 index 0000000..0592fed --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/import_symbol_empty.vv:1:12: error: empty `os` import set, remove `{}` + 1 | import os {} + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.vv new file mode 100644 index 0000000..252aceb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_empty.vv @@ -0,0 +1 @@ +import os {} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.out new file mode 100644 index 0000000..5d74a05 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.out @@ -0,0 +1,11 @@ +vlib/v/checker/tests/import_symbol_fn_err.vv:1:17: error: module `crypto` has no constant or function `userper` + 1 | import crypto { userper } + | ~~~~~~~ + 2 | fn main() { + 3 | usurper() +vlib/v/checker/tests/import_symbol_fn_err.vv:3:3: error: unknown function: usurper + 1 | import crypto { userper } + 2 | fn main() { + 3 | usurper() + | ~~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.vv new file mode 100644 index 0000000..04ba99b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_fn_err.vv @@ -0,0 +1,4 @@ +import crypto { userper } +fn main() { + usurper() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.out new file mode 100644 index 0000000..2193b15 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/import_symbol_invalid.vv:1:17: error: import syntax error, please specify a valid fn or type name + 1 | import crypto { *_v } + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.vv new file mode 100644 index 0000000..485c151 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_invalid.vv @@ -0,0 +1 @@ +import crypto { *_v } diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.out new file mode 100644 index 0000000..2d3d1e2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.out @@ -0,0 +1,48 @@ +vlib/v/checker/tests/import_symbol_private_err.vv:3:20: error: module `time` function `since()` is private + 1 | import v.scanner + 2 | import v.parser + 3 | import time { now, since } + | ~~~~~ + 4 | import io { ReaderWriterImpl } + 5 | +vlib/v/checker/tests/import_symbol_private_err.vv:4:13: error: module `io` type `ReaderWriterImpl` is private + 2 | import v.parser + 3 | import time { now, since } + 4 | import io { ReaderWriterImpl } + | ~~~~~~~~~~~~~~~~ + 5 | + 6 | fn main() { +vlib/v/checker/tests/import_symbol_private_err.vv:7:18: error: constant `v.scanner.single_quote` is private + 5 | + 6 | fn main() { + 7 | println(scanner.single_quote) + | ~~~~~~~~~~~~ + 8 | println(parser.State.html) + 9 | since(now()) +vlib/v/checker/tests/import_symbol_private_err.vv:8:17: error: enum `v.parser.State` is private + 6 | fn main() { + 7 | println(scanner.single_quote) + 8 | println(parser.State.html) + | ~~~~~~~~~~ + 9 | since(now()) + 10 | _ = map{'h': 2}.exists('h') +vlib/v/checker/tests/import_symbol_private_err.vv:9:2: error: function `time.since` is private + 7 | println(scanner.single_quote) + 8 | println(parser.State.html) + 9 | since(now()) + | ~~~~~~~~~~~~ + 10 | _ = map{'h': 2}.exists('h') + 11 | _ = ReaderWriterImpl{} +vlib/v/checker/tests/import_symbol_private_err.vv:10:18: error: method `map[string]int.exists` is private + 8 | println(parser.State.html) + 9 | since(now()) + 10 | _ = map{'h': 2}.exists('h') + | ~~~~~~~~~~~ + 11 | _ = ReaderWriterImpl{} + 12 | } +vlib/v/checker/tests/import_symbol_private_err.vv:11:6: error: type `io.ReaderWriterImpl` is private + 9 | since(now()) + 10 | _ = map{'h': 2}.exists('h') + 11 | _ = ReaderWriterImpl{} + | ~~~~~~~~~~~~~~~~~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.vv new file mode 100644 index 0000000..0957e86 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_private_err.vv @@ -0,0 +1,12 @@ +import v.scanner +import v.parser +import time { now, since } +import io { ReaderWriterImpl } + +fn main() { + println(scanner.single_quote) + println(parser.State.html) + since(now()) + _ = map{'h': 2}.exists('h') + _ = ReaderWriterImpl{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.out new file mode 100644 index 0000000..2c1cd9b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/import_symbol_type_err.vv:1:17: error: module `crypto` has no type `Coin` + 1 | import crypto { Coin } + | ~~~~ + 2 | fn main() { + 3 | println(Coin{}) +vlib/v/checker/tests/import_symbol_type_err.vv:3:11: error: unknown type `crypto.Coin`. +Did you mean `crypto.Hash`? + 1 | import crypto { Coin } + 2 | fn main() { + 3 | println(Coin{}) + | ~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.vv new file mode 100644 index 0000000..7eccd97 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_type_err.vv @@ -0,0 +1,4 @@ +import crypto { Coin } +fn main() { + println(Coin{}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.out b/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.out new file mode 100644 index 0000000..2ab6a66 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/import_symbol_unclosed.vv:1:28: error: import syntax error, no closing `}` + 1 | import crypto.sha256 { sum ] + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.vv b/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.vv new file mode 100644 index 0000000..799a636 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_symbol_unclosed.vv @@ -0,0 +1 @@ +import crypto.sha256 { sum ] diff --git a/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.out b/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.out new file mode 100644 index 0000000..06b3499 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_syntax_err.vv:1:12: error: cannot import multiple modules at a time + 1 | import time, os + | ^ + 2 | fn main() { + 3 | println(time.now()) diff --git a/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.vv b/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.vv new file mode 100644 index 0000000..2649ca6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_syntax_err.vv @@ -0,0 +1,4 @@ +import time, os +fn main() { + println(time.now()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.out b/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.out new file mode 100644 index 0000000..38df8cd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/import_unused_warning.vv:1:8: warning: module 'time' is imported but never used + 1 | import time + | ~~~~ + 2 | fn main() { + 3 | println('hello, world') diff --git a/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.vv b/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.vv new file mode 100644 index 0000000..1fb573f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/import_unused_warning.vv @@ -0,0 +1,4 @@ +import time +fn main() { + println('hello, world') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.out b/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.out new file mode 100644 index 0000000..d6e9e12 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.out @@ -0,0 +1,77 @@ +vlib/v/checker/tests/in_mismatch_type.vv:10:5: error: left operand to `in` does not match the array element type: expected `string`, not `int literal` + 8 | } + 9 | s := 'abcd' + 10 | if 1 in a_s { + | ~~~~~~~~ + 11 | println('ok') + 12 | } +vlib/v/checker/tests/in_mismatch_type.vv:13:5: error: left operand to `in` does not match the map key type: expected `string`, not `int literal` + 11 | println('ok') + 12 | } + 13 | if 2 in m { + | ~~~~~~ + 14 | println('yeah') + 15 | } +vlib/v/checker/tests/in_mismatch_type.vv:16:5: error: use `str.contains(substr)` instead of `substr in str` + 14 | println('yeah') + 15 | } + 16 | if 3 in s { + | ~~~~~~ + 17 | println('dope') + 18 | } +vlib/v/checker/tests/in_mismatch_type.vv:19:5: error: use `str.contains(substr)` instead of `substr in str` + 17 | println('dope') + 18 | } + 19 | if `a` in s { + | ~~~~~~~~ + 20 | println("oh no :'(") + 21 | } +vlib/v/checker/tests/in_mismatch_type.vv:22:7: error: `in` can only be used with an array/map/string + 20 | println("oh no :'(") + 21 | } + 22 | if 1 in 12 { + | ~~ + 23 | println('right') + 24 | } +vlib/v/checker/tests/in_mismatch_type.vv:25:5: error: left operand to `in` does not match the map key type: expected `string`, not `Int` + 23 | println('right') + 24 | } + 25 | if Int(2) in m { + | ~~~~~~~~~~~ + 26 | println('yeah') + 27 | } +vlib/v/checker/tests/in_mismatch_type.vv:28:5: error: left operand to `in` does not match the array element type: expected `int`, not `string` + 26 | println('yeah') + 27 | } + 28 | if '3' in a_i { + | ~~~~~~~~~~ + 29 | println('sure') + 30 | } +vlib/v/checker/tests/in_mismatch_type.vv:31:5: error: left operand to `in` does not match the array element type: expected `int`, not `string` + 29 | println('sure') + 30 | } + 31 | if '2' in a_i { + | ~~~~~~~~~~ + 32 | println('all right') + 33 | } +vlib/v/checker/tests/in_mismatch_type.vv:34:5: error: left operand to `!in` does not match the array element type: expected `string`, not `int literal` + 32 | println('all right') + 33 | } + 34 | if 1 !in a_s { + | ~~~~~~~~~ + 35 | println('ok') + 36 | } +vlib/v/checker/tests/in_mismatch_type.vv:37:5: error: left operand to `!in` does not match the array element type: expected `int`, not `string` + 35 | println('ok') + 36 | } + 37 | if '1' !in a_i { + | ~~~~~~~~~~~ + 38 | println('good') + 39 | } +vlib/v/checker/tests/in_mismatch_type.vv:41:5: error: left operand to `!in` does not match the map key type: expected `string`, not `int literal` + 39 | } + 40 | + 41 | if 5 !in m { + | ~~~~~~~ + 42 | println('yay') + 43 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.vv b/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.vv new file mode 100644 index 0000000..4a5dc69 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/in_mismatch_type.vv @@ -0,0 +1,44 @@ +type Int = int + +fn main() { + a_i := [1, 2, 3] + a_s := ['1', '2', '3'] + m := map{ + 'test': 1 + } + s := 'abcd' + if 1 in a_s { + println('ok') + } + if 2 in m { + println('yeah') + } + if 3 in s { + println('dope') + } + if `a` in s { + println("oh no :'(") + } + if 1 in 12 { + println('right') + } + if Int(2) in m { + println('yeah') + } + if '3' in a_i { + println('sure') + } + if '2' in a_i { + println('all right') + } + if 1 !in a_s { + println('ok') + } + if '1' !in a_i { + println('good') + } + + if 5 !in m { + println('yay') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.out new file mode 100644 index 0000000..610ef46 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.out @@ -0,0 +1,8 @@ +vlib/v/checker/tests/incorrect_for_in_name_variable.vv:3:6: error: variable name `_aa` cannot start with `_` + 1 | fn main() { + 2 | a := [1,2,3] + 3 | for _aa in a { + | ~~~ + 4 | println(_aa) + 5 | } +
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.vv new file mode 100644 index 0000000..888fd60 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_for_in_name_variable.vv @@ -0,0 +1,6 @@ +fn main() { + a := [1,2,3] + for _aa in a { + println(_aa) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.out new file mode 100644 index 0000000..820e8d5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_alias_type.vv:1:1: error: type alias `integer` must begin with capital letter + 1 | type integer = int + | ~~~~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.vv new file mode 100644 index 0000000..7e2d363 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_alias_type.vv @@ -0,0 +1 @@ +type integer = int diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.out diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.vv new file mode 100644 index 0000000..50f553f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_const.vv @@ -0,0 +1,3 @@ +const ( + _my_const = 0 +) diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.out new file mode 100644 index 0000000..27a4392 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/incorrect_name_enum.vv:1:1: error: enum name `color` must begin with capital letter + 1 | enum color { + | ~~~~~~~~~~ + 2 | green + 3 | yellow
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.vv new file mode 100644 index 0000000..90c4d4d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum.vv @@ -0,0 +1,4 @@ +enum color { + green + yellow +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.out new file mode 100644 index 0000000..04f2748 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/incorrect_name_enum_field.vv:2:5: error: field name `Green` cannot contain uppercase letters, use snake_case instead + 1 | enum Color { + 2 | Green + | ~~~~~ + 3 | red + 4 | blue
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.vv new file mode 100644 index 0000000..8cb0031 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_enum_field.vv @@ -0,0 +1,5 @@ +enum Color { + Green + red + blue +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.out new file mode 100644 index 0000000..4ded743 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_fn_type.vv:1:1: error: fn type `callback` must begin with capital letter + 1 | type callback = fn () + | ~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.vv new file mode 100644 index 0000000..f565315 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_fn_type.vv @@ -0,0 +1 @@ +type callback = fn () diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.out new file mode 100644 index 0000000..0826b36 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_function.vv:1:1: error: function name `_my_fn` cannot start with `_` + 1 | fn _my_fn() {} + | ~~~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.vv new file mode 100644 index 0000000..b75a1a2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_function.vv @@ -0,0 +1 @@ +fn _my_fn() {} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.out new file mode 100644 index 0000000..95a49b9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_interface.vv:1:1: error: interface name `_MyInterface` must begin with capital letter + 1 | interface _MyInterface {} + | ~~~~~~~~~~~~~~~~~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.vv new file mode 100644 index 0000000..abe6cb8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface.vv @@ -0,0 +1 @@ +interface _MyInterface {} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.out new file mode 100644 index 0000000..daeda3e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/incorrect_name_interface_method.vv:2:5: error: method name `_speak` cannot start with `_` + 1 | interface MyInterface { + 2 | _speak() + | ~~~~~~~~ + 3 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.vv new file mode 100644 index 0000000..2ab12be --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_interface_method.vv @@ -0,0 +1,3 @@ +interface MyInterface { + _speak() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.out new file mode 100644 index 0000000..4edc08e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_module.vv:1:1: error: module name `_A` cannot start with `_` + 1 | module _A + | ~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.vv new file mode 100644 index 0000000..50526ca --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_module.vv @@ -0,0 +1 @@ +module _A diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.out new file mode 100644 index 0000000..03f1a93 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/incorrect_name_struct.vv:1:8: error: struct name `abc` must begin with capital letter + 1 | struct abc {} + | ~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.vv new file mode 100644 index 0000000..0c77ebc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct.vv @@ -0,0 +1 @@ +struct abc {} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.out new file mode 100644 index 0000000..22fddfc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/incorrect_name_struct_field.vv:2:5: error: field name `_a` cannot start with `_` + 1 | struct Abc { + 2 | _a int + | ~~~~~~ + 3 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.vv new file mode 100644 index 0000000..b1b2205 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_struct_field.vv @@ -0,0 +1,3 @@ +struct Abc { + _a int +} diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.out new file mode 100644 index 0000000..91a0412 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/incorrect_name_sum_type.vv:1:1: error: sum type `integer` must begin with capital letter + 1 | type integer = i8 | i16 | int | i64 + | ~~~~~~~~~~~~ + 2 | type Integer = i8 | i16 | int | i64 + 3 | +vlib/v/checker/tests/incorrect_name_sum_type.vv:4:1: error: method overrides built-in sum type method + 2 | type Integer = i8 | i16 | int | i64 + 3 | + 4 | fn (i Integer) type_name() { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ + 5 | } + 6 | diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.vv new file mode 100644 index 0000000..e73300d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_sum_type.vv @@ -0,0 +1,6 @@ +type integer = i8 | i16 | int | i64 +type Integer = i8 | i16 | int | i64 + +fn (i Integer) type_name() { +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.out b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.out new file mode 100644 index 0000000..7a3de82 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/incorrect_name_variable.vv:2:2: error: variable name `_abc` cannot start with `_` + 1 | fn main() { + 2 | _abc := 1 + | ~~~~ + 3 | _ = _abc + 4 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.vv b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.vv new file mode 100644 index 0000000..d4d4295 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/incorrect_name_variable.vv @@ -0,0 +1,4 @@ +fn main() { + _abc := 1 + _ = _abc +} diff --git a/v_windows/v/old/vlib/v/checker/tests/index_expr.out b/v_windows/v/old/vlib/v/checker/tests/index_expr.out new file mode 100644 index 0000000..90aa0a2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/index_expr.out @@ -0,0 +1,69 @@ +vlib/v/checker/tests/index_expr.vv:3:7: error: type `int` does not support indexing + 1 | fn test_invalid_index() { + 2 | v := 4 + 3 | _ = v[0] + | ~~~ + 4 | + 5 | a := [2] +vlib/v/checker/tests/index_expr.vv:6:7: error: non-integer index `[]int` (array type `[]int`) + 4 | + 5 | a := [2] + 6 | _ = a[a] + | ~~~ + 7 | _ = a[-1] + 8 | } +vlib/v/checker/tests/index_expr.vv:7:8: error: negative index `-1` + 5 | a := [2] + 6 | _ = a[a] + 7 | _ = a[-1] + | ~~ + 8 | } + 9 | +vlib/v/checker/tests/index_expr.vv:12:7: error: type `int` does not support indexing + 10 | fn test_invalid_slice() { + 11 | v := 4 + 12 | _ = v[1..] + | ~~~~~ + 13 | _ = v[..1] + 14 | +vlib/v/checker/tests/index_expr.vv:13:7: error: type `int` does not support indexing + 11 | v := 4 + 12 | _ = v[1..] + 13 | _ = v[..1] + | ~~~~~ + 14 | + 15 | a := [2] +vlib/v/checker/tests/index_expr.vv:16:7: error: non-integer index `[]int` (array type `[]int`) + 14 | + 15 | a := [2] + 16 | _ = a[a..] + | ~~~~~ + 17 | _ = a[..a] + 18 | _ = a[-1..] +vlib/v/checker/tests/index_expr.vv:17:7: error: non-integer index `[]int` (array type `[]int`) + 15 | a := [2] + 16 | _ = a[a..] + 17 | _ = a[..a] + | ~~~~~ + 18 | _ = a[-1..] + 19 | _ = a[..-1] +vlib/v/checker/tests/index_expr.vv:18:8: error: negative index `-1` + 16 | _ = a[a..] + 17 | _ = a[..a] + 18 | _ = a[-1..] + | ~~ + 19 | _ = a[..-1] + 20 | _ = a[-1..-2] +vlib/v/checker/tests/index_expr.vv:19:10: error: negative index `-1` + 17 | _ = a[..a] + 18 | _ = a[-1..] + 19 | _ = a[..-1] + | ~~ + 20 | _ = a[-1..-2] + 21 | } +vlib/v/checker/tests/index_expr.vv:20:8: error: negative index `-1` + 18 | _ = a[-1..] + 19 | _ = a[..-1] + 20 | _ = a[-1..-2] + | ~~ + 21 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/index_expr.vv b/v_windows/v/old/vlib/v/checker/tests/index_expr.vv new file mode 100644 index 0000000..072661d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/index_expr.vv @@ -0,0 +1,21 @@ +fn test_invalid_index() { + v := 4 + _ = v[0] + + a := [2] + _ = a[a] + _ = a[-1] +} + +fn test_invalid_slice() { + v := 4 + _ = v[1..] + _ = v[..1] + + a := [2] + _ = a[a..] + _ = a[..a] + _ = a[-1..] + _ = a[..-1] + _ = a[-1..-2] +} diff --git a/v_windows/v/old/vlib/v/checker/tests/infix_err.out b/v_windows/v/old/vlib/v/checker/tests/infix_err.out new file mode 100644 index 0000000..3637169 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/infix_err.out @@ -0,0 +1,81 @@ +vlib/v/checker/tests/infix_err.vv:7:5: error: mismatched types `string` and `?string` + 5 | return none + 6 | } + 7 | _ = '' + f() + | ~~~~~~~~ + 8 | _ = f() + '' + 9 | _ = f() + f() +vlib/v/checker/tests/infix_err.vv:8:5: error: mismatched types `?string` and `string` + 6 | } + 7 | _ = '' + f() + 8 | _ = f() + '' + | ~~~~~~~~ + 9 | _ = f() + f() + 10 | +vlib/v/checker/tests/infix_err.vv:9:9: error: `+` cannot be used with `?string` + 7 | _ = '' + f() + 8 | _ = f() + '' + 9 | _ = f() + f() + | ^ + 10 | + 11 | _ = 4 + g() +vlib/v/checker/tests/infix_err.vv:11:7: error: `+` cannot be used with `?int` + 9 | _ = f() + f() + 10 | + 11 | _ = 4 + g() + | ^ + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) +vlib/v/checker/tests/infix_err.vv:12:5: error: unwrapped optional cannot be used in an infix expression + 10 | + 11 | _ = 4 + g() + 12 | _ = int(0) + g() // FIXME not detected + | ~~~~~~~~~~~~ + 13 | _ = g() + int(3) + 14 | _ = g() + 3 +vlib/v/checker/tests/infix_err.vv:13:9: error: `+` cannot be used with `?int` + 11 | _ = 4 + g() + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) + | ^ + 14 | _ = g() + 3 + 15 | +vlib/v/checker/tests/infix_err.vv:14:9: error: `+` cannot be used with `?int` + 12 | _ = int(0) + g() // FIXME not detected + 13 | _ = g() + int(3) + 14 | _ = g() + 3 + | ^ + 15 | + 16 | // binary operands +vlib/v/checker/tests/infix_err.vv:17:5: error: left operand for `&&` is not a boolean + 15 | + 16 | // binary operands + 17 | _ = 1 && 2 + | ^ + 18 | _ = true || 2 + 19 | +vlib/v/checker/tests/infix_err.vv:18:13: error: right operand for `||` is not a boolean + 16 | // binary operands + 17 | _ = 1 && 2 + 18 | _ = true || 2 + | ^ + 19 | + 20 | // boolean expressions +vlib/v/checker/tests/infix_err.vv:21:22: error: ambiguous boolean expression. use `()` to ensure correct order of operations + 19 | + 20 | // boolean expressions + 21 | _ = 1 == 1 && 2 == 2 || 3 == 3 + | ~~ + 22 | _ = 1 == 1 + 23 | && 2 == 2 || 3 == 3 +vlib/v/checker/tests/infix_err.vv:23:12: error: ambiguous boolean expression. use `()` to ensure correct order of operations + 21 | _ = 1 == 1 && 2 == 2 || 3 == 3 + 22 | _ = 1 == 1 + 23 | && 2 == 2 || 3 == 3 + | ~~ + 24 | && 4 == 4 +vlib/v/checker/tests/infix_err.vv:24:2: error: ambiguous boolean expression. use `()` to ensure correct order of operations + 22 | _ = 1 == 1 + 23 | && 2 == 2 || 3 == 3 + 24 | && 4 == 4 + | ~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/infix_err.vv b/v_windows/v/old/vlib/v/checker/tests/infix_err.vv new file mode 100644 index 0000000..13381b4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/infix_err.vv @@ -0,0 +1,24 @@ +fn f() ?string { + return none +} +fn g() ?int { + return none +} +_ = '' + f() +_ = f() + '' +_ = f() + f() + +_ = 4 + g() +_ = int(0) + g() // FIXME not detected +_ = g() + int(3) +_ = g() + 3 + +// binary operands +_ = 1 && 2 +_ = true || 2 + +// boolean expressions +_ = 1 == 1 && 2 == 2 || 3 == 3 +_ = 1 == 1 + && 2 == 2 || 3 == 3 + && 4 == 4 diff --git a/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.out b/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.out new file mode 100644 index 0000000..c9d0e2d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/int_modulo_by_zero_err.vv:2:17: error: modulo by zero + 1 | fn main() { + 2 | println(3 % 0) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.vv b/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.vv new file mode 100644 index 0000000..8945861 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/int_modulo_by_zero_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(3 % 0) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.out b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.out new file mode 100644 index 0000000..b2476ce --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/interface_implementing_interface.vv:15:10: error: cannot implement interface `Thing` with a different interface `Animal` + 13 | dog := Dog{} + 14 | animal := Animal(dog) + 15 | thing := Thing(animal) + | ~~~~~~~~~~~~~ + 16 | println(thing)
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.vv b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.vv new file mode 100644 index 0000000..a71e9ea --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_interface.vv @@ -0,0 +1,16 @@ +interface Thing { + kind string +} + +interface Animal { + kind string +} + +struct Dog { + kind string = 'labrador' +} + +dog := Dog{} +animal := Animal(dog) +thing := Thing(animal) +println(thing) diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.out b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.out new file mode 100644 index 0000000..afa4876 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/interface_implementing_own_interface_method.vv:5:1: error: interface `Animal` cannot implement its own interface method `speak` + 3 | } + 4 | + 5 | fn (a Animal) speak() { + | ~~~~~~~~~~~~~~~~~~~~~ + 6 | println('speaking') + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.vv b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.vv new file mode 100644 index 0000000..9881bd7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_implementing_own_interface_method.vv @@ -0,0 +1,7 @@ +interface Animal { + speak() +} + +fn (a Animal) speak() { + println('speaking') +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_init_err.out b/v_windows/v/old/vlib/v/checker/tests/interface_init_err.out new file mode 100644 index 0000000..238395c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_init_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/interface_init_err.vv:15:7: error: interface field `Server.handler` must be initialized + 13 | + 14 | fn main() { + 15 | _ := Server{} + | ~~~~~~~~ + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_init_err.vv b/v_windows/v/old/vlib/v/checker/tests/interface_init_err.vv new file mode 100644 index 0000000..e2def73 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_init_err.vv @@ -0,0 +1,16 @@ +interface Handler { + foo string + handle(int) int +} + +struct Server { + handler Handler +} + +fn (s Server) handle(x int) int { + return x +} + +fn main() { + _ := Server{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.out b/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.out new file mode 100644 index 0000000..ac3f23d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/interface_return_parameter_err.vv:2:17: error: unknown type `Baz`. +Did you mean `Foo`? + 1 | interface Foo { + 2 | bar(string) []Baz + | ~~~~~ + 3 | bar2(Bax) string + 4 | } +vlib/v/checker/tests/interface_return_parameter_err.vv:3:10: error: unknown type `Bax`. +Did you mean `Foo`? + 1 | interface Foo { + 2 | bar(string) []Baz + 3 | bar2(Bax) string + | ~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.vv b/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.vv new file mode 100644 index 0000000..e6168cf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_return_parameter_err.vv @@ -0,0 +1,4 @@ +interface Foo { + bar(string) []Baz + bar2(Bax) string +} diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.out b/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.out new file mode 100644 index 0000000..669fb01 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/interface_too_many_embedding_levels.vv:9:1: error: too many interface embedding levels: 101, for interface `I103` + 7 | } + 8 | + 9 | interface I103 { + | ~~~~~~~~~~~~~~~~ + 10 | I102 + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.vv b/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.vv new file mode 100644 index 0000000..6975ef0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interface_too_many_embedding_levels.vv @@ -0,0 +1,431 @@ +interface I1 { + I0 +} + +interface I2 { + I1 +} + +interface I103 { + I102 +} + +interface I102 { + I101 +} + +interface I101 { + I100 +} + +interface I3 { + I2 +} + +interface I4 { + I3 +} + +interface I5 { + I4 +} + +interface I6 { + I5 +} + +interface I7 { + I6 +} + +interface I8 { + I7 +} + +interface I9 { + I8 +} + +interface I10 { + I9 +} + +interface I11 { + I10 +} + +interface I12 { + I11 +} + +interface I13 { + I12 +} + +interface I14 { + I13 +} + +interface I15 { + I14 +} + +interface I16 { + I15 +} + +interface I17 { + I16 +} + +interface I18 { + I17 +} + +interface I19 { + I18 +} + +interface I20 { + I19 +} + +interface I21 { + I20 +} + +interface I22 { + I21 +} + +interface I23 { + I22 +} + +interface I24 { + I23 +} + +interface I25 { + I24 +} + +interface I26 { + I25 +} + +interface I27 { + I26 +} + +interface I28 { + I27 +} + +interface I29 { + I28 +} + +interface I30 { + I29 +} + +interface I31 { + I30 +} + +interface I32 { + I31 +} + +interface I33 { + I32 +} + +interface I34 { + I33 +} + +interface I35 { + I34 +} + +interface I36 { + I35 +} + +interface I37 { + I36 +} + +interface I38 { + I37 +} + +interface I39 { + I38 +} + +interface I40 { + I39 +} + +interface I41 { + I40 +} + +interface I42 { + I41 +} + +interface I43 { + I42 +} + +interface I44 { + I43 +} + +interface I45 { + I44 +} + +interface I46 { + I45 +} + +interface I47 { + I46 +} + +interface I48 { + I47 +} + +interface I49 { + I48 +} + +interface I50 { + I49 +} + +interface I51 { + I50 +} + +interface I52 { + I51 +} + +interface I53 { + I52 +} + +interface I54 { + I53 +} + +interface I55 { + I54 +} + +interface I56 { + I55 +} + +interface I57 { + I56 +} + +interface I58 { + I57 +} + +interface I59 { + I58 +} + +interface I60 { + I59 +} + +interface I61 { + I60 +} + +interface I62 { + I61 +} + +interface I63 { + I62 +} + +interface I64 { + I63 +} + +interface I65 { + I64 +} + +interface I66 { + I65 +} + +interface I67 { + I66 +} + +interface I68 { + I67 +} + +interface I69 { + I68 +} + +interface I70 { + I69 +} + +interface I71 { + I70 +} + +interface I72 { + I71 +} + +interface I73 { + I72 +} + +interface I74 { + I73 +} + +interface I75 { + I74 +} + +interface I76 { + I75 +} + +interface I77 { + I76 +} + +interface I78 { + I77 +} + +interface I79 { + I78 +} + +interface I80 { + I79 +} + +interface I81 { + I80 +} + +interface I82 { + I81 +} + +interface I83 { + I82 +} + +interface I84 { + I83 +} + +interface I85 { + I84 +} + +interface I86 { + I85 +} + +interface I87 { + I86 +} + +interface I88 { + I87 +} + +interface I89 { + I88 +} + +interface I90 { + I89 +} + +interface I91 { + I90 +} + +interface I92 { + I91 +} + +interface I93 { + I92 +} + +interface I94 { + I93 +} + +interface I95 { + I94 +} + +interface I96 { + I95 +} + +interface I97 { + I96 +} + +interface I98 { + I97 +} + +interface I99 { + I98 +} + +interface I100 { + I99 +} + +interface I0 { + m999() int +} + +struct Abc { + x int = 123 +} + +fn (s Abc) m999() int { + return 999 +} + +fn main() { + a := Abc{} + dump(a) + i := I103(a) + dump(i) + assert i.m999() == 999 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.out b/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.out new file mode 100644 index 0000000..c47f72f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/interpolation_recursive_str_err.vv:8:8: error: cannot call `str()` method recursively + 6 | + 7 | fn (t Test) str() string { + 8 | _ = '$t' + | ^ + 9 | return 'test' + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.vv b/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.vv new file mode 100644 index 0000000..4f3f3d8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/interpolation_recursive_str_err.vv @@ -0,0 +1,15 @@ +module main + +struct Test { + a int +} + +fn (t Test) str() string { + _ = '$t' + return 'test' +} + +fn main() { + a := Test{} + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.out b/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.out new file mode 100644 index 0000000..e4a2b5c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/invalid_char_err.vv:1:1: error: invalid character `🐈` + 1 | 🐈println('') + | ^
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.vv b/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.vv new file mode 100644 index 0000000..0a27589 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_char_err.vv @@ -0,0 +1 @@ +🐈println('') diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_property.out b/v_windows/v/old/vlib/v/checker/tests/invalid_property.out new file mode 100644 index 0000000..e7839a4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_property.out @@ -0,0 +1,18 @@ +vlib/v/checker/tests/invalid_property.vv:2:7: error: `string` has no property `length` + 1 | s :='' + 2 | _ = s.length + | ~~~~~~ + 3 | _ = [1,2].foo + 4 | +vlib/v/checker/tests/invalid_property.vv:3:11: error: `[]int` has no property `foo` + 1 | s :='' + 2 | _ = s.length + 3 | _ = [1,2].foo + | ~~~ + 4 | + 5 | mut fa := [3,4]! +vlib/v/checker/tests/invalid_property.vv:6:8: error: `[2]int` has no property `bar` + 4 | + 5 | mut fa := [3,4]! + 6 | _ = fa.bar + | ~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_property.vv b/v_windows/v/old/vlib/v/checker/tests/invalid_property.vv new file mode 100644 index 0000000..427c2e7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_property.vv @@ -0,0 +1,6 @@ +s :='' +_ = s.length +_ = [1,2].foo + +mut fa := [3,4]! +_ = fa.bar diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.out b/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.out new file mode 100644 index 0000000..7333400 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/invalid_vweb_param_type.vv:8:24: error: invalid type `[]bool` for parameter `list` in vweb app method `index` + 6 | + 7 | ['/:list'; get] + 8 | fn (mut app App) index(list []bool) vweb.Result { + | ~~~~ + 9 | return app.text('') + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.vv b/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.vv new file mode 100644 index 0000000..6274830 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invalid_vweb_param_type.vv @@ -0,0 +1,12 @@ +import vweb + +struct App { + vweb.Context +} + +['/:list'; get] +fn (mut app App) index(list []bool) vweb.Result { + return app.text('') +} + +vweb.run(&App{}, 5000) diff --git a/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.out b/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.out new file mode 100644 index 0000000..ad8c86f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.out @@ -0,0 +1,26 @@ +vlib/v/checker/tests/invert_other_types_bits_error.vv:2:13: error: operator ~ only defined on int types + 1 | fn main() { + 2 | println(~3.0) + | ^ + 3 | println(~10.5) + 4 | println(~'2') +vlib/v/checker/tests/invert_other_types_bits_error.vv:3:13: error: operator ~ only defined on int types + 1 | fn main() { + 2 | println(~3.0) + 3 | println(~10.5) + | ^ + 4 | println(~'2') + 5 | println(~[2, 4, 6]) +vlib/v/checker/tests/invert_other_types_bits_error.vv:4:13: error: operator ~ only defined on int types + 2 | println(~3.0) + 3 | println(~10.5) + 4 | println(~'2') + | ^ + 5 | println(~[2, 4, 6]) + 6 | } +vlib/v/checker/tests/invert_other_types_bits_error.vv:5:13: error: operator ~ only defined on int types + 3 | println(~10.5) + 4 | println(~'2') + 5 | println(~[2, 4, 6]) + | ^ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.vv b/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.vv new file mode 100644 index 0000000..ad74f64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/invert_other_types_bits_error.vv @@ -0,0 +1,6 @@ +fn main() { + println(~3.0) + println(~10.5) + println(~'2') + println(~[2, 4, 6]) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.out b/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.out new file mode 100644 index 0000000..0459e96 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/is_type_invalid.vv:14:12: error: `IoS` has no variant `byte` + 12 | + 13 | fn main() { + 14 | if IoS(1) is byte { + | ~~ + 15 | println('not cool') + 16 | } +vlib/v/checker/tests/is_type_invalid.vv:18:7: error: `Cat` doesn't implement method `speak` of interface `Animal` + 16 | } + 17 | a := Animal(Dog{}) + 18 | if a is Cat { + | ~~ + 19 | println('not cool either') + 20 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.vv b/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.vv new file mode 100644 index 0000000..2e7f774 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/is_type_invalid.vv @@ -0,0 +1,21 @@ +type IoS = int | string + +interface Animal { + speak() +} + +struct Dog {} + +fn (d Dog) speak() {} + +struct Cat {} + +fn main() { + if IoS(1) is byte { + println('not cool') + } + a := Animal(Dog{}) + if a is Cat { + println('not cool either') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.out b/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.out new file mode 100644 index 0000000..1c52d7a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/is_type_not_exist.vv:8:10: error: is: type `SomethingThatDontExist` does not exist + 6 | + 7 | fn fn_with_sum_type_param(i Integer) { + 8 | if i is SomethingThatDontExist { + | ~~~~~~~~~~~~~~~~~~~~~~ + 9 | println('It should fail !') + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.vv b/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.vv new file mode 100644 index 0000000..e50859b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/is_type_not_exist.vv @@ -0,0 +1,11 @@ +type Integer = i8 | i16 | int | i64 + +fn main() { + fn_with_sum_type_param(1) +} + +fn fn_with_sum_type_param(i Integer) { + if i is SomethingThatDontExist { + println('It should fail !') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.out b/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.out new file mode 100644 index 0000000..caadcfc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.out @@ -0,0 +1,35 @@ +vlib/v/checker/tests/labelled_break_continue.vv:7:14: error: invalid label name `L2` + 5 | i++ + 6 | for { + 7 | if i < 7 {continue L2} + | ~~~~~~~~ + 8 | else {break L2} + 9 | } +vlib/v/checker/tests/labelled_break_continue.vv:8:10: error: invalid label name `L2` + 6 | for { + 7 | if i < 7 {continue L2} + 8 | else {break L2} + | ~~~~~ + 9 | } + 10 | } +vlib/v/checker/tests/labelled_break_continue.vv:15:14: error: invalid label name `L1` + 13 | i = e + 14 | for { + 15 | if i < 3 {continue L1} + | ~~~~~~~~ + 16 | else {break L1} + 17 | } +vlib/v/checker/tests/labelled_break_continue.vv:16:10: error: invalid label name `L1` + 14 | for { + 15 | if i < 3 {continue L1} + 16 | else {break L1} + | ~~~~~ + 17 | } + 18 | } +vlib/v/checker/tests/labelled_break_continue.vv:21:11: error: nesting of labelled `for` loops is not supported + 19 | // check nested loops (not supported ATM) + 20 | L3: for ;; i++ { + 21 | L4: for { + | ^ + 22 | if i < 17 {continue L3} + 23 | else {break L3} diff --git a/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.vv b/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.vv new file mode 100644 index 0000000..3447ab1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/labelled_break_continue.vv @@ -0,0 +1,26 @@ +fn main() { + mut i := 4 + // check branching to a later loop + L1: for { + i++ + for { + if i < 7 {continue L2} + else {break L2} + } + } + // check branching to an earlier loop + L2: for e in [1,2,3,4] { + i = e + for { + if i < 3 {continue L1} + else {break L1} + } + } + // check nested loops (not supported ATM) + L3: for ;; i++ { + L4: for { + if i < 17 {continue L3} + else {break L3} + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.out b/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.out new file mode 100644 index 0000000..29696aa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/lock_already_locked.vv:11:3: error: nested `lock`/`rlock` not allowed + 9 | } + 10 | lock a { + 11 | rlock a { + | ~~~~~ + 12 | a.x++ + 13 | } +vlib/v/checker/tests/lock_already_locked.vv:15:10: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 13 | } + 14 | } + 15 | println(a.x) + | ^ + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.vv b/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.vv new file mode 100644 index 0000000..7bb6365 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_already_locked.vv @@ -0,0 +1,16 @@ +struct St { +mut: + x int +} + +fn main() { + shared a := &St{ + x: 5 + } + lock a { + rlock a { + a.x++ + } + } + println(a.x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.out b/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.out new file mode 100644 index 0000000..b7e3fda --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/lock_already_rlocked.vv:11:3: error: nested `lock`/`rlock` not allowed + 9 | } + 10 | rlock a { + 11 | lock a { + | ~~~~ + 12 | a.x++ + 13 | } +vlib/v/checker/tests/lock_already_rlocked.vv:15:10: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 13 | } + 14 | } + 15 | println(a.x) + | ^ + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.vv b/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.vv new file mode 100644 index 0000000..c8e8236 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_already_rlocked.vv @@ -0,0 +1,16 @@ +struct St { +mut: + x int +} + +fn main() { + shared a := &St{ + x: 5 + } + rlock a { + lock a { + a.x++ + } + } + println(a.x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_const.out b/v_windows/v/old/vlib/v/checker/tests/lock_const.out new file mode 100644 index 0000000..2b923da --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_const.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/lock_const.vv:7:8: error: `a` must be declared as `shared` variable to be locked + 5 | fn main() { + 6 | mut c := 0 + 7 | rlock a { + | ^ + 8 | c = a + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_const.vv b/v_windows/v/old/vlib/v/checker/tests/lock_const.vv new file mode 100644 index 0000000..df16a6a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_const.vv @@ -0,0 +1,11 @@ +const ( + a = 5 +) + +fn main() { + mut c := 0 + rlock a { + c = a + } + println(c) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_needed.out b/v_windows/v/old/vlib/v/checker/tests/lock_needed.out new file mode 100644 index 0000000..637cbb9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_needed.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/lock_needed.vv:10:2: error: `abc` is `shared` and needs explicit lock for `v.ast.SelectorExpr` + 8 | x: 5 + 9 | } + 10 | abc.x++ + | ~~~ + 11 | println(abc.x) + 12 | } +vlib/v/checker/tests/lock_needed.vv:11:10: error: `abc` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 9 | } + 10 | abc.x++ + 11 | println(abc.x) + | ~~~ + 12 | } + 13 | +vlib/v/checker/tests/lock_needed.vv:25:12: error: `a.st` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 23 | } + 24 | } + 25 | println(a.st.x) + | ~~ + 26 | } + 27 | +vlib/v/checker/tests/lock_needed.vv:30:10: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 28 | fn g() { + 29 | shared a := []f64{len: 10, init: 7.5} + 30 | println(a[3]) + | ^ + 31 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_needed.vv b/v_windows/v/old/vlib/v/checker/tests/lock_needed.vv new file mode 100644 index 0000000..001aa7f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_needed.vv @@ -0,0 +1,31 @@ +struct St { +mut: + x int +} + +fn main() { + shared abc := &St{ + x: 5 + } + abc.x++ + println(abc.x) +} + +struct Abc { +mut: + st shared St +} + +fn f() { + mut a := Abc{ + st: St{ + x: 9 + } + } + println(a.st.x) +} + +fn g() { + shared a := []f64{len: 10, init: 7.5} + println(a[3]) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.out b/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.out new file mode 100644 index 0000000..00a05c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/lock_nonshared.vv:10:7: error: `a` must be declared as `shared` variable to be locked + 8 | x: 5 + 9 | } + 10 | lock a { + | ^ + 11 | a.x++ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.vv b/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.vv new file mode 100644 index 0000000..1524285 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/lock_nonshared.vv @@ -0,0 +1,14 @@ +struct St { +mut: + x int +} + +fn main() { + mut a := &St{ + x: 5 + } + lock a { + a.x++ + } + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.out b/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.out new file mode 100644 index 0000000..71b5f75 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/main_and_script_err.vv:1:1: error: function `main` is already defined + 1 | fn main() { + | ^ + 2 | println('main') + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.vv b/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.vv new file mode 100644 index 0000000..e746460 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_and_script_err.vv @@ -0,0 +1,4 @@ +fn main() { + println('main') +} +println('out') diff --git a/v_windows/v/old/vlib/v/checker/tests/main_args_err.out b/v_windows/v/old/vlib/v/checker/tests/main_args_err.out new file mode 100644 index 0000000..ee5f426 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_args_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/main_args_err.vv:1:1: error: function `main` cannot have arguments + 1 | fn main(a string) { + | ~~~~~~~~~~~~~~~~~ + 2 | println(a) + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/main_args_err.vv b/v_windows/v/old/vlib/v/checker/tests/main_args_err.vv new file mode 100644 index 0000000..69c9508 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_args_err.vv @@ -0,0 +1,3 @@ +fn main(a string) { + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/main_called_err.out b/v_windows/v/old/vlib/v/checker/tests/main_called_err.out new file mode 100644 index 0000000..1f1e253 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_called_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/main_called_err.vv:2:2: error: the `main` function cannot be called in the program + 1 | fn main() { + 2 | main() + | ~~~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/main_called_err.vv b/v_windows/v/old/vlib/v/checker/tests/main_called_err.vv new file mode 100644 index 0000000..2be2db1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_called_err.vv @@ -0,0 +1,3 @@ +fn main() { + main() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.out b/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.out new file mode 100644 index 0000000..09e4a9f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/main_no_body_err.vv:1:1: error: function `main` must declare a body + 1 | fn main() + | ~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.vv b/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.vv new file mode 100644 index 0000000..d955fb2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_no_body_err.vv @@ -0,0 +1 @@ +fn main() diff --git a/v_windows/v/old/vlib/v/checker/tests/main_return_err.out b/v_windows/v/old/vlib/v/checker/tests/main_return_err.out new file mode 100644 index 0000000..c9ce435 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_return_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/main_return_err.vv:1:1: error: function `main` cannot return values + 1 | fn main() f64 { + | ~~~~~~~~~~~~~ + 2 | return 1.23 + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/main_return_err.vv b/v_windows/v/old/vlib/v/checker/tests/main_return_err.vv new file mode 100644 index 0000000..de52fe0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/main_return_err.vv @@ -0,0 +1,3 @@ +fn main() f64 { + return 1.23 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_delete.out b/v_windows/v/old/vlib/v/checker/tests/map_delete.out new file mode 100644 index 0000000..c3a1822 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_delete.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/map_delete.vv:5:11: error: cannot use `int literal` as `string` in argument 1 to `Map.delete` + 3 | '1': 1 + 4 | } + 5 | m.delete(1) + | ^ + 6 | m.delete(1, 2) + 7 | m2 := map{ +vlib/v/checker/tests/map_delete.vv:6:4: error: expected 1 argument, but got 2 + 4 | } + 5 | m.delete(1) + 6 | m.delete(1, 2) + | ~~~~~~~~~~~~ + 7 | m2 := map{ + 8 | '1': 1 +vlib/v/checker/tests/map_delete.vv:10:2: error: `m2` is immutable, declare it with `mut` to make it mutable + 8 | '1': 1 + 9 | } + 10 | m2.delete('1') + | ~~ + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/map_delete.vv b/v_windows/v/old/vlib/v/checker/tests/map_delete.vv new file mode 100644 index 0000000..26b2606 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_delete.vv @@ -0,0 +1,11 @@ +fn main() { + mut m := map{ + '1': 1 + } + m.delete(1) + m.delete(1, 2) + m2 := map{ + '1': 1 + } + m2.delete('1') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.out b/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.out new file mode 100644 index 0000000..943e7b1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/map_func_void_return_err.vv:2:22: error: type mismatch, `voids` does not return anything + 1 | fn main() { + 2 | list := [1,2,3].map(voids(it)) + | ~~~~~~~~~ + 3 | } + 4 | diff --git a/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.vv b/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.vv new file mode 100644 index 0000000..bd5446e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_func_void_return_err.vv @@ -0,0 +1,7 @@ +fn main() { + list := [1,2,3].map(voids(it)) +} + +fn voids(arg int) { + println(arg) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.out b/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.out new file mode 100644 index 0000000..e18f40d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/map_init_invalid_syntax.vv:2:10: error: invalid empty map initilization syntax, use e.g. map[string]int{} instead + 1 | fn main() { + 2 | a := map{} + | ~~ + 3 | println(a) + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.vv b/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.vv new file mode 100644 index 0000000..a976d70 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_invalid_syntax.vv @@ -0,0 +1,4 @@ +fn main() { + a := map{} + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.out new file mode 100644 index 0000000..d560b64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/map_init_key_duplicate_err.vv:5:3: error: duplicate key "foo" in map literal + 3 | 'foo': 'bar' + 4 | 'abc': 'abc' + 5 | 'foo': 'bar' + | ~~~~~ + 6 | } + 7 | println(a) +vlib/v/checker/tests/map_init_key_duplicate_err.vv:9:18: error: duplicate key "2" in map literal + 7 | println(a) + 8 | + 9 | _ = map{2:0 3:0 2:0} + | ^ + 10 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.vv new file mode 100644 index 0000000..cd6efe6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_key_duplicate_err.vv @@ -0,0 +1,10 @@ +fn main() { + a := map{ + 'foo': 'bar' + 'abc': 'abc' + 'foo': 'bar' + } + println(a) + + _ = map{2:0 3:0 2:0} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.out b/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.out new file mode 100644 index 0000000..117e787 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/map_init_wrong_type.vv:3:18: error: invalid map value: expected `f32`, not `float literal` + 1 | fn main() { + 2 | mut a := map[string]f32{} + 3 | a = map{ 'x': 12.3 } + | ~~~~ + 4 | _ = map{2:0 3:0 "hi":0} + 5 | _ = map{2:0 3:`@` 4:0} +vlib/v/checker/tests/map_init_wrong_type.vv:4:20: error: invalid map key: expected `int`, not `string` + 2 | mut a := map[string]f32{} + 3 | a = map{ 'x': 12.3 } + 4 | _ = map{2:0 3:0 "hi":0} + | ~~~~ + 5 | _ = map{2:0 3:`@` 4:0} + 6 | _ = a +vlib/v/checker/tests/map_init_wrong_type.vv:5:18: error: invalid map value: expected `int`, not `rune` + 3 | a = map{ 'x': 12.3 } + 4 | _ = map{2:0 3:0 "hi":0} + 5 | _ = map{2:0 3:`@` 4:0} + | ~~~ + 6 | _ = a + 7 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.vv b/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.vv new file mode 100644 index 0000000..dc41230 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_init_wrong_type.vv @@ -0,0 +1,7 @@ +fn main() { + mut a := map[string]f32{} + a = map{ 'x': 12.3 } + _ = map{2:0 3:0 "hi":0} + _ = map{2:0 3:`@` 4:0} + _ = a +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_ops.out b/v_windows/v/old/vlib/v/checker/tests/map_ops.out new file mode 100644 index 0000000..d30508b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_ops.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/map_ops.vv:3:7: error: invalid key: expected `int`, not `rune` + 1 | fn test_map() { + 2 | mut m := map[int]string + 3 | _ = m[`!`] + | ~~~~~ + 4 | m['hi'] = 8 + 5 | m[&m] += 4 +vlib/v/checker/tests/map_ops.vv:4:3: error: invalid key: expected `int`, not `string` + 2 | mut m := map[int]string + 3 | _ = m[`!`] + 4 | m['hi'] = 8 + | ~~~~~~ + 5 | m[&m] += 4 + 6 | } +vlib/v/checker/tests/map_ops.vv:5:3: error: invalid key: expected `int`, not `&map[int]string` + 3 | _ = m[`!`] + 4 | m['hi'] = 8 + 5 | m[&m] += 4 + | ~~~~ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/map_ops.vv b/v_windows/v/old/vlib/v/checker/tests/map_ops.vv new file mode 100644 index 0000000..ac71947 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_ops.vv @@ -0,0 +1,6 @@ +fn test_map() { + mut m := map[int]string + _ = m[`!`] + m['hi'] = 8 + m[&m] += 4 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.out b/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.out new file mode 100644 index 0000000..d5f268b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/map_unknown_value.vv:2:23: error: unknown type `DoesNotExist` + 1 | struct App { + 2 | my_map map[string]DoesNotExist + | ~~~~~~~~~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.vv b/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.vv new file mode 100644 index 0000000..90cb87d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/map_unknown_value.vv @@ -0,0 +1,3 @@ +struct App { + my_map map[string]DoesNotExist +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.out b/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.out new file mode 100644 index 0000000..49ddf1f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/match_alias_type_err.vv:13:3: error: cannot match alias type `Stmt` with `SelectStmt` + 11 | + 12 | match stmt { + 13 | SelectStmt { panic('select') } + | ~~~~~~~~~~ + 14 | else { /* why? */ } + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.vv new file mode 100644 index 0000000..2673231 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_alias_type_err.vv @@ -0,0 +1,16 @@ +type Stmt = SelectStmt + +struct SelectStmt {} + +fn parse(sql string) Stmt { + return SelectStmt{} +} + +fn main() { + stmt := parse('select 123') + + match stmt { + SelectStmt { panic('select') } + else { /* why? */ } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.out b/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.out new file mode 100644 index 0000000..11263d5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/match_duplicate_branch.vv:15:3: error: match case `St1` is handled more than once + 13 | match i { + 14 | St1 { println('St1') } + 15 | St1 { println('St1') } + | ~~~ + 16 | St2 { println('St2') } + 17 | } +vlib/v/checker/tests/match_duplicate_branch.vv:20:3: error: match case `St1` is handled more than once + 18 | match i { + 19 | St1 { println('St1') } + 20 | St1 { println('St1') } + | ~~~ + 21 | else { println('else') } + 22 | } +vlib/v/checker/tests/match_duplicate_branch.vv:29:3: error: match case `green` is handled more than once + 27 | .red { println('red') } + 28 | .green { println('green') } + 29 | .green { println('green') } + | ~~~~~~ + 30 | .blue { println('blue') } + 31 | } +vlib/v/checker/tests/match_duplicate_branch.vv:34:3: error: match case `green` is handled more than once + 32 | match c { + 33 | .red, .green { println('red green') } + 34 | .green { println('green') } + | ~~~~~~ + 35 | else { println('else') } + 36 | } +vlib/v/checker/tests/match_duplicate_branch.vv:43:3: error: match case `2` is handled more than once + 41 | 1 { println('1') } + 42 | 2 { println('2') } + 43 | 2 { println('3') } + | ^ + 44 | else { println('else') } + 45 | } +vlib/v/checker/tests/match_duplicate_branch.vv:51:3: error: match case `3` is handled more than once + 49 | match i { + 50 | 1...5 { println('1 to 5') } + 51 | 3 { println('3') } + | ^ + 52 | else { println('else') } + 53 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.vv b/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.vv new file mode 100644 index 0000000..dd5a92c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_duplicate_branch.vv @@ -0,0 +1,61 @@ +enum Color { + red + green + blue +} + +struct St1 {} +struct St2 {} + +type St = St1 | St2 + +fn test_sum_type(i St) { + match i { + St1 { println('St1') } + St1 { println('St1') } + St2 { println('St2') } + } + match i { + St1 { println('St1') } + St1 { println('St1') } + else { println('else') } + } +} + +fn test_enum(c Color) { + match c { + .red { println('red') } + .green { println('green') } + .green { println('green') } + .blue { println('blue') } + } + match c { + .red, .green { println('red green') } + .green { println('green') } + else { println('else') } + } +} + +fn test_int(i int) { + match i { + 1 { println('1') } + 2 { println('2') } + 2 { println('3') } + else { println('else') } + } +} + +fn test_range(i int) { + match i { + 1...5 { println('1 to 5') } + 3 { println('3') } + else { println('else') } + } +} + +fn main() { + test_sum_type(St1{}) + test_enum(.red) + test_int(2) + test_range(4) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.out b/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.out new file mode 100644 index 0000000..c3331f1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/match_else_last_expr.vv:4:3: error: `else` must be the last branch of `match` + 2 | match 1 { + 3 | 1 { println('1') } + 4 | else { println('else') } + | ~~~~ + 5 | 4 { println('4') } + 6 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.vv b/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.vv new file mode 100644 index 0000000..3aa5cc5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_else_last_expr.vv @@ -0,0 +1,7 @@ +fn main() { + match 1 { + 1 { println('1') } + else { println('else') } + 4 { println('4') } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.out b/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.out new file mode 100644 index 0000000..e42355f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/match_expr_and_expected_type_error.vv:3:3: error: cannot match `rune` with `string` + 1 | ch := `a` + 2 | match ch { + 3 | 'a' {} + | ~~~ + 4 | else {} + 5 | } +vlib/v/checker/tests/match_expr_and_expected_type_error.vv:9:3: error: cannot match `int` with `string` + 7 | i := 123 + 8 | match i { + 9 | 'a' {} + | ~~~ + 10 | else {} + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.vv b/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.vv new file mode 100644 index 0000000..ef1e62c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_and_expected_type_error.vv @@ -0,0 +1,11 @@ +ch := `a` +match ch { + 'a' {} + else {} +} + +i := 123 +match i { + 'a' {} + else {} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_else.out b/v_windows/v/old/vlib/v/checker/tests/match_expr_else.out new file mode 100644 index 0000000..cf70833 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_else.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/match_expr_else.vv:5:6: error: match must be exhaustive (add match branches for: `f64` or `else {}` at the end) + 3 | fn main() { + 4 | x := AA('test') + 5 | _ = match x { + | ~~~~~~~~~ + 6 | int { + 7 | 'int' +vlib/v/checker/tests/match_expr_else.vv:23:3: error: match expression is exhaustive, `else` is unnecessary + 21 | 'f64' + 22 | } + 23 | else { + | ~~~~ + 24 | 'else' + 25 | } +vlib/v/checker/tests/match_expr_else.vv:34:3: error: `else` must be the last branch of `match` + 32 | 'string' + 33 | } + 34 | else { + | ~~~~ + 35 | 'else' + 36 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_else.vv b/v_windows/v/old/vlib/v/checker/tests/match_expr_else.vv new file mode 100644 index 0000000..7c5551e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_else.vv @@ -0,0 +1,41 @@ +type AA = int | string | f64 + +fn main() { + x := AA('test') + _ = match x { + int { + 'int' + } + string { + 'string' + } + } + _ = match x { + int { + 'int' + } + string { + 'string' + } + f64 { + 'f64' + } + else { + 'else' + } + } + _ = match x { + int { + 'int' + } + string { + 'string' + } + else { + 'else' + } + f64 { + 'f64' + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.out b/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.out new file mode 100644 index 0000000..927da5a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/match_expr_empty_branch.vv:3:2: error: `match` expression requires an expression as the last statement of every branch + 1 | _ := match true { + 2 | true { 0 } + 3 | false {} + | ~~~~~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.vv b/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.vv new file mode 100644 index 0000000..2a8650d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_empty_branch.vv @@ -0,0 +1,4 @@ +_ := match true { + true { 0 } + false {} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.out b/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.out new file mode 100644 index 0000000..6b5e161 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/match_expr_non_void_stmt_last.vv:9:4: error: `match` expression requires an expression as the last statement of every branch + 7 | } + 8 | []int { + 9 | return arr.str() + | ~~~~~~~~~~~~~~~~ + 10 | } + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.vv b/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.vv new file mode 100644 index 0000000..0737152 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_expr_non_void_stmt_last.vv @@ -0,0 +1,17 @@ +type Arr = []int | []string + +fn (arr Arr) str() string { + return match arr { + []string { + arr.join(' ') + } + []int { + return arr.str() + } + } +} + +fn main() { + println(Arr([0, 0])) + println(Arr(['0', '0'])) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.out b/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.out new file mode 100644 index 0000000..4c6b98b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/match_invalid_type.vv:5:3: error: `IoS` has no variant `byte` + 3 | fn sum() { + 4 | match IoS(1) { + 5 | byte { + | ~~~~ + 6 | println('not cool') + 7 | } +vlib/v/checker/tests/match_invalid_type.vv:4:2: error: match must be exhaustive (add match branches for: `int`, `string` or `else {}` at the end) + 2 | + 3 | fn sum() { + 4 | match IoS(1) { + | ~~~~~~~~~~~~~~ + 5 | byte { + 6 | println('not cool') +vlib/v/checker/tests/match_invalid_type.vv:24:3: error: `Cat` doesn't implement method `speak` of interface `Animal` + 22 | a := Animal(Dog{}) + 23 | match a { + 24 | Cat { + | ~~~ + 25 | println('not cool either') + 26 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.vv b/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.vv new file mode 100644 index 0000000..3a5dca6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_invalid_type.vv @@ -0,0 +1,29 @@ +type IoS = int | string + +fn sum() { + match IoS(1) { + byte { + println('not cool') + } + } +} + +interface Animal { + speak() +} + +struct Dog {} + +fn (d Dog) speak() {} + +struct Cat {} + +fn iface() { + a := Animal(Dog{}) + match a { + Cat { + println('not cool either') + } + else {} + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.out b/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.out new file mode 100644 index 0000000..3a8e8fe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/match_return_mismatch_type_err.vv:4:10: error: return type mismatch, it should be `string` + 2 | a := match 1 { + 3 | 1 { 'aa' } + 4 | else { 22 } + | ~~ + 5 | } + 6 | println(a) diff --git a/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.vv new file mode 100644 index 0000000..c422126 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_return_mismatch_type_err.vv @@ -0,0 +1,7 @@ +fn main() { + a := match 1 { + 1 { 'aa' } + else { 22 } + } + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.out b/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.out new file mode 100644 index 0000000..9f2201f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/match_sumtype_multiple_types.vv:26:13: error: type `Charlie` has no field or method `char` + 24 | match l { + 25 | Alfa, Charlie { + 26 | assert l.char == `a` + | ~~~~ + 27 | assert l.letter() == 'a' + 28 | } +vlib/v/checker/tests/match_sumtype_multiple_types.vv:27:13: error: unknown method: `Charlie.letter` + 25 | Alfa, Charlie { + 26 | assert l.char == `a` + 27 | assert l.letter() == 'a' + | ~~~~~~~~ + 28 | } + 29 | Bravo {
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.vv b/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.vv new file mode 100644 index 0000000..eca5954 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_sumtype_multiple_types.vv @@ -0,0 +1,33 @@ +struct Alfa { + char rune +} + +fn (a Alfa) letter() rune { + return a.char +} + +struct Bravo { + char rune +} + +fn (b Bravo) letter() rune { + return b.char +} + +struct Charlie {} + +type NATOAlphabet = Alfa | Bravo | Charlie + +fn method_not_exists() { + a := Alfa{} + l := NATOAlphabet(a) + match l { + Alfa, Charlie { + assert l.char == `a` + assert l.letter() == 'a' + } + Bravo { + assert false + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.out b/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.out new file mode 100644 index 0000000..ddfed08 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/match_undefined_cond.vv:4:15: error: undefined ident: `Asd` + 2 | + 3 | fn main() { + 4 | res := match Asd { + | ~~~ + 5 | 1 { 'foo' } + 6 | 2 { 'test' } +vlib/v/checker/tests/match_undefined_cond.vv:5:3: error: cannot match `void` with `int literal` + 3 | fn main() { + 4 | res := match Asd { + 5 | 1 { 'foo' } + | ^ + 6 | 2 { 'test' } + 7 | else { '' } +vlib/v/checker/tests/match_undefined_cond.vv:6:3: error: cannot match `void` with `int literal` + 4 | res := match Asd { + 5 | 1 { 'foo' } + 6 | 2 { 'test' } + | ^ + 7 | else { '' } + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.vv b/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.vv new file mode 100644 index 0000000..952e4b7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/match_undefined_cond.vv @@ -0,0 +1,10 @@ +type Asd = int + +fn main() { + res := match Asd { + 1 { 'foo' } + 2 { 'test' } + else { '' } + } + _ = res +} diff --git a/v_windows/v/old/vlib/v/checker/tests/method_array_slice.out b/v_windows/v/old/vlib/v/checker/tests/method_array_slice.out new file mode 100644 index 0000000..dde9055 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_array_slice.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/method_array_slice.vv:5:12: error: .slice() is a private method, use `x[start..end]` instead + 3 | fn main() { + 4 | a := os.args.clone() + 5 | println(a.slice(1)) + | ~~~~~~~~ + 6 | println(a[1..]) + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/method_array_slice.vv b/v_windows/v/old/vlib/v/checker/tests/method_array_slice.vv new file mode 100644 index 0000000..cfb77f3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_array_slice.vv @@ -0,0 +1,7 @@ +import os + +fn main() { + a := os.args.clone() + println(a.slice(1)) + println(a[1..]) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.out b/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.out new file mode 100644 index 0000000..2017a6f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/method_generic_infer_err.vv:9:7: error: could not infer generic type `T` in call to `func` + 7 | fn main() { + 8 | data := Data{} + 9 | data.func() + | ~~~~~~ + 10 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.vv b/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.vv new file mode 100644 index 0000000..226c4c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_generic_infer_err.vv @@ -0,0 +1,10 @@ +struct Data {} + +fn (_ Data) func<T>() T { + return T{} +} + +fn main() { + data := Data{} + data.func() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.out b/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.out new file mode 100644 index 0000000..195ab56 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/method_op_alias_err.vv:4:18: error: expected `Foo` not `Foo2` - both operands must be the same type for operator overloading + 2 | type Foo2 = string + 3 | + 4 | fn (f Foo) + (f1 Foo2) Foo2 { + | ~~~~ + 5 | return Foo2(f + f1) + 6 | } +vlib/v/checker/tests/method_op_alias_err.vv:5:17: error: infix expr: cannot use `string` (right expression) as `string` + 3 | + 4 | fn (f Foo) + (f1 Foo2) Foo2 { + 5 | return Foo2(f + f1) + | ~~~~~~ + 6 | } + 7 | +vlib/v/checker/tests/method_op_alias_err.vv:8:1: error: cannot define operator methods on type alias for `string` + 6 | } + 7 | + 8 | fn (f Foo) * (f1 Foo) Foo { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 9 | return Foo(f + f1) + 10 | } +vlib/v/checker/tests/method_op_alias_err.vv:14:6: error: mismatched types `Foo` and `string` + 12 | fn main() { + 13 | mut f := Foo('fg') + 14 | f += 'fg' + | ~~ + 15 | f *= Foo2('2') + 16 | f -= Foo('fo') +vlib/v/checker/tests/method_op_alias_err.vv:15:9: error: cannot assign to `f`: expected `Foo`, not `Foo2` + 13 | mut f := Foo('fg') + 14 | f += 'fg' + 15 | f *= Foo2('2') + | ~~~~~~~~~ + 16 | f -= Foo('fo') + 17 | println(f) +vlib/v/checker/tests/method_op_alias_err.vv:16:6: error: cannot use operator methods on type alias for `string` + 14 | f += 'fg' + 15 | f *= Foo2('2') + 16 | f -= Foo('fo') + | ~~ + 17 | println(f) + 18 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.vv b/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.vv new file mode 100644 index 0000000..d5b4ecd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_op_alias_err.vv @@ -0,0 +1,18 @@ +type Foo = string +type Foo2 = string + +fn (f Foo) + (f1 Foo2) Foo2 { + return Foo2(f + f1) +} + +fn (f Foo) * (f1 Foo) Foo { + return Foo(f + f1) +} + +fn main() { + mut f := Foo('fg') + f += 'fg' + f *= Foo2('2') + f -= Foo('fo') + println(f) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/method_op_err.out b/v_windows/v/old/vlib/v/checker/tests/method_op_err.out new file mode 100644 index 0000000..547ceea --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_op_err.out @@ -0,0 +1,69 @@ +vlib/v/checker/tests/method_op_err.vv:11:1: error: operator methods should have exactly 1 argument + 9 | } + 10 | + 11 | fn (u User) + () { + | ~~~~~~~~~~~~~~~~ + 12 | } + 13 | +vlib/v/checker/tests/method_op_err.vv:14:18: error: expected `User` not `Foo` - both operands must be the same type for operator overloading + 12 | } + 13 | + 14 | fn (u User) - (f Foo) User { + | ~~~ + 15 | return User{u.a - f.a, u.b-f.a} + 16 | } +vlib/v/checker/tests/method_op_err.vv:18:9: error: receiver cannot be `mut` for operator overloading + 16 | } + 17 | + 18 | fn (mut u User) * (u1 User) User { + | ~~~~~~ + 19 | return User{} + 20 | } +vlib/v/checker/tests/method_op_err.vv:22:1: error: argument cannot be `mut` for operator overloading + 20 | } + 21 | + 22 | fn (u User) / (mut u1 User) User { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 23 | return User{} + 24 | } +vlib/v/checker/tests/method_op_err.vv:32:13: error: infix expr: cannot use `Foo` (right expression) as `User` + 30 | fn main() { + 31 | println(User{3, 4}) + 32 | println(User{3, 4} - Foo{3, 3}) + | ~~~~~~~~~~~~~~~~~~~~~~ + 33 | println(User{3, 2} < User{2, 4}) + 34 | println(User{3, 4} < Foo{3, 4}) +vlib/v/checker/tests/method_op_err.vv:33:13: error: undefined operation `User` < `User` + 31 | println(User{3, 4}) + 32 | println(User{3, 4} - Foo{3, 3}) + 33 | println(User{3, 2} < User{2, 4}) + | ~~~~~~~~~~~~~~~~~~~~~~~ + 34 | println(User{3, 4} < Foo{3, 4}) + 35 | mut u := User{3, 4} +vlib/v/checker/tests/method_op_err.vv:34:13: error: mismatched types `User` and `Foo` + 32 | println(User{3, 4} - Foo{3, 3}) + 33 | println(User{3, 2} < User{2, 4}) + 34 | println(User{3, 4} < Foo{3, 4}) + | ~~~~~~~~~~~~~~~~~~~~~~ + 35 | mut u := User{3, 4} + 36 | _ = u +vlib/v/checker/tests/method_op_err.vv:37:10: error: cannot assign to `u`: expected `User`, not `int literal` + 35 | mut u := User{3, 4} + 36 | _ = u + 37 | u += 12 + | ~~ + 38 | u %= User{1, 3} + 39 | u += User{2, 3} +vlib/v/checker/tests/method_op_err.vv:38:5: error: operator %= not defined on left operand type `User` + 36 | _ = u + 37 | u += 12 + 38 | u %= User{1, 3} + | ^ + 39 | u += User{2, 3} + 40 | } +vlib/v/checker/tests/method_op_err.vv:39:7: error: operator `+` must return `User` to be used as an assignment operator + 37 | u += 12 + 38 | u %= User{1, 3} + 39 | u += User{2, 3} + | ~~ + 40 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/method_op_err.vv b/v_windows/v/old/vlib/v/checker/tests/method_op_err.vv new file mode 100644 index 0000000..24a82dd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_op_err.vv @@ -0,0 +1,40 @@ +struct User { + a int + b int +} + +struct Foo { + a int + b int +} + +fn (u User) + () { +} + +fn (u User) - (f Foo) User { + return User{u.a - f.a, u.b-f.a} +} + +fn (mut u User) * (u1 User) User { + return User{} +} + +fn (u User) / (mut u1 User) User { + return User{} +} + +fn (u User) + (u1 User) Foo { + return Foo{a: u.a + u1.a, b: u.b + u1.b} +} + +fn main() { + println(User{3, 4}) + println(User{3, 4} - Foo{3, 3}) + println(User{3, 2} < User{2, 4}) + println(User{3, 4} < Foo{3, 4}) + mut u := User{3, 4} + _ = u + u += 12 + u %= User{1, 3} + u += User{2, 3} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.out b/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.out new file mode 100644 index 0000000..c5175b3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/method_wrong_arg_type.vv:10:9: error: cannot use `MyEnum` as `string` in argument 1 to `Sss.info` + 8 | e := MyEnum.x + 9 | s := Sss{} + 10 | s.info(e) + | ^ + 11 | } + 12 | +vlib/v/checker/tests/method_wrong_arg_type.vv:18:8: error: cannot use `int` as `&Sss` in argument 1 to `Sss.ptr` + 16 | s := Sss{} + 17 | v := 4 + 18 | s.ptr(v) + | ^ + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.vv b/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.vv new file mode 100644 index 0000000..d44a4cd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/method_wrong_arg_type.vv @@ -0,0 +1,19 @@ +enum MyEnum { x y z } +pub fn (e MyEnum) str() string { return int(e).str() } + +struct Sss { } +fn (s Sss) info(msg string) { println(msg) } + +fn enum_str() { + e := MyEnum.x + s := Sss{} + s.info(e) +} + +fn (s Sss) ptr(p &Sss) {} + +fn ptr_arg() { + s := Sss{} + v := 4 + s.ptr(v) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.out new file mode 100644 index 0000000..b6895aa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.out @@ -0,0 +1,62 @@ +vlib/v/checker/tests/minus_op_wrong_type_err.vv:10:10: error: mismatched types `Aaa` and `int literal` + 8 | + 9 | fn main() { + 10 | println(Aaa{} - 10) + | ~~~~~~~~~~ + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:11:10: error: mismatched types `int literal` and `Aaa` + 9 | fn main() { + 10 | println(Aaa{} - 10) + 11 | println(10 - Aaa{}) + | ~~~~~~~~~~ + 12 | println([1, 2, 3] - 10) + 13 | println(10 - [1, 2, 3]) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:12:10: error: mismatched types `[]int` and `int literal` + 10 | println(Aaa{} - 10) + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) + | ~~~~~~~~~~~~~~ + 13 | println(10 - [1, 2, 3]) + 14 | a := map[string]int{} +vlib/v/checker/tests/minus_op_wrong_type_err.vv:13:10: error: mismatched types `int literal` and `[]int` + 11 | println(10 - Aaa{}) + 12 | println([1, 2, 3] - 10) + 13 | println(10 - [1, 2, 3]) + | ~~~~~~~~~~~~~~ + 14 | a := map[string]int{} + 15 | println(a - 10) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:15:10: error: mismatched types `map[string]int` and `int literal` + 13 | println(10 - [1, 2, 3]) + 14 | a := map[string]int{} + 15 | println(a - 10) + | ~~~~~~ + 16 | println(10 - a) + 17 | println(-Aaa{}) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:16:10: error: mismatched types `int literal` and `map[string]int` + 14 | a := map[string]int{} + 15 | println(a - 10) + 16 | println(10 - a) + | ~~~~~~ + 17 | println(-Aaa{}) + 18 | println(-a) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:17:10: error: - operator can only be used with numeric types + 15 | println(a - 10) + 16 | println(10 - a) + 17 | println(-Aaa{}) + | ^ + 18 | println(-a) + 19 | println(-Color.red) +vlib/v/checker/tests/minus_op_wrong_type_err.vv:18:10: error: - operator can only be used with numeric types + 16 | println(10 - a) + 17 | println(-Aaa{}) + 18 | println(-a) + | ^ + 19 | println(-Color.red) + 20 | } +vlib/v/checker/tests/minus_op_wrong_type_err.vv:19:10: error: - operator can only be used with numeric types + 17 | println(-Aaa{}) + 18 | println(-a) + 19 | println(-Color.red) + | ^ + 20 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.vv new file mode 100644 index 0000000..e015064 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/minus_op_wrong_type_err.vv @@ -0,0 +1,20 @@ +struct Aaa {} + +enum Color { + red + green + blue +} + +fn main() { + println(Aaa{} - 10) + println(10 - Aaa{}) + println([1, 2, 3] - 10) + println(10 - [1, 2, 3]) + a := map[string]int{} + println(a - 10) + println(10 - a) + println(-Aaa{}) + println(-a) + println(-Color.red) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.out b/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.out new file mode 100644 index 0000000..a1a1d8a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/mismatched_ptr_op_ptr.vv:5:17: error: mismatched types `&string` and `string` + 3 | unsafe { + 4 | b := &a + 5 | println(b+*b) + | ~~~ + 6 | println(b+b) + 7 | } +vlib/v/checker/tests/mismatched_ptr_op_ptr.vv:6:17: error: invalid operator `+` to `&string` and `&string` + 4 | b := &a + 5 | println(b+*b) + 6 | println(b+b) + | ~~~ + 7 | } + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.vv b/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.vv new file mode 100644 index 0000000..21a859d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mismatched_ptr_op_ptr.vv @@ -0,0 +1,8 @@ +fn main() { + a := '1' + unsafe { + b := &a + println(b+*b) + println(b+b) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.out b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.out new file mode 100644 index 0000000..c6dc4b2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.out @@ -0,0 +1 @@ +builder error: Header file <missing/folder/header1.h>, needed for module `main` was not found. Please install the corresponding development headers. diff --git a/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.vv b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.vv new file mode 100644 index 0000000..d8bdb47 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_1.vv @@ -0,0 +1,6 @@ +module main + +// The following header file is intentionally missing. +// The #include does not have the optional explanation part +// after a `#` sign: +#include <missing/folder/header1.h> diff --git a/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.out b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.out new file mode 100644 index 0000000..176ee7b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.out @@ -0,0 +1 @@ +builder error: Header file <missing/folder/header.h>, needed for module `main` was not found. Please install missing C library. diff --git a/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.vv b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.vv new file mode 100644 index 0000000..a76cc0b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/missing_c_lib_header_with_explanation_2.vv @@ -0,0 +1,6 @@ +module main + +// The following header file is intentionally missing. +// The part after `#` is an explanation message, that V will +// show, when it is not found: +#include <missing/folder/header.h> # Please install missing C library diff --git a/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.out new file mode 100644 index 0000000..6ae53be --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.out @@ -0,0 +1,56 @@ +vlib/v/checker/tests/mod_op_wrong_type_err.vv:3:10: error: float modulo not allowed, use math.fmod() instead + 1 | struct Aaa{} + 2 | fn main() { + 3 | println(0.5 % 1) + | ~~~ + 4 | println(1 % 0.5) + 5 | println([1,2,3] % 1) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:4:14: error: float modulo not allowed, use math.fmod() instead + 2 | fn main() { + 3 | println(0.5 % 1) + 4 | println(1 % 0.5) + | ~~~ + 5 | println([1,2,3] % 1) + 6 | println(1 % [1,2,3]) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:5:10: error: mismatched types `[]int` and `int literal` + 3 | println(0.5 % 1) + 4 | println(1 % 0.5) + 5 | println([1,2,3] % 1) + | ~~~~~~~~~~~ + 6 | println(1 % [1,2,3]) + 7 | a := Aaa{} +vlib/v/checker/tests/mod_op_wrong_type_err.vv:6:10: error: mismatched types `int literal` and `[]int` + 4 | println(1 % 0.5) + 5 | println([1,2,3] % 1) + 6 | println(1 % [1,2,3]) + | ~~~~~~~~~~~ + 7 | a := Aaa{} + 8 | println(a % 1) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:8:10: error: mismatched types `Aaa` and `int literal` + 6 | println(1 % [1,2,3]) + 7 | a := Aaa{} + 8 | println(a % 1) + | ~~~~~ + 9 | println(1 % a) + 10 | b := map[string]int +vlib/v/checker/tests/mod_op_wrong_type_err.vv:9:10: error: mismatched types `int literal` and `Aaa` + 7 | a := Aaa{} + 8 | println(a % 1) + 9 | println(1 % a) + | ~~~~~ + 10 | b := map[string]int + 11 | println(b % 1) +vlib/v/checker/tests/mod_op_wrong_type_err.vv:11:10: error: mismatched types `map[string]int` and `int literal` + 9 | println(1 % a) + 10 | b := map[string]int + 11 | println(b % 1) + | ~~~~~ + 12 | println(1 % b) + 13 | } +vlib/v/checker/tests/mod_op_wrong_type_err.vv:12:10: error: mismatched types `int literal` and `map[string]int` + 10 | b := map[string]int + 11 | println(b % 1) + 12 | println(1 % b) + | ~~~~~ + 13 | } + diff --git a/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.vv new file mode 100644 index 0000000..b699714 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mod_op_wrong_type_err.vv @@ -0,0 +1,13 @@ +struct Aaa{} +fn main() { + println(0.5 % 1) + println(1 % 0.5) + println([1,2,3] % 1) + println(1 % [1,2,3]) + a := Aaa{} + println(a % 1) + println(1 % a) + b := map[string]int + println(b % 1) + println(1 % b) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.out b/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.out new file mode 100644 index 0000000..c54a42d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/modify_const_with_ref.vv:11:11: error: `constant` is immutable, cannot have a mutable reference to it + 9 | mut unused_var := Foo{} + 10 | unused_var = Foo{} + 11 | mut c := &constant + | ^ + 12 | c.value = 200 + 13 | } +vlib/v/checker/tests/modify_const_with_ref.vv:9:6: error: unused variable: `unused_var` + 7 | + 8 | fn main() { + 9 | mut unused_var := Foo{} + | ~~~~~~~~~~ + 10 | unused_var = Foo{} + 11 | mut c := &constant diff --git a/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.vv b/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.vv new file mode 100644 index 0000000..872460e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modify_const_with_ref.vv @@ -0,0 +1,13 @@ +struct Foo { +mut: + value int +} + +const constant = Foo{ 100 } + +fn main() { + mut unused_var := Foo{} + unused_var = Foo{} + mut c := &constant + c.value = 200 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.out b/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.out new file mode 100644 index 0000000..6efd5f2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/module_not_at_same_line_err.vv:2:1: error: `module` and `main` must be at same line + 1 | module + 2 | main + | ~~~~ + 3 | fn main() { + 4 | println('hello, world') diff --git a/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.vv b/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.vv new file mode 100644 index 0000000..a0e52f9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/module_not_at_same_line_err.vv @@ -0,0 +1,5 @@ +module +main +fn main() { + println('hello, world') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore.out b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore.out new file mode 100644 index 0000000..a0cc315 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/modules/module_alias_started_with_underscore/main.v:3:1: error: module alias `_` cannot start with `_` + 1 | module main + 2 | + 3 | import underscore as _ + | ~~~~~~~~~~~~~~~~~~~~~~ + 4 | + 5 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/main.v b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/main.v new file mode 100644 index 0000000..39f80a1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/main.v @@ -0,0 +1,7 @@ +module main + +import underscore as _ + +fn main() { + _.foo() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/underscore.v b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/underscore.v new file mode 100644 index 0000000..ec83c1c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/module_alias_started_with_underscore/underscore.v @@ -0,0 +1,5 @@ +module underscore + +pub fn foo() { + println('bar') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type.out b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type.out new file mode 100644 index 0000000..dbdf6a5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/modules/overload_return_type/main.v:14:8: error: cannot assign to `two`: expected `point.Point`, not `int` + 12 | y: 1 + 13 | } + 14 | two = one + two + | ~~~~~~~~~ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/main.v b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/main.v new file mode 100644 index 0000000..b682c49 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/main.v @@ -0,0 +1,15 @@ +module main + +import point { Point } + +fn main() { + one := Point{ + x: 1 + y: 2 + } + mut two := Point{ + x: 5 + y: 1 + } + two = one + two +} diff --git a/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/point.v b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/point.v new file mode 100644 index 0000000..a26932b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/modules/overload_return_type/point.v @@ -0,0 +1,11 @@ +module point + +pub struct Point { +mut: + x int + y int +} + +pub fn (a Point) + (b Point) int { + return a.x + b.x +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.out b/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.out new file mode 100644 index 0000000..6bd5ff9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.out @@ -0,0 +1,57 @@ +vlib/v/checker/tests/mul_op_wrong_type_err.vv:5:13: error: mismatched types `Aaa` and `int literal` + 3 | struct Aaa{} + 4 | fn main() { + 5 | println(Aaa{} * 10) + | ~~~~~~~~~~ + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:6:13: error: mismatched types `int literal` and `Aaa` + 4 | fn main() { + 5 | println(Aaa{} * 10) + 6 | println(10 * Aaa{}) + | ~~~~~~~~~~ + 7 | println([1,2,3] * 10) + 8 | println(10 * [1,2,3]) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:7:13: error: mismatched types `[]int` and `int literal` + 5 | println(Aaa{} * 10) + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) + | ~~~~~~~~~~~~ + 8 | println(10 * [1,2,3]) + 9 | a := map[string]int +vlib/v/checker/tests/mul_op_wrong_type_err.vv:8:13: error: mismatched types `int literal` and `[]int` + 6 | println(10 * Aaa{}) + 7 | println([1,2,3] * 10) + 8 | println(10 * [1,2,3]) + | ~~~~~~~~~~~~ + 9 | a := map[string]int + 10 | println(a * 10) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:10:13: error: mismatched types `map[string]int` and `int literal` + 8 | println(10 * [1,2,3]) + 9 | a := map[string]int + 10 | println(a * 10) + | ~~~~~~ + 11 | println(10 * a) + 12 | c1 := cmplx.complex(1,-2) +vlib/v/checker/tests/mul_op_wrong_type_err.vv:11:13: error: mismatched types `int literal` and `map[string]int` + 9 | a := map[string]int + 10 | println(a * 10) + 11 | println(10 * a) + | ~~~~~~ + 12 | c1 := cmplx.complex(1,-2) + 13 | c2 := c1 * 2.0 +vlib/v/checker/tests/mul_op_wrong_type_err.vv:13:8: error: infix expr: cannot use `float literal` (right expression) as `math.complex.Complex` + 11 | println(10 * a) + 12 | c1 := cmplx.complex(1,-2) + 13 | c2 := c1 * 2.0 + | ~~~~~~~~ + 14 | println(c2) + 15 | c3 := 2.0 * c1 +vlib/v/checker/tests/mul_op_wrong_type_err.vv:15:8: error: infix expr: cannot use `math.complex.Complex` (right expression) as `float literal` + 13 | c2 := c1 * 2.0 + 14 | println(c2) + 15 | c3 := 2.0 * c1 + | ~~~~~~~~ + 16 | println(c3) + 17 | } + diff --git a/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.vv new file mode 100644 index 0000000..a1e3394 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mul_op_wrong_type_err.vv @@ -0,0 +1,17 @@ +import math +import math.complex as cmplx +struct Aaa{} +fn main() { + println(Aaa{} * 10) + println(10 * Aaa{}) + println([1,2,3] * 10) + println(10 * [1,2,3]) + a := map[string]int + println(a * 10) + println(10 * a) + c1 := cmplx.complex(1,-2) + c2 := c1 * 2.0 + println(c2) + c3 := 2.0 * c1 + println(c3) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.out new file mode 100644 index 0000000..731b9f7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/multi_const_field_name_duplicate_err.vv:2:8: error: duplicate const `aaa` + 1 | const (aaa = 1) + 2 | const (aaa = 2) + | ~~~ + 3 | fn main() { + 4 | println(aaa) diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.vv new file mode 100644 index 0000000..883abac --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_const_field_name_duplicate_err.vv @@ -0,0 +1,5 @@ +const (aaa = 1) +const (aaa = 2) +fn main() { + println(aaa) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_names_err.out b/v_windows/v/old/vlib/v/checker/tests/multi_names_err.out new file mode 100644 index 0000000..a022208 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_names_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/multi_names_err.vv:2:4: error: unexpected name `a` + 1 | fn main() { + 2 | a a a a := 1 + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_names_err.vv b/v_windows/v/old/vlib/v/checker/tests/multi_names_err.vv new file mode 100644 index 0000000..cff1441 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_names_err.vv @@ -0,0 +1,3 @@ +fn main() { + a a a a := 1 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.out b/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.out new file mode 100644 index 0000000..f5be76a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/multi_value_method_err.vv:1:7: error: cannot define method on multi-value + 1 | fn (v (int, int)) f() {} + | ~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.vv b/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.vv new file mode 100644 index 0000000..a84f0b6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/multi_value_method_err.vv @@ -0,0 +1 @@ +fn (v (int, int)) f() {} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_arg.out b/v_windows/v/old/vlib/v/checker/tests/mut_arg.out new file mode 100644 index 0000000..f18c285 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_arg.out @@ -0,0 +1,25 @@ +vlib/v/checker/tests/mut_arg.vv:6:3: error: `f` parameter `par` is `mut`, you need to provide `mut` e.g. `mut arg1` + 4 | } + 5 | + 6 | f([3,4]) + | ~~~~~ + 7 | mut a := [1,2] + 8 | f(a) +vlib/v/checker/tests/mut_arg.vv:8:3: error: `f` parameter `par` is `mut`, you need to provide `mut` e.g. `mut arg1` + 6 | f([3,4]) + 7 | mut a := [1,2] + 8 | f(a) + | ^ + 9 | + 10 | g(mut [3,4]) +vlib/v/checker/tests/mut_arg.vv:10:7: error: array literal can not be modified + 8 | f(a) + 9 | + 10 | g(mut [3,4]) + | ~~~~~ + 11 | g(mut a) +vlib/v/checker/tests/mut_arg.vv:11:7: error: `g` parameter `par` is not `mut`, `mut` is not needed` + 9 | + 10 | g(mut [3,4]) + 11 | g(mut a) + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_arg.vv b/v_windows/v/old/vlib/v/checker/tests/mut_arg.vv new file mode 100644 index 0000000..0a2afdd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_arg.vv @@ -0,0 +1,11 @@ +fn f(mut par []int) { +} +fn g(par []int) { +} + +f([3,4]) +mut a := [1,2] +f(a) + +g(mut [3,4]) +g(mut a) diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.out b/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.out new file mode 100644 index 0000000..726f4b8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/mut_args_warning.vv:1:8: warning: use `mut f Foo` instead of `f mut Foo` + 1 | fn f(x mut []int) { x[0] = 1 } + | ~~~ + 2 | fn main() { + 3 | mut x := [0] diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.vv b/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.vv new file mode 100644 index 0000000..c29b27d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_args_warning.vv @@ -0,0 +1,5 @@ +fn f(x mut []int) { x[0] = 1 } +fn main() { + mut x := [0] + f(mut x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.out b/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.out new file mode 100644 index 0000000..a98d17b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/mut_array_get_element_address_err.vv:3:20: error: cannot take the address of mutable array elements outside unsafe blocks + 1 | fn main() { + 2 | mut arr_int := [int(23), 45, 7, 8] + 3 | ele := &arr_int[1] + | ~~~ + 4 | println(ele) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.vv b/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.vv new file mode 100644 index 0000000..1afbcb3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_array_get_element_address_err.vv @@ -0,0 +1,5 @@ +fn main() { + mut arr_int := [int(23), 45, 7, 8] + ele := &arr_int[1] + println(ele) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_int.out b/v_windows/v/old/vlib/v/checker/tests/mut_int.out new file mode 100644 index 0000000..20a092c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_int.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/mut_int.vv:1:14: error: mutable arguments are only allowed for arrays, interfaces, maps, pointers, structs or their aliases +return values instead: `fn foo(mut n int) {` => `fn foo(n int) int {` + 1 | fn foo(mut x int) { + | ~~~ + 2 | } + 3 | diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_int.vv b/v_windows/v/old/vlib/v/checker/tests/mut_int.vv new file mode 100644 index 0000000..a268c5a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_int.vv @@ -0,0 +1,5 @@ +fn foo(mut x int) { +} + +fn main() { +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.out b/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.out new file mode 100644 index 0000000..297c228 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/mut_map_get_value_address_err.vv:3:12: error: cannot take the address of map values + 1 | fn main() { + 2 | mut m := map{'key' : 3} + 3 | a := &m['key'] + | ~~~~~~~ + 4 | println(a) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.vv b/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.vv new file mode 100644 index 0000000..46e5b77 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_map_get_value_address_err.vv @@ -0,0 +1,5 @@ +fn main() { + mut m := map{'key' : 3} + a := &m['key'] + println(a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_receiver.out b/v_windows/v/old/vlib/v/checker/tests/mut_receiver.out new file mode 100644 index 0000000..fb160a4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_receiver.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/mut_receiver.vv:5:4: warning: use `(mut f Foo)` instead of `(f mut Foo)` + 3 | name string + 4 | } + 5 | fn (f mut Foo) info() { + | ~~~~~~~~~~~ + 6 | f.name = 'foo' + 7 | } +vlib/v/checker/tests/mut_receiver.vv:8:4: error: use `(mut f Foo)` or `(f &Foo)` instead of `(mut f &Foo)` + 6 | f.name = 'foo' + 7 | } + 8 | fn (mut f &Foo) info2() { + | ~~~~~~~~~~~~ + 9 | f.name = 'foo' + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_receiver.vv b/v_windows/v/old/vlib/v/checker/tests/mut_receiver.vv new file mode 100644 index 0000000..fae05df --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_receiver.vv @@ -0,0 +1,13 @@ +struct Foo{ +mut: + name string +} +fn (f mut Foo) info() { + f.name = 'foo' +} +fn (mut f &Foo) info2() { + f.name = 'foo' +} +fn main() { + println('hello, world') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.out b/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.out new file mode 100644 index 0000000..e0cd490 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/mut_receiver_lit.vv:10:1: error: cannot pass expression as `mut` + 8 | } + 9 | + 10 | Box{}.set(0) + | ~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.vv b/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.vv new file mode 100644 index 0000000..e015e71 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/mut_receiver_lit.vv @@ -0,0 +1,10 @@ +struct Box { +mut: + value int +} + +fn (mut box Box) set(value int) { + box.value = value +} + +Box{}.set(0) diff --git a/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.out b/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.out new file mode 100644 index 0000000..1927447 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/negative_assign_to_unsigned.vv:3:9: error: Cannot assign negative value to unsigned integer type + 1 | fn main() { + 2 | mut u := u32(10) + 3 | u = -10 + | ~~~ + 4 | eprintln(u) + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.vv b/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.vv new file mode 100644 index 0000000..da7646d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/negative_assign_to_unsigned.vv @@ -0,0 +1,5 @@ +fn main() { + mut u := u32(10) + u = -10 + eprintln(u) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/nested_aliases.out b/v_windows/v/old/vlib/v/checker/tests/nested_aliases.out new file mode 100644 index 0000000..da93210 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/nested_aliases.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/nested_aliases.vv:2:16: error: type `MyInt` is an alias, use the original alias type `int` instead + 1 | type MyInt = int + 2 | type MyMyInt = MyInt + | ~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/nested_aliases.vv b/v_windows/v/old/vlib/v/checker/tests/nested_aliases.vv new file mode 100644 index 0000000..a21d0d3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/nested_aliases.vv @@ -0,0 +1,2 @@ +type MyInt = int +type MyMyInt = MyInt diff --git a/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.out b/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.out new file mode 100644 index 0000000..8a996a1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/no_heap_struct.vv:13:6: error: `x` cannot be assigned outside `unsafe` blocks as it might refer to an object stored on stack. Consider declaring `Abc` as `[heap]`. + 11 | fn f(x &Abc) St { + 12 | s := St{ + 13 | a: x + | ^ + 14 | } + 15 | return s +vlib/v/checker/tests/no_heap_struct.vv:19:9: error: `x` cannot be returned outside `unsafe` blocks as it might refer to an object stored on stack. Consider declaring `Abc` as `[heap]`. + 17 | + 18 | fn g(mut x Abc) &Abc { + 19 | return x + | ^ + 20 | } + 21 | +vlib/v/checker/tests/no_heap_struct.vv:23:7: error: `x` cannot be assigned outside `unsafe` blocks as it might refer to an object stored on stack. Consider declaring `Abc` as `[heap]`. + 21 | + 22 | fn h(x &Abc) &Abc { + 23 | y := x + | ^ + 24 | return y + 25 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.vv b/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.vv new file mode 100644 index 0000000..ce1d474 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_heap_struct.vv @@ -0,0 +1,25 @@ +struct Abc { +mut: + n int +} + +struct St { +mut: + a &Abc +} + +fn f(x &Abc) St { + s := St{ + a: x + } + return s +} + +fn g(mut x Abc) &Abc { + return x +} + +fn h(x &Abc) &Abc { + y := x + return y +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.out b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.out new file mode 100644 index 0000000..e01c3a7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/no_interface_instantiation_a.vv:4:9: error: cannot instantiate interface `Speaker` + 2 | + 3 | fn main() { + 4 | _ = Speaker{} + | ~~~~~~~~~ + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.vv b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.vv new file mode 100644 index 0000000..1d98644 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_a.vv @@ -0,0 +1,5 @@ +interface Speaker {} + +fn main() { + _ = Speaker{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.out b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.out new file mode 100644 index 0000000..0a8f1b9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/no_interface_instantiation_b.vv:6:5: error: expected 1 arguments, but got 0 + 4 | + 5 | fn main() { + 6 | my_fn() + | ~~~~~~~ + 7 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.vv b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.vv new file mode 100644 index 0000000..4c73538 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_b.vv @@ -0,0 +1,7 @@ +interface Speaker {} + +fn my_fn(s Speaker) {} + +fn main() { + my_fn() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.out b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.out new file mode 100644 index 0000000..11f0568 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/no_interface_instantiation_c.vv:9:9: error: cannot instantiate interface `Speaker` + 7 | fn main() { + 8 | my_fn( + 9 | speak: 1 + | ~~~~~~~~ + 10 | ) + 11 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.vv b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.vv new file mode 100644 index 0000000..0eb6eec --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_instantiation_c.vv @@ -0,0 +1,11 @@ +interface Speaker { + speak() +} + +fn my_fn(s Speaker) {} + +fn main() { + my_fn( + speak: 1 + ) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_str.out b/v_windows/v/old/vlib/v/checker/tests/no_interface_str.out new file mode 100644 index 0000000..37b33f2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_str.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/no_interface_str.vv:18:12: error: interface `Animal` does not have a .str() method. Use typeof() instead + 16 | fn moin() { + 17 | a := get_animal() + 18 | println(a.str()) + | ~~~~~ + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/no_interface_str.vv b/v_windows/v/old/vlib/v/checker/tests/no_interface_str.vv new file mode 100644 index 0000000..b0da84a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_interface_str.vv @@ -0,0 +1,19 @@ +interface Animal { + speak() +} + +struct Cow { +} + +fn (c Cow)speak() { + println('moo') +} + +fn get_animal() Animal { + return Cow{} +} + +fn moin() { + a := get_animal() + println(a.str()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_main_mod.out b/v_windows/v/old/vlib/v/checker/tests/no_main_mod.out new file mode 100644 index 0000000..549575d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_main_mod.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/no_main_mod.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) + 1 | module a + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/no_main_mod.vv b/v_windows/v/old/vlib/v/checker/tests/no_main_mod.vv new file mode 100644 index 0000000..a32281d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_main_mod.vv @@ -0,0 +1 @@ +module a diff --git a/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.out b/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.out new file mode 100644 index 0000000..5b0d71e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/no_main_println_err.vv:1:5: error: expected 1 arguments, but got 0 + 1 | println() + | ~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.vv b/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.vv new file mode 100644 index 0000000..2ac13fb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_main_println_err.vv @@ -0,0 +1 @@ + println() diff --git a/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.out b/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.out new file mode 100644 index 0000000..b55e1d4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/no_method_on_interface_propagation.vv:18:5: error: unknown method or field: `Cat.foo` + 16 | a := new_animal('persian') + 17 | if a is Cat { + 18 | a.foo() + | ~~~~~ + 19 | } + 20 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.vv b/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.vv new file mode 100644 index 0000000..a9673df --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_method_on_interface_propagation.vv @@ -0,0 +1,20 @@ +struct Cat { + breed string +} + +interface Animal { + breed string +} + +fn (a Animal) foo() {} + +fn new_animal(breed string) Animal { + return &Cat{breed} +} + +fn test_methods_on_interfaces_dont_exist_on_implementers() { + a := new_animal('persian') + if a is Cat { + a.foo() + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/no_pub_in_main.out b/v_windows/v/old/vlib/v/checker/tests/no_pub_in_main.out new file mode 100644 index 0000000..e1da080 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_pub_in_main.out @@ -0,0 +1,49 @@ +vlib/v/checker/tests/no_pub_in_main.vv:3:1: error: type alias `Integer` in module main cannot be declared public + 1 | module main + 2 | + 3 | pub type Integer = int + | ~~~~~~~~~~~~~~~~ + 4 | + 5 | pub type Float = f32 | f64 +vlib/v/checker/tests/no_pub_in_main.vv:5:1: error: sum type `Float` in module main cannot be declared public + 3 | pub type Integer = int + 4 | + 5 | pub type Float = f32 | f64 + | ~~~~~~~~~~~~~~ + 6 | + 7 | // Buggy ATM +vlib/v/checker/tests/no_pub_in_main.vv:10:1: error: enum `Color` in module main cannot be declared public + 8 | // pub type Fn = fn () int + 9 | + 10 | pub enum Color { + | ~~~~~~~~~~~~~~ + 11 | red + 12 | green +vlib/v/checker/tests/no_pub_in_main.vv:16:1: error: const in module main cannot be declared public + 14 | } + 15 | + 16 | pub const ( + | ~~~~~~~~~ + 17 | w = 'world' + 18 | ) +vlib/v/checker/tests/no_pub_in_main.vv:20:1: error: function `my_fn` in module main cannot be declared public + 18 | ) + 19 | + 20 | pub fn my_fn() int { + | ~~~~~~~~~~~~~~~~~~ + 21 | return 1 + 22 | } +vlib/v/checker/tests/no_pub_in_main.vv:24:1: error: function `main` cannot be declared public + 22 | } + 23 | + 24 | pub fn main() { + | ~~~~~~~~~~~~~ + 25 | println('main') + 26 | } +vlib/v/checker/tests/no_pub_in_main.vv:28:1: error: struct `MyStruct` in module main cannot be declared public + 26 | } + 27 | + 28 | pub struct MyStruct { + | ~~~~~~~~~~~~~~~~~~~ + 29 | field int + 30 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.out b/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.out diff --git a/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.vv b/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.vv new file mode 100644 index 0000000..3b66ce2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/no_warning_for_in_mut_var_unused.vv @@ -0,0 +1,7 @@ +fn main() { + mut arr := [1, 2, 3] + for mut v in arr { + v = 2 + } + println(arr) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.out b/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.out new file mode 100644 index 0000000..a885eb7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/non_lvalue_as_voidptr.vv:5:13: error: expression cannot be passed as `voidptr` + 3 | } + 4 | + 5 | println(add(5, 10)) + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.vv b/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.vv new file mode 100644 index 0000000..55de9f3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/non_lvalue_as_voidptr.vv @@ -0,0 +1,5 @@ +fn add(a voidptr, b voidptr) int { + return int(a) + int(b) +} + +println(add(5, 10)) diff --git a/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.out b/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.out new file mode 100644 index 0000000..7d155d0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.out @@ -0,0 +1,16 @@ +vlib/v/checker/tests/non_matching_functional_args.vv:27:6: error: cannot use `fn (mut Table)` as `fn (Table)` in argument 1 to `sum` + 25 | + 26 | fn main() { + 27 | sum(fn (mut t Table) { + | ~~~~~~~~~~~~~~~~~~ + 28 | t.rename() + 29 | println(t.name) +Details: `main.MyFn`'s expected fn argument: `zzzz` is NOT a pointer, but the passed fn argument: `t` is a pointer +vlib/v/checker/tests/non_matching_functional_args.vv:31:6: error: cannot use `fn (mut Table)` as `fn (Table)` in argument 1 to `sum` + 29 | println(t.name) + 30 | }) + 31 | sum(xxx) + | ~~~ + 32 | sum(yyy) + 33 | } +Details: `main.MyFn`'s expected fn argument: `zzzz` is NOT a pointer, but the passed fn argument: `mytable` is a pointer diff --git a/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.vv b/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.vv new file mode 100644 index 0000000..a0e90ff --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/non_matching_functional_args.vv @@ -0,0 +1,33 @@ +struct Table { +pub mut: + name string +} + +type MyFn = fn (zzzz Table) + +fn (mut t Table) rename() { + t.name = 'abc' +} + +fn yyy(t Table) { + println(t.name) +} + +fn xxx(mut mytable Table) { + mytable.rename() + println(mytable.name) +} + +fn sum(myfn MyFn) { + mut t := Table{} + myfn(t) +} + +fn main() { + sum(fn (mut t Table) { + t.rename() + println(t.name) + }) + sum(xxx) + sum(yyy) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.out b/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.out new file mode 100644 index 0000000..0d0ba86 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.out @@ -0,0 +1,75 @@ +vlib/v/checker/tests/none_type_cast_err.vv:2:7: error: cannot cast `none` to `string` + 1 | fn main() { + 2 | _ := string(none) + | ~~~~~~~~~~~~ + 3 | _ := int(none) + 4 | _ := i8(none) +vlib/v/checker/tests/none_type_cast_err.vv:3:7: error: cannot cast `none` to `int` + 1 | fn main() { + 2 | _ := string(none) + 3 | _ := int(none) + | ~~~~~~~~~ + 4 | _ := i8(none) + 5 | _ := i16(none) +vlib/v/checker/tests/none_type_cast_err.vv:4:7: error: cannot cast `none` to `i8` + 2 | _ := string(none) + 3 | _ := int(none) + 4 | _ := i8(none) + | ~~~~~~~~ + 5 | _ := i16(none) + 6 | _ := i64(none) +vlib/v/checker/tests/none_type_cast_err.vv:5:7: error: cannot cast `none` to `i16` + 3 | _ := int(none) + 4 | _ := i8(none) + 5 | _ := i16(none) + | ~~~~~~~~~ + 6 | _ := i64(none) + 7 | _ := u16(none) +vlib/v/checker/tests/none_type_cast_err.vv:6:7: error: cannot cast `none` to `i64` + 4 | _ := i8(none) + 5 | _ := i16(none) + 6 | _ := i64(none) + | ~~~~~~~~~ + 7 | _ := u16(none) + 8 | _ := u32(none) +vlib/v/checker/tests/none_type_cast_err.vv:7:7: error: cannot cast `none` to `u16` + 5 | _ := i16(none) + 6 | _ := i64(none) + 7 | _ := u16(none) + | ~~~~~~~~~ + 8 | _ := u32(none) + 9 | _ := u64(none) +vlib/v/checker/tests/none_type_cast_err.vv:8:7: error: cannot cast `none` to `u32` + 6 | _ := i64(none) + 7 | _ := u16(none) + 8 | _ := u32(none) + | ~~~~~~~~~ + 9 | _ := u64(none) + 10 | _ := rune(none) +vlib/v/checker/tests/none_type_cast_err.vv:9:7: error: cannot cast `none` to `u64` + 7 | _ := u16(none) + 8 | _ := u32(none) + 9 | _ := u64(none) + | ~~~~~~~~~ + 10 | _ := rune(none) + 11 | _ := f32(none) +vlib/v/checker/tests/none_type_cast_err.vv:10:7: error: cannot cast `none` to `rune` + 8 | _ := u32(none) + 9 | _ := u64(none) + 10 | _ := rune(none) + | ~~~~~~~~~~ + 11 | _ := f32(none) + 12 | _ := f64(none) +vlib/v/checker/tests/none_type_cast_err.vv:11:7: error: cannot cast `none` to `f32` + 9 | _ := u64(none) + 10 | _ := rune(none) + 11 | _ := f32(none) + | ~~~~~~~~~ + 12 | _ := f64(none) + 13 | } +vlib/v/checker/tests/none_type_cast_err.vv:12:7: error: cannot cast `none` to `f64` + 10 | _ := rune(none) + 11 | _ := f32(none) + 12 | _ := f64(none) + | ~~~~~~~~~ + 13 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.vv b/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.vv new file mode 100644 index 0000000..953b369 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/none_type_cast_err.vv @@ -0,0 +1,13 @@ +fn main() { + _ := string(none) + _ := int(none) + _ := i8(none) + _ := i16(none) + _ := i64(none) + _ := u16(none) + _ := u32(none) + _ := u64(none) + _ := rune(none) + _ := f32(none) + _ := f64(none) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out new file mode 100644 index 0000000..02fbccc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop + 2 | fn another() { + 3 | eprintln(@FN) + 4 | for { + | ^ + 5 | break + 6 | } +vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: error: unreachable code after a [noreturn] call + 16 | eprintln('start') + 17 | abc() + 18 | eprintln('done') + | ~~~~~~~~~~~~~~~~ + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv new file mode 100644 index 0000000..84f413c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv @@ -0,0 +1,19 @@ +[noreturn] +fn another() { + eprintln(@FN) + for { + break + } +} + +[noreturn] +fn abc() { + eprintln(@FN) + another() +} + +fn main() { + eprintln('start') + abc() + eprintln('done') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.out b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.out new file mode 100644 index 0000000..d8c3279 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.out @@ -0,0 +1,19 @@ +vlib/v/checker/tests/noreturn_with_return.vv:2:1: error: [noreturn] functions cannot use return statements + 1 | [noreturn] + 2 | fn another() { + | ~~~~~~~~~~~~ + 3 | eprintln(@FN) + 4 | // for{} +vlib/v/checker/tests/noreturn_with_return.vv:6:2: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop + 4 | // for{} + 5 | // exit(0) + 6 | return + | ~~~~~~ + 7 | } + 8 | +vlib/v/checker/tests/noreturn_with_return.vv:18:2: error: unreachable code after a [noreturn] call + 16 | eprintln('start') + 17 | abc() + 18 | eprintln('done') + | ~~~~~~~~~~~~~~~~ + 19 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.vv b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.vv new file mode 100644 index 0000000..c5fdaa7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_with_return.vv @@ -0,0 +1,19 @@ +[noreturn] +fn another() { + eprintln(@FN) + // for{} + // exit(0) + return +} + +[noreturn] +fn abc() { + eprintln(@FN) + another() +} + +fn main() { + eprintln('start') + abc() + eprintln('done') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out b/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out new file mode 100644 index 0000000..6215215 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: error: [noreturn] functions should end with a call to another [noreturn] function, or with an infinite `for {}` loop + 1 | [noreturn] + 2 | fn another() { + 3 | eprintln(@FN) + | ~~~~~~~~~~~~~ + 4 | } + 5 | +vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: error: unreachable code after a [noreturn] call + 13 | eprintln('start') + 14 | abc() + 15 | eprintln('done') + | ~~~~~~~~~~~~~~~~ + 16 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv b/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv new file mode 100644 index 0000000..d764d7d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv @@ -0,0 +1,16 @@ +[noreturn] +fn another() { + eprintln(@FN) +} + +[noreturn] +fn abc() { + eprintln(@FN) + another() +} + +fn main() { + eprintln('start') + abc() + eprintln('done') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.out new file mode 100644 index 0000000..29eac2d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/oct_lit_without_digit_err.vv:2:14: error: number part of this octal is not provided + 1 | fn main() { + 2 | println(0o) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.vv new file mode 100644 index 0000000..195a010 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oct_lit_without_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0o) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.out b/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.out new file mode 100644 index 0000000..0dbccf9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/oct_lit_wrong_digit_err.vv:2:18: error: this octal number has unsuitable digit `8` + 1 | fn main() { + 2 | println(0o1118) + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.vv b/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.vv new file mode 100644 index 0000000..235e1a9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oct_lit_wrong_digit_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0o1118) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.out b/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.out new file mode 100644 index 0000000..3e47b49 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.out @@ -0,0 +1,168 @@ +vlib/v/checker/tests/optional_fn_err.vv:13:16: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 11 | + 12 | const ( + 13 | const_value = bar(0) + | ~~~~~~ + 14 | ) + 15 | +vlib/v/checker/tests/optional_fn_err.vv:19:14: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 17 | f fn (int) + 18 | mut: + 19 | value int = bar(0) + | ~~~~~~ + 20 | opt ?int = bar(0) + 21 | } +vlib/v/checker/tests/optional_fn_err.vv:33:2: error: foo() returns an option, so it should have either an `or {}` block, or `?` at the end + 31 | fn main() { + 32 | // call fn + 33 | foo() + | ~~~~~ + 34 | _ := bar(0) + 35 | println(twice(bar(0))) +vlib/v/checker/tests/optional_fn_err.vv:34:7: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 32 | // call fn + 33 | foo() + 34 | _ := bar(0) + | ~~~~~~ + 35 | println(twice(bar(0))) + 36 | +vlib/v/checker/tests/optional_fn_err.vv:35:16: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 33 | foo() + 34 | _ := bar(0) + 35 | println(twice(bar(0))) + | ~~~~~~ + 36 | + 37 | // anon fn +vlib/v/checker/tests/optional_fn_err.vv:38:16: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 36 | + 37 | // anon fn + 38 | fn (_ int) {}(bar(0)) + | ~~~~~~ + 39 | + 40 | // assert +vlib/v/checker/tests/optional_fn_err.vv:41:9: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 39 | + 40 | // assert + 41 | assert bar(true) + | ~~~~~~~~~ + 42 | + 43 | // struct +vlib/v/checker/tests/optional_fn_err.vv:46:10: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 44 | mut v := Data{ + 45 | f: fn (_ int) {}, + 46 | value: bar(0), + | ~~~~~~ + 47 | opt: bar(0), + 48 | } +vlib/v/checker/tests/optional_fn_err.vv:49:8: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 47 | opt: bar(0), + 48 | } + 49 | v.add(bar(0)) // call method + | ~~~~~~ + 50 | v.f(bar(0)) // call fn field + 51 | +vlib/v/checker/tests/optional_fn_err.vv:50:6: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 48 | } + 49 | v.add(bar(0)) // call method + 50 | v.f(bar(0)) // call fn field + | ~~~~~~ + 51 | + 52 | // array +vlib/v/checker/tests/optional_fn_err.vv:54:9: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 52 | // array + 53 | mut arr := [1, 2] + 54 | arr << bar(0) + | ~~~~~~ + 55 | // init + 56 | _ := [bar(0)] +vlib/v/checker/tests/optional_fn_err.vv:56:8: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 54 | arr << bar(0) + 55 | // init + 56 | _ := [bar(0)] + | ~~~~~~ + 57 | _ := []int{init: bar(0)} + 58 | _ := [bar(0)]! +vlib/v/checker/tests/optional_fn_err.vv:57:19: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 55 | // init + 56 | _ := [bar(0)] + 57 | _ := []int{init: bar(0)} + | ~~~~~~ + 58 | _ := [bar(0)]! + 59 | _ := [1]int{init: bar(0)} +vlib/v/checker/tests/optional_fn_err.vv:58:8: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 56 | _ := [bar(0)] + 57 | _ := []int{init: bar(0)} + 58 | _ := [bar(0)]! + | ~~~~~~ + 59 | _ := [1]int{init: bar(0)} + 60 | // index +vlib/v/checker/tests/optional_fn_err.vv:61:13: error: cannot use optional as index (array type `[]int`) + 59 | _ := [1]int{init: bar(0)} + 60 | // index + 61 | println(arr[bar(0)]) + | ~~~~~~~~ + 62 | // array builtin methods + 63 | arr.insert(0, bar(0)) +vlib/v/checker/tests/optional_fn_err.vv:63:16: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 61 | println(arr[bar(0)]) + 62 | // array builtin methods + 63 | arr.insert(0, bar(0)) + | ~~~~~~ + 64 | arr.prepend(bar(0)) + 65 | arr.contains(bar(0)) +vlib/v/checker/tests/optional_fn_err.vv:64:14: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 62 | // array builtin methods + 63 | arr.insert(0, bar(0)) + 64 | arr.prepend(bar(0)) + | ~~~~~~ + 65 | arr.contains(bar(0)) + 66 | arr.index(bar(0)) +vlib/v/checker/tests/optional_fn_err.vv:65:15: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 63 | arr.insert(0, bar(0)) + 64 | arr.prepend(bar(0)) + 65 | arr.contains(bar(0)) + | ~~~~~~ + 66 | arr.index(bar(0)) + 67 | println(arr.map(bar(0))) +vlib/v/checker/tests/optional_fn_err.vv:66:12: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 64 | arr.prepend(bar(0)) + 65 | arr.contains(bar(0)) + 66 | arr.index(bar(0)) + | ~~~~~~ + 67 | println(arr.map(bar(0))) + 68 | println(arr.filter(bar(true))) +vlib/v/checker/tests/optional_fn_err.vv:67:18: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 65 | arr.contains(bar(0)) + 66 | arr.index(bar(0)) + 67 | println(arr.map(bar(0))) + | ~~~~~~ + 68 | println(arr.filter(bar(true))) + 69 | println(arr.any(bar(true))) +vlib/v/checker/tests/optional_fn_err.vv:68:21: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 66 | arr.index(bar(0)) + 67 | println(arr.map(bar(0))) + 68 | println(arr.filter(bar(true))) + | ~~~~~~~~~ + 69 | println(arr.any(bar(true))) + 70 | println(arr.all(bar(true))) +vlib/v/checker/tests/optional_fn_err.vv:69:18: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 67 | println(arr.map(bar(0))) + 68 | println(arr.filter(bar(true))) + 69 | println(arr.any(bar(true))) + | ~~~~~~~~~ + 70 | println(arr.all(bar(true))) + 71 | +vlib/v/checker/tests/optional_fn_err.vv:70:18: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 68 | println(arr.filter(bar(true))) + 69 | println(arr.any(bar(true))) + 70 | println(arr.all(bar(true))) + | ~~~~~~~~~ + 71 | + 72 | match bar(0) { +vlib/v/checker/tests/optional_fn_err.vv:72:8: error: bar() returns an option, so it should have either an `or {}` block, or `?` at the end + 70 | println(arr.all(bar(true))) + 71 | + 72 | match bar(0) { + | ~~~~~~ + 73 | 0 { } + 74 | else { } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.vv b/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.vv new file mode 100644 index 0000000..b3d82d1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_fn_err.vv @@ -0,0 +1,76 @@ + +// use optional without ? or an or block in places where it is not allowed + +fn foo() ? { + println('foo is called') +} + +fn bar<T>(v T) ?T { + return none +} + +const ( + const_value = bar(0) +) + +struct Data { + f fn (int) +mut: + value int = bar(0) + opt ?int = bar(0) +} + +fn (mut v Data) add(n int) { + v.value += n +} + +fn twice(n int) int { + return n * 2 +} + +fn main() { + // call fn + foo() + _ := bar(0) + println(twice(bar(0))) + + // anon fn + fn (_ int) {}(bar(0)) + + // assert + assert bar(true) + + // struct + mut v := Data{ + f: fn (_ int) {}, + value: bar(0), + opt: bar(0), + } + v.add(bar(0)) // call method + v.f(bar(0)) // call fn field + + // array + mut arr := [1, 2] + arr << bar(0) + // init + _ := [bar(0)] + _ := []int{init: bar(0)} + _ := [bar(0)]! + _ := [1]int{init: bar(0)} + // index + println(arr[bar(0)]) + // array builtin methods + arr.insert(0, bar(0)) + arr.prepend(bar(0)) + arr.contains(bar(0)) + arr.index(bar(0)) + println(arr.map(bar(0))) + println(arr.filter(bar(true))) + println(arr.any(bar(true))) + println(arr.all(bar(true))) + + match bar(0) { + 0 { } + else { } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.out new file mode 100644 index 0000000..8f13586 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/optional_in_println_mismatch.vv:6:23: error: wrong return type `string` in the `or {}` block, expected `int` + 4 | + 5 | fn main() { + 6 | println(funcy() or { '' }) + | ~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.vv new file mode 100644 index 0000000..fd3d067 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_in_println_mismatch.vv @@ -0,0 +1,7 @@ +fn funcy() ?int { + return none +} + +fn main() { + println(funcy() or { '' }) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.out new file mode 100644 index 0000000..64fe585 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/optional_interface_mismatch.vv:11:9: error: mismatched types `?MObject` and `string` + 9 | + 10 | fn give_string(line string) ?MObject { + 11 | return if true { 'string' } else { 'string' } + | ~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.vv new file mode 100644 index 0000000..1138fa3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_interface_mismatch.vv @@ -0,0 +1,12 @@ +fn main() { + le_string := give_string('string') or { return } + le_string.unimplemented() +} + +interface MObject { + unimplemented() string +} + +fn give_string(line string) ?MObject { + return if true { 'string' } else { 'string' } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.out new file mode 100644 index 0000000..d48fd8f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/optional_or_block_mismatch.vv:10:18: error: wrong return type `Bar` in the `or {}` block, expected `&Bar` + 8 | + 9 | fn main() { + 10 | x := foo() or { Bar{} } + | ~~~~~ + 11 | println(x) + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.vv new file mode 100644 index 0000000..849a7aa --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_mismatch.vv @@ -0,0 +1,12 @@ +module main + +struct Bar {} + +fn foo() ?&Bar { + return none +} + +fn main() { + x := foo() or { Bar{} } + println(x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.out b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.out new file mode 100644 index 0000000..ed608c3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/optional_or_block_none_err.vv:18:3: error: wrong return type `none` in the `or {}` block, expected `Animal` + 16 | fn main() { + 17 | mut dog := new_animal(9) or { + 18 | none + | ~~~~ + 19 | } + 20 | diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.vv b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.vv new file mode 100644 index 0000000..c1970a3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_none_err.vv @@ -0,0 +1,22 @@ +module main + +struct Animal { + mut: + height byte +} + +fn new_animal(height byte) ?Animal { + if height < 10 { + return error('Too small to be an animal!') + } + + return Animal{ height: height } +} + +fn main() { + mut dog := new_animal(9) or { + none + } + + println(dog) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.out b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.out new file mode 100644 index 0000000..0cd1b38 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.vv:13:3: error: the default expression type in the `or` block should be `string`, instead you gave a value of type `int literal` + 11 | // must be of the same type of the return + 12 | // type of the `test_optional` function + 13 | 123 + | ~~~ + 14 | // 'I break things' + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.vv b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.vv new file mode 100644 index 0000000..9935bb7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_or_block_returns_value_of_incompatible_type.vv @@ -0,0 +1,16 @@ +fn test_optional(fail bool) ?string { + if fail { + return error('false') + } + return 'fff' +} + +fn main() { + // a := test_optional(false) or { println(err) } + test_optional(true) or { + // must be of the same type of the return + // type of the `test_optional` function + 123 + // 'I break things' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.out b/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.out new file mode 100644 index 0000000..f113a89 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/optional_propagate_nested.vv:10:19: error: to propagate the optional call, `xx_prop` must return an optional + 8 | + 9 | fn xx_prop() string { + 10 | s := ret(raise() ?) + | ^ + 11 | return s + 12 | } +vlib/v/checker/tests/optional_propagate_nested.vv:28:22: error: to propagate the optional call, `aa_propagate` must return an optional + 26 | + 27 | fn (mut s St) aa_propagate() { + 28 | f := retf(s.raise() ?) + | ^ + 29 | s.z = 7.5 + 30 | println(f) diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.vv b/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.vv new file mode 100644 index 0000000..d00ef53 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_propagate_nested.vv @@ -0,0 +1,31 @@ +fn ret(s string) string { + return s +} + +fn raise() ?string { + return none +} + +fn xx_prop() string { + s := ret(raise() ?) + return s +} + +struct St { +mut: + z f64 +} + +fn (mut s St) raise() ?f64 { + return error('some error') +} + +fn retf(f f64) f64 { + return f +} + +fn (mut s St) aa_propagate() { + f := retf(s.raise() ?) + s.z = 7.5 + println(f) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.out b/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.out new file mode 100644 index 0000000..6550765 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/optional_type_call_err.vv:4:5: error: optional type cannot be called directly + 2 | + 3 | fn main() { + 4 | os.ls('.').filter(it.ends_with('.v')) or { return } + | ~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.vv b/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.vv new file mode 100644 index 0000000..1b0cfa0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/optional_type_call_err.vv @@ -0,0 +1,5 @@ +import os + +fn main() { + os.ls('.').filter(it.ends_with('.v')) or { return } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/or_err.out b/v_windows/v/old/vlib/v/checker/tests/or_err.out new file mode 100644 index 0000000..5aaf5f2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/or_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/or_err.vv:4:10: error: last statement in the `or {}` block should be an expression of type `&int` or exit parent scope + 2 | return none + 3 | } + 4 | a := f() or { + | ~~~~ + 5 | {} + 6 | } +vlib/v/checker/tests/or_err.vv:11:2: error: wrong return type `rune` in the `or {}` block, expected `&int` + 9 | } + 10 | _ = f() or { + 11 | `.` + | ~~~ + 12 | } + 13 | diff --git a/v_windows/v/old/vlib/v/checker/tests/or_err.vv b/v_windows/v/old/vlib/v/checker/tests/or_err.vv new file mode 100644 index 0000000..035b87e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/or_err.vv @@ -0,0 +1,13 @@ +fn f() ?&int { + return none +} +a := f() or { + {} +} +_ = f() or { + a +} +_ = f() or { + `.` +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.out new file mode 100644 index 0000000..c84faa5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/or_expr_types_mismatch.vv:3:19: error: wrong return type `none` in the `or {}` block, expected `string` + 1 | fn get_map() ?string { + 2 | m := map{1: 'a', 2: 'b'} + 3 | return m[1] or { none } + | ~~~~ + 4 | } + 5 | +vlib/v/checker/tests/or_expr_types_mismatch.vv:8:19: error: wrong return type `none` in the `or {}` block, expected `int` + 6 | fn get_array() ?int { + 7 | a := [1, 2, 3] + 8 | return a[4] or { none } + | ~~~~ + 9 | } + 10 | diff --git a/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.vv new file mode 100644 index 0000000..1b557c3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/or_expr_types_mismatch.vv @@ -0,0 +1,17 @@ +fn get_map() ?string { + m := map{1: 'a', 2: 'b'} + return m[1] or { none } +} + +fn get_array() ?int { + a := [1, 2, 3] + return a[4] or { none } +} + +fn main() { + map_result := get_map() or { return } + println(map_result) + + array_result := get_array() or { return } + println(array_result) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.out b/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.out new file mode 100644 index 0000000..26e5131 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/orm_empty_struct.vv:9:15: error: V orm: select: empty fields in `Person` + 7 | db := sqlite.connect(':memory:')? + 8 | _ := sql db { + 9 | select from Person + | ~~~~~~ + 10 | } + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.vv b/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.vv new file mode 100644 index 0000000..ba7b4e7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/orm_empty_struct.vv @@ -0,0 +1,11 @@ +import sqlite + +struct Person { +} + +fn main() { + db := sqlite.connect(':memory:')? + _ := sql db { + select from Person + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/os_prefix.out b/v_windows/v/old/vlib/v/checker/tests/os_prefix.out new file mode 100644 index 0000000..4b87a6f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/os_prefix.out @@ -0,0 +1,18 @@ +vlib/v/checker/tests/os_prefix.vv:1:8: warning: module 'os' is imported but never used + 1 | import os + | ~~ + 2 | + 3 | fn main() { +vlib/v/checker/tests/os_prefix.vv:5:12: error: unknown function: execute + 3 | fn main() { + 4 | cmd := "ls" + 5 | result := execute(cmd) + | ~~~~~~~~~~~~ + 6 | println(result) + 7 | } +vlib/v/checker/tests/os_prefix.vv:6:2: error: `println` can not print void expressions + 4 | cmd := "ls" + 5 | result := execute(cmd) + 6 | println(result) + | ~~~~~~~~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/os_prefix.vv b/v_windows/v/old/vlib/v/checker/tests/os_prefix.vv new file mode 100644 index 0000000..b9342d3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/os_prefix.vv @@ -0,0 +1,7 @@ +import os + +fn main() { + cmd := "ls" + result := execute(cmd) + println(result) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.out b/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.out new file mode 100644 index 0000000..b26b097 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/overflow_int_err.vv:4:7: error: overflow in implicit type `int`, use explicit type casting instead + 2 | a := -2147483648 + 3 | b := 2147483647 + 4 | c := -2147483649 + | ~~~~~~~~~~~ + 5 | d := 2147483648 + 6 | println(a) +vlib/v/checker/tests/overflow_int_err.vv:5:7: error: overflow in implicit type `int`, use explicit type casting instead + 3 | b := 2147483647 + 4 | c := -2147483649 + 5 | d := 2147483648 + | ~~~~~~~~~~ + 6 | println(a) + 7 | println(b) diff --git a/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.vv b/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.vv new file mode 100644 index 0000000..0537ae3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/overflow_int_err.vv @@ -0,0 +1,10 @@ +fn main() { + a := -2147483648 + b := 2147483647 + c := -2147483649 + d := 2147483648 + println(a) + println(b) + println(c) + println(d) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/overload_return_type.out b/v_windows/v/old/vlib/v/checker/tests/overload_return_type.out new file mode 100644 index 0000000..547519c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/overload_return_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/overload_return_type.vv:14:11: error: cannot assign to `two`: expected `Point`, not `int` + 12 | mut one := Point {x:1, y:2} + 13 | mut two := Point {x:5, y:1} + 14 | two = one + two + | ~~~~~~~~~ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/overload_return_type.vv b/v_windows/v/old/vlib/v/checker/tests/overload_return_type.vv new file mode 100644 index 0000000..f9ae2f1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/overload_return_type.vv @@ -0,0 +1,15 @@ +struct Point { + mut: + x int + y int +} + +fn (a Point) +(b Point) int { + return a.x + b.x +} + +fn main() { + mut one := Point {x:1, y:2} + mut two := Point {x:5, y:1} + two = one + two +} diff --git a/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.out b/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.out new file mode 100644 index 0000000..30a9622 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.out @@ -0,0 +1,8 @@ +vlib/v/checker/tests/oversized_int_lit.vv:1:8: error: integer literal 18446744073709551616 overflows int + 1 | assert 18446744073709551616 > 0 + | ~~~~~~~~~~~~~~~~~~~~ + 2 | assert -9223372036854775809 < 0 +vlib/v/checker/tests/oversized_int_lit.vv:2:8: error: integer literal -9223372036854775809 overflows int + 1 | assert 18446744073709551616 > 0 + 2 | assert -9223372036854775809 < 0 + | ~~~~~~~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.vv b/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.vv new file mode 100644 index 0000000..d6e3a27 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/oversized_int_lit.vv @@ -0,0 +1,2 @@ +assert 18446744073709551616 > 0 +assert -9223372036854775809 < 0 diff --git a/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.out b/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.out new file mode 100644 index 0000000..09a0343 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/pass_mut_lit.vv:10:12: error: cannot pass expression as `mut` + 8 | } + 9 | + 10 | modify(mut Box{}, 10) + | ~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.vv b/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.vv new file mode 100644 index 0000000..7d358f9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/pass_mut_lit.vv @@ -0,0 +1,10 @@ +struct Box { +mut: + value int +} + +fn modify(mut box Box, value int) { + box.value = value +} + +modify(mut Box{}, 10) diff --git a/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.out b/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.out new file mode 100644 index 0000000..1acbdb5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.vv:3:31: error: expression cannot be passed as `voidptr` + 1 | import strconv + 2 | + 3 | strconv.v_printf('%02.02f\n', 1.1) + | ~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.vv b/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.vv new file mode 100644 index 0000000..1b3bc39 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/passing_expr_to_fn_expecting_voidptr.vv @@ -0,0 +1,3 @@ +import strconv + +strconv.v_printf('%02.02f\n', 1.1) diff --git a/v_windows/v/old/vlib/v/checker/tests/pointer_ops.out b/v_windows/v/old/vlib/v/checker/tests/pointer_ops.out new file mode 100644 index 0000000..0221116 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/pointer_ops.out @@ -0,0 +1,49 @@ +vlib/v/checker/tests/pointer_ops.vv:5:7: error: `+` cannot be used with `voidptr` + 3 | unsafe { + 4 | mut p := voidptr(0) + 5 | _ = p + 1 + | ^ + 6 | p++ + 7 | p += 3 +vlib/v/checker/tests/pointer_ops.vv:6:4: error: invalid operation: ++ (non-numeric type `voidptr`) + 4 | mut p := voidptr(0) + 5 | _ = p + 1 + 6 | p++ + | ~~ + 7 | p += 3 + 8 | _ = p - 1 +vlib/v/checker/tests/pointer_ops.vv:7:3: error: operator `+=` not defined on left operand type `voidptr` + 5 | _ = p + 1 + 6 | p++ + 7 | p += 3 + | ^ + 8 | _ = p - 1 + 9 | p-- +vlib/v/checker/tests/pointer_ops.vv:8:7: error: `-` cannot be used with `voidptr` + 6 | p++ + 7 | p += 3 + 8 | _ = p - 1 + | ^ + 9 | p-- + 10 | p -= 3 +vlib/v/checker/tests/pointer_ops.vv:9:4: error: invalid operation: -- (non-numeric type `voidptr`) + 7 | p += 3 + 8 | _ = p - 1 + 9 | p-- + | ~~ + 10 | p -= 3 + 11 | _ = p[3] +vlib/v/checker/tests/pointer_ops.vv:10:3: error: operator `-=` not defined on left operand type `voidptr` + 8 | _ = p - 1 + 9 | p-- + 10 | p -= 3 + | ^ + 11 | _ = p[3] + 12 | } +vlib/v/checker/tests/pointer_ops.vv:11:8: error: type `voidptr` does not support indexing + 9 | p-- + 10 | p -= 3 + 11 | _ = p[3] + | ~~~ + 12 | } + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/pointer_ops.vv b/v_windows/v/old/vlib/v/checker/tests/pointer_ops.vv new file mode 100644 index 0000000..e93161b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/pointer_ops.vv @@ -0,0 +1,13 @@ +// void* arithmetic is not allowed in MSVC, so ban it +fn test_voidptr() { + unsafe { + mut p := voidptr(0) + _ = p + 1 + p++ + p += 3 + _ = p - 1 + p-- + p -= 3 + _ = p[3] + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/prefix_err.out b/v_windows/v/old/vlib/v/checker/tests/prefix_err.out new file mode 100644 index 0000000..528ddd0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/prefix_err.out @@ -0,0 +1,95 @@ +vlib/v/checker/tests/prefix_err.vv:5:6: error: cannot take the address of true + 3 | } + 4 | + 5 | b := &true + | ^ + 6 | _ := &get() + 7 | _ := &(get()) +vlib/v/checker/tests/prefix_err.vv:6:6: error: cannot take the address of get() + 4 | + 5 | b := &true + 6 | _ := &get() + | ^ + 7 | _ := &(get()) + 8 | _ := &(get() + 1) +vlib/v/checker/tests/prefix_err.vv:7:6: error: cannot take the address of get() + 5 | b := &true + 6 | _ := &get() + 7 | _ := &(get()) + | ^ + 8 | _ := &(get() + 1) + 9 | _ := &10 +vlib/v/checker/tests/prefix_err.vv:8:6: error: cannot take the address of get() + 1 + 6 | _ := &get() + 7 | _ := &(get()) + 8 | _ := &(get() + 1) + | ^ + 9 | _ := &10 + 10 | _ := &"Hi" +vlib/v/checker/tests/prefix_err.vv:9:6: error: cannot take the address of 10 + 7 | _ := &(get()) + 8 | _ := &(get() + 1) + 9 | _ := &10 + | ^ + 10 | _ := &"Hi" + 11 | _ := &"${b}" +vlib/v/checker/tests/prefix_err.vv:10:6: error: cannot take the address of 'Hi' + 8 | _ := &(get() + 1) + 9 | _ := &10 + 10 | _ := &"Hi" + | ^ + 11 | _ := &"${b}" + 12 | _ := &`c` +vlib/v/checker/tests/prefix_err.vv:11:6: error: cannot take the address of '$b' + 9 | _ := &10 + 10 | _ := &"Hi" + 11 | _ := &"${b}" + | ^ + 12 | _ := &`c` + 13 | _ := &1.2 +vlib/v/checker/tests/prefix_err.vv:12:6: error: cannot take the address of `c` + 10 | _ := &"Hi" + 11 | _ := &"${b}" + 12 | _ := &`c` + | ^ + 13 | _ := &1.2 + 14 | _ := &(1 + 2) +vlib/v/checker/tests/prefix_err.vv:13:6: error: cannot take the address of 1.2 + 11 | _ := &"${b}" + 12 | _ := &`c` + 13 | _ := &1.2 + | ^ + 14 | _ := &(1 + 2) + 15 | _ := 12.3 +vlib/v/checker/tests/prefix_err.vv:14:6: error: cannot take the address of 1 + 2 + 12 | _ := &`c` + 13 | _ := &1.2 + 14 | _ := &(1 + 2) + | ^ + 15 | _ := 12.3 + 16 | +vlib/v/checker/tests/prefix_err.vv:18:5: error: invalid indirect of `int` + 16 | + 17 | a := 1 + 18 | _ = *a + | ^ + 19 | a <- 4 + 20 | +vlib/v/checker/tests/prefix_err.vv:19:1: error: cannot push on non-channel `int` + 17 | a := 1 + 18 | _ = *a + 19 | a <- 4 + | ^ + 20 | + 21 | _ = ~true +vlib/v/checker/tests/prefix_err.vv:21:5: error: operator ~ only defined on int types + 19 | a <- 4 + 20 | + 21 | _ = ~true + | ^ + 22 | _ = !4 +vlib/v/checker/tests/prefix_err.vv:22:5: error: ! operator can only be used with bool types + 20 | + 21 | _ = ~true + 22 | _ = !4 + | ^ diff --git a/v_windows/v/old/vlib/v/checker/tests/prefix_err.vv b/v_windows/v/old/vlib/v/checker/tests/prefix_err.vv new file mode 100644 index 0000000..6472a0b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/prefix_err.vv @@ -0,0 +1,22 @@ +fn get() int { + return 1 +} + +b := &true +_ := &get() +_ := &(get()) +_ := &(get() + 1) +_ := &10 +_ := &"Hi" +_ := &"${b}" +_ := &`c` +_ := &1.2 +_ := &(1 + 2) +_ := 12.3 + +a := 1 +_ = *a +a <- 4 + +_ = ~true +_ = !4 diff --git a/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.out b/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.out new file mode 100644 index 0000000..575fc0f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/prefix_expr_decl_assign_err.vv:2:5: error: non-name on the left side of `:=` + 1 | fn main() { + 2 | &a := 12 + | ^ + 3 | (*d) := 14 + 4 | } +vlib/v/checker/tests/prefix_expr_decl_assign_err.vv:3:5: error: non-name `(*d)` on left side of `:=` + 1 | fn main() { + 2 | &a := 12 + 3 | (*d) := 14 + | ~~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.vv b/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.vv new file mode 100644 index 0000000..3cfff48 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/prefix_expr_decl_assign_err.vv @@ -0,0 +1,4 @@ +fn main() { + &a := 12 + (*d) := 14 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/print_char.out b/v_windows/v/old/vlib/v/checker/tests/print_char.out new file mode 100644 index 0000000..055ec11 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/print_char.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/print_char.vv:1:1: error: `println` cannot print type `char` directly, print its address or cast it to an integer instead + 1 | println(char(91)) + | ~~~~~~~~~~~~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/print_char.vv b/v_windows/v/old/vlib/v/checker/tests/print_char.vv new file mode 100644 index 0000000..9ddba8a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/print_char.vv @@ -0,0 +1 @@ +println(char(91)) diff --git a/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.out b/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.out new file mode 100644 index 0000000..674f2a5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/println_can_not_print_void_expressions.vv:3:2: error: `print` can not print void expressions + 1 | fn blabla() {} + 2 | fn main() { + 3 | print(blabla()) + | ~~~~~~~~~~~~~~~ + 4 | println(blabla()) + 5 | eprint(blabla()) +vlib/v/checker/tests/println_can_not_print_void_expressions.vv:4:2: error: `println` can not print void expressions + 2 | fn main() { + 3 | print(blabla()) + 4 | println(blabla()) + | ~~~~~~~~~~~~~~~~~ + 5 | eprint(blabla()) + 6 | eprintln(blabla()) +vlib/v/checker/tests/println_can_not_print_void_expressions.vv:5:2: error: `eprint` can not print void expressions + 3 | print(blabla()) + 4 | println(blabla()) + 5 | eprint(blabla()) + | ~~~~~~~~~~~~~~~~ + 6 | eprintln(blabla()) + 7 | } +vlib/v/checker/tests/println_can_not_print_void_expressions.vv:6:2: error: `eprintln` can not print void expressions + 4 | println(blabla()) + 5 | eprint(blabla()) + 6 | eprintln(blabla()) + | ~~~~~~~~~~~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.vv b/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.vv new file mode 100644 index 0000000..e412697 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/println_can_not_print_void_expressions.vv @@ -0,0 +1,7 @@ +fn blabla() {} +fn main() { + print(blabla()) + println(blabla()) + eprint(blabla()) + eprintln(blabla()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/ptr_assign.out b/v_windows/v/old/vlib/v/checker/tests/ptr_assign.out new file mode 100644 index 0000000..5afa1d2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ptr_assign.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/ptr_assign.vv:3:5: error: cannot assign to `p`: expected `&int`, not `int literal` + 1 | mut v := 43 + 2 | mut p := &v + 3 | p = 4 + | ^ + 4 | _ = p diff --git a/v_windows/v/old/vlib/v/checker/tests/ptr_assign.vv b/v_windows/v/old/vlib/v/checker/tests/ptr_assign.vv new file mode 100644 index 0000000..562f196 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/ptr_assign.vv @@ -0,0 +1,4 @@ +mut v := 43 +mut p := &v +p = 4 +_ = p diff --git a/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.out b/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.out new file mode 100644 index 0000000..667a0d2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.out @@ -0,0 +1,4 @@ +vlib/v/checker/tests/receiver_unknown_type_single_letter.vv:1:7: error: unknown type `Abc` + 1 | fn (p Abc) foo() {} + | ~~~ + 2 | diff --git a/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.vv b/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.vv new file mode 100644 index 0000000..703cf29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/receiver_unknown_type_single_letter.vv @@ -0,0 +1,2 @@ +fn (p Abc) foo() {} + diff --git a/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.out b/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.out new file mode 100644 index 0000000..f3ec2a7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/recursive_interface_err.vv:2:6: error: recursive interface fields are not allowed because they cannot be initialised + 1 | interface Foo { + 2 | foo Foo + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.vv b/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.vv new file mode 100644 index 0000000..74a3dd9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/recursive_interface_err.vv @@ -0,0 +1,3 @@ +interface Foo { + foo Foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.out b/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.out new file mode 100644 index 0000000..846e5b7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/reference_field_must_be_initialized.vv:8:7: error: reference field `Node.next` must be initialized + 6 | + 7 | fn main(){ + 8 | n := Node{ data: 123 } + | ~~~~~~~~~~~~~~~~~ + 9 | eprintln('n.data: $n.data') + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.vv b/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.vv new file mode 100644 index 0000000..a308173 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/reference_field_must_be_initialized.vv @@ -0,0 +1,10 @@ +module main +struct Node { + data int + next &Node +} + +fn main(){ + n := Node{ data: 123 } + eprintln('n.data: $n.data') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/reference_return.out b/v_windows/v/old/vlib/v/checker/tests/reference_return.out new file mode 100644 index 0000000..4c9b3c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/reference_return.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/reference_return.vv:6:9: error: fn `f` expects you to return a reference type `&Aa`, but you are returning `Aa` instead + 4 | + 5 | fn f() &Aa { + 6 | return Aa{ + | ~~~ + 7 | a: 1 + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/reference_return.vv b/v_windows/v/old/vlib/v/checker/tests/reference_return.vv new file mode 100644 index 0000000..42c1e5a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/reference_return.vv @@ -0,0 +1,14 @@ +struct Aa { + a int +} + +fn f() &Aa { + return Aa{ + a: 1 + } +} + +fn main() { + x := f() + println(x.a) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.out new file mode 100644 index 0000000..8182870 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.out @@ -0,0 +1,34 @@ +vlib/v/checker/tests/return_count_mismatch.vv:2:9: error: unexpected argument, current function does not return anything + 1 | fn v() { + 2 | return 3 + | ^ + 3 | } + 4 | +vlib/v/checker/tests/return_count_mismatch.vv:7:2: error: expected `int` argument + 5 | fn f() int + 6 | { + 7 | return + | ~~~~~~ + 8 | } + 9 | +vlib/v/checker/tests/return_count_mismatch.vv:12:2: error: expected `(int, string)` arguments + 10 | fn g() (int, string) + 11 | { + 12 | return + | ~~~~~~ + 13 | } + 14 | +vlib/v/checker/tests/return_count_mismatch.vv:17:2: error: expected 1 argument, but got 2 + 15 | fn ff() int + 16 | { + 17 | return 2, '' + | ~~~~~~~~~~~~ + 18 | } + 19 | +vlib/v/checker/tests/return_count_mismatch.vv:22:2: error: expected 2 arguments, but got 1 + 20 | fn gg() (int, string) + 21 | { + 22 | return 3 + | ~~~~~~~~ + 23 | } + 24 | diff --git a/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.vv new file mode 100644 index 0000000..15f4116 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_count_mismatch.vv @@ -0,0 +1,24 @@ +fn v() { + return 3 +} + +fn f() int +{ + return +} + +fn g() (int, string) +{ + return +} + +fn ff() int +{ + return 2, '' +} + +fn gg() (int, string) +{ + return 3 +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.out b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.out new file mode 100644 index 0000000..ea41c8b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_duplicate_with_none_err_a.vv:3:2: error: unreachable code + 1 | fn f() ?bool { + 2 | return true + 3 | return none + | ~~~~~~~~~~~ + 4 | } + 5 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.vv new file mode 100644 index 0000000..c356eb8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_a.vv @@ -0,0 +1,9 @@ +fn f() ?bool { + return true + return none +} +fn main() { + f() or { + println('fail') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.out b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.out new file mode 100644 index 0000000..7bc37bb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_duplicate_with_none_err_b.vv:3:2: error: unreachable code + 1 | fn f() ?bool { + 2 | return none + 3 | return true + | ~~~~~~~~~~~ + 4 | } + 5 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.vv new file mode 100644 index 0000000..aaf39a1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_duplicate_with_none_err_b.vv @@ -0,0 +1,9 @@ +fn f() ?bool { + return none + return true +} +fn main() { + f() or { + println('fail') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.out b/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.out new file mode 100644 index 0000000..3ac7df0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/return_fixed_array.vv:1:25: error: fixed array cannot be returned by function + 1 | fn return_fixed_array() [3]int { + | ~~~~~~ + 2 | return [1, 2, 3]! + 3 | } +vlib/v/checker/tests/return_fixed_array.vv:5:41: error: fixed array cannot be used in multi-return + 3 | } + 4 | + 5 | fn return_fixed_array_in_multi_return() ([3]int, [3]int) { + | ~~~~~~~~~~~~~~~~ + 6 | return [1, 2, 3]!, [4, 5, 6]! + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.vv b/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.vv new file mode 100644 index 0000000..dc24da1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_fixed_array.vv @@ -0,0 +1,7 @@ +fn return_fixed_array() [3]int { + return [1, 2, 3]! +} + +fn return_fixed_array_in_multi_return() ([3]int, [3]int) { + return [1, 2, 3]!, [4, 5, 6]! +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.out new file mode 100644 index 0000000..f8315ac --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_comp_if.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | $if windows { + 5 |
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.vv new file mode 100644 index 0000000..e6e6d79 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if.vv @@ -0,0 +1,9 @@ +fn main() {} + +fn foo() string { + $if windows { + + } $else { + + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.out new file mode 100644 index 0000000..4c24e85 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_comp_if_nested.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | $if windows { + 5 | if true {
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.vv new file mode 100644 index 0000000..08fada9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_comp_if_nested.vv @@ -0,0 +1,17 @@ +fn main() {} + +fn foo() string { + $if windows { + if true { + + } else { + return '' + } + } $else { + if true { + + } else { + return '' + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.out new file mode 100644 index 0000000..41eb21b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/return_missing_if_else_simple.vv:1:1: error: missing return at end of function `if_no_returns` + 1 | fn if_no_returns() int { + | ~~~~~~~~~~~~~~~~~~~~~~ + 2 | if true { + 3 | println('no return in then') +vlib/v/checker/tests/return_missing_if_else_simple.vv:10:1: error: missing return at end of function `if_no_return_in_else` + 8 | } + 9 | + 10 | fn if_no_return_in_else() int { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 11 | if true { + 12 | return 123 diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.vv new file mode 100644 index 0000000..802a7d9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_else_simple.vv @@ -0,0 +1,35 @@ +fn if_no_returns() int { + if true { + println('no return in then') + } else { + println('no return in else') + } + println('hello') +} + +fn if_no_return_in_else() int { + if true { + return 123 + } else { + println('no return in else') + } + println('hello') +} + +fn if_returns_in_both_branches() int { + // The if here always returns, so the function + // returns too: + if true { + return 123 + } else { + return 456 + } + // TODO: should produce a warning/error about a statement after a return. + println('hello') +} + +fn main() { + println(if_no_returns()) + println(if_no_return_in_else()) + println(if_returns_in_both_branches()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.out new file mode 100644 index 0000000..d4877d8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_if_match.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | if true { + 5 | match 1 {
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.vv new file mode 100644 index 0000000..88ab70c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_if_match.vv @@ -0,0 +1,13 @@ +fn main() {} + +fn foo() string { + if true { + match 1 { + 1 { return '' } + 2 { } + else { return '' } + } + } else { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.out new file mode 100644 index 0000000..196b321 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_match_if.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | match 1 { + 5 | 1 { return '' }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.vv new file mode 100644 index 0000000..4ff9345 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_if.vv @@ -0,0 +1,15 @@ +fn main() {} + +fn foo() string { + match 1 { + 1 { return '' } + 2 { + if true { + + } else { + return '' + } + } + else { return '' } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.out new file mode 100644 index 0000000..6e8306b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/return_missing_match_simple.vv:4:3: warning: `match` must have at least one non `else` branch + 2 | a := 1 + 3 | match a { + 4 | else { println('abc') } + | ~~~~ + 5 | } + 6 | println('hello') +vlib/v/checker/tests/return_missing_match_simple.vv:1:1: error: missing return at end of function `h` + 1 | fn h() int { + | ~~~~~~~~~~ + 2 | a := 1 + 3 | match a { diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.vv new file mode 100644 index 0000000..463c2b2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_match_simple.vv @@ -0,0 +1,12 @@ +fn h() int { + a := 1 + match a { + else { println('abc') } + } + println('hello') +} + +fn main() { + d := h() + println('h returned: $d') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.out new file mode 100644 index 0000000..fce3245 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_nested.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | if true { + 5 | return ''
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.vv new file mode 100644 index 0000000..41b4c7f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_nested.vv @@ -0,0 +1,11 @@ +fn main() {} + +fn foo() string { + if true { + return '' + } else { + if true { + return '' + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.out b/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.out new file mode 100644 index 0000000..8016345 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_missing_simple.vv:3:1: error: missing return at end of function `foo` + 1 | fn main() {} + 2 | + 3 | fn foo() string { + | ~~~~~~~~~~~~~~~ + 4 | if true { + 5 | return ''
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.vv b/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.vv new file mode 100644 index 0000000..ed200fe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_missing_simple.vv @@ -0,0 +1,7 @@ +fn main() {} + +fn foo() string { + if true { + return '' + } else {} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.out b/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.out new file mode 100644 index 0000000..01b9990 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/return_ref_as_no_ref_bug.vv:11:9: error: fn `return_not_reference` expects you to return a non reference type `BugStruct`, but you are returning `&BugStruct` instead + 9 | + 10 | fn return_not_reference() BugStruct{ + 11 | return &BugStruct { + | ^ + 12 | id: 1 + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.vv b/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.vv new file mode 100644 index 0000000..8d04dc9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_ref_as_no_ref_bug.vv @@ -0,0 +1,14 @@ +struct BugStruct { + id int +} + +fn main() { + x := return_not_reference() + println(x.id) +} + +fn return_not_reference() BugStruct{ + return &BugStruct { + id: 1 + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_type.out b/v_windows/v/old/vlib/v/checker/tests/return_type.out new file mode 100644 index 0000000..971347c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/return_type.vv:2:9: error: cannot use `int literal` as type `bool` in return argument + 1 | fn test() bool { + 2 | return 100 + | ~~~ + 3 | } + 4 | diff --git a/v_windows/v/old/vlib/v/checker/tests/return_type.vv b/v_windows/v/old/vlib/v/checker/tests/return_type.vv new file mode 100644 index 0000000..333ec9f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_type.vv @@ -0,0 +1,5 @@ +fn test() bool { + return 100 +} + +fn main() {} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.out b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.vv new file mode 100644 index 0000000..d6fffe5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if.vv @@ -0,0 +1,9 @@ +fn main() {} + +fn foo() string { + $if windows { + return '' + } $else { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.out b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.vv new file mode 100644 index 0000000..c76e981 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_comp_if_nested.vv @@ -0,0 +1,17 @@ +fn main() {} + +fn foo() string { + $if windows { + if true { + return '' + } else { + return '' + } + } $else { + if true { + return '' + } else { + return '' + } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.out b/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.vv new file mode 100644 index 0000000..5e8d1bf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_if_match.vv @@ -0,0 +1,13 @@ +fn main() {} + +fn foo() string { + if true { + match 1 { + 1 { return '' } + 2 { return '' } + else { return '' } + } + } else { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.out b/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.vv new file mode 100644 index 0000000..2fbbcdf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_match_if.vv @@ -0,0 +1,15 @@ +fn main() {} + +fn foo() string { + match 1 { + 1 { return '' } + 2 { + if true { + return '' + } else { + return '' + } + } + else { return '' } + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_nested.out b/v_windows/v/old/vlib/v/checker/tests/return_working_nested.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_nested.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_nested.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_nested.vv new file mode 100644 index 0000000..1d72a02 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_nested.vv @@ -0,0 +1,12 @@ +fn main() {} + +fn foo() string { + if true { + return '' + } else { + if true { + return '' + } + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_simple.out b/v_windows/v/old/vlib/v/checker/tests/return_working_simple.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_simple.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_simple.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_simple.vv new file mode 100644 index 0000000..271e3f6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_simple.vv @@ -0,0 +1,9 @@ +fn main() {} + +fn foo() string { + if true { + return '' + } else { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.out b/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.vv new file mode 100644 index 0000000..a95825f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_two_if.vv @@ -0,0 +1,17 @@ +fn main() {} + +fn foo() string { + if true { + if true { + return '' + } + + if true { + return '' + } else { + return '' + } + } else { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.out b/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.out new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.out diff --git a/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.vv b/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.vv new file mode 100644 index 0000000..777b297 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/return_working_unsafe.vv @@ -0,0 +1,7 @@ +fn main() {} + +fn foo() string { + unsafe { + return '' + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/returns/return_missing_simple.vv b/v_windows/v/old/vlib/v/checker/tests/returns/return_missing_simple.vv new file mode 100644 index 0000000..ad62212 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/returns/return_missing_simple.vv @@ -0,0 +1,7 @@ +fn foo() string { + if true { + return '' + } else { + + } +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out new file mode 100644 index 0000000..60866d5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv:2:10: error: invalid operation: shift on type `float literal` + 1 | fn main() { + 2 | println(0.5 >> 1) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv new file mode 100644 index 0000000..5ea5841 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0.5 >> 1) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out new file mode 100644 index 0000000..7a0c5d9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv:2:15: error: cannot shift non-integer type `float literal` into type `int literal` + 1 | fn main() { + 2 | println(1 >> 0.5) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv new file mode 100644 index 0000000..cd55344 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(1 >> 0.5) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.run.out b/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.run.out new file mode 100644 index 0000000..f114c07 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.run.out @@ -0,0 +1 @@ +log_and_die: error: oh no diff --git a/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.vv b/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.vv new file mode 100644 index 0000000..10cf22c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/run/noreturn_fn_can_be_used_instead_of_panic.vv @@ -0,0 +1,14 @@ +fn abc() ?int { + return error('oh no') +} + +[noreturn] +fn log_and_die(e IError) { + eprintln('${@FN}: error: $e') + exit(77) +} + +fn main() { + x := abc() or { log_and_die(err) } + println(x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.run.out b/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.run.out new file mode 100644 index 0000000..9fa8e3c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.run.out @@ -0,0 +1,15 @@ +vlib/v/checker/tests/run/unused_variable_warning.vv:3:2: warning: unused variable: `a` + 1 | // NB: this test should compile and run, but it also should produce a compiler warning. + 2 | fn main() { + 3 | a := 1 + | ^ + 4 | b := 2 + 5 | println('hello') +vlib/v/checker/tests/run/unused_variable_warning.vv:4:2: warning: unused variable: `b` + 2 | fn main() { + 3 | a := 1 + 4 | b := 2 + | ^ + 5 | println('hello') + 6 | } +hello diff --git a/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.vv b/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.vv new file mode 100644 index 0000000..1611e54 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/run/unused_variable_warning.vv @@ -0,0 +1,6 @@ +// NB: this test should compile and run, but it also should produce a compiler warning. +fn main() { + a := 1 + b := 2 + println('hello') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/selective_const_import.out b/v_windows/v/old/vlib/v/checker/tests/selective_const_import.out new file mode 100644 index 0000000..690fc3c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selective_const_import.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/selective_const_import.vv:1:15: error: cannot selectively import constant `second` from `time`, import `time` and use `time.second` instead + 1 | import time { second } + | ~~~~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/selective_const_import.vv b/v_windows/v/old/vlib/v/checker/tests/selective_const_import.vv new file mode 100644 index 0000000..93e7b2f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selective_const_import.vv @@ -0,0 +1 @@ +import time { second } diff --git a/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.out b/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.out new file mode 100644 index 0000000..9e98006 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/selector_expr_assign.vv:7:6: error: struct fields can only be declared during the initialization + 5 | fn main() { + 6 | abc := Abc{} + 7 | abc.a := 2 + | ^ + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.vv b/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.vv new file mode 100644 index 0000000..024c869 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selector_expr_assign.vv @@ -0,0 +1,8 @@ +struct Abc { + a int +} + +fn main() { + abc := Abc{} + abc.a := 2 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.out b/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.out new file mode 100644 index 0000000..51065b7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/selector_expr_optional_err.vv:4:46: error: cannot access fields of an optional, handle the error with `or {...}` or propagate it with `?` + 2 | + 3 | fn main() { + 4 | println(http.get('https://httpbin.org/').status_code) + | ~~~~~~~~~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.vv b/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.vv new file mode 100644 index 0000000..d277787 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/selector_expr_optional_err.vv @@ -0,0 +1,5 @@ +import net.http + +fn main() { + println(http.get('https://httpbin.org/').status_code) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.out b/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.out new file mode 100644 index 0000000..e41873c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.out @@ -0,0 +1,83 @@ +vlib/v/checker/tests/shared_bad_args.vv:43:8: error: `r` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut receiver + 41 | shared r := Qr{ a: 7 } + 42 | lock s { + 43 | u := r.s_val(s) + | ^ + 44 | println(u) + 45 | } +vlib/v/checker/tests/shared_bad_args.vv:47:16: error: `s` is `shared` and must be `rlock`ed or `lock`ed to be passed as non-mut argument + 45 | } + 46 | lock r { + 47 | v := r.s_val(s) + | ^ + 48 | println(v) + 49 | } +vlib/v/checker/tests/shared_bad_args.vv:50:13: error: `m` is `shared` and must be `rlock`ed or `lock`ed to be passed as non-mut argument + 48 | println(v) + 49 | } + 50 | w := m_val(m) + | ^ + 51 | x := a_val(a) + 52 | println('$w $x') +vlib/v/checker/tests/shared_bad_args.vv:51:13: error: `a` is `shared` and must be `rlock`ed or `lock`ed to be passed as non-mut argument + 49 | } + 50 | w := m_val(m) + 51 | x := a_val(a) + | ^ + 52 | println('$w $x') + 53 | } +vlib/v/checker/tests/shared_bad_args.vv:61:3: error: r must be added to the `lock` list above + 59 | shared r := Qr{ a: 7 } + 60 | lock s { + 61 | r.s_mut(mut s) + | ^ + 62 | } + 63 | lock r { +vlib/v/checker/tests/shared_bad_args.vv:64:15: error: s must be added to the `lock` list above + 62 | } + 63 | lock r { + 64 | r.s_mut(mut s) + | ^ + 65 | } + 66 | m_mut(mut m) +vlib/v/checker/tests/shared_bad_args.vv:66:12: error: m is `shared` and must be `lock`ed to be passed as `mut` + 64 | r.s_mut(mut s) + 65 | } + 66 | m_mut(mut m) + | ^ + 67 | a_mut(mut a) + 68 | } +vlib/v/checker/tests/shared_bad_args.vv:67:12: error: a is `shared` and must be `lock`ed to be passed as `mut` + 65 | } + 66 | m_mut(mut m) + 67 | a_mut(mut a) + | ^ + 68 | } + 69 | +vlib/v/checker/tests/shared_bad_args.vv:76:10: error: `y` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 74 | fn main() { + 75 | shared y := St{ a: 5 } + 76 | println(y) + | ^ + 77 | println('$y') + 78 | a := Ab{ s: St{ a: 3 } } +vlib/v/checker/tests/shared_bad_args.vv:77:12: error: `y` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut interpolation object + 75 | shared y := St{ a: 5 } + 76 | println(y) + 77 | println('$y') + | ^ + 78 | a := Ab{ s: St{ a: 3 } } + 79 | println(a.s) +vlib/v/checker/tests/shared_bad_args.vv:79:12: error: `a.s` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut argument to print + 77 | println('$y') + 78 | a := Ab{ s: St{ a: 3 } } + 79 | println(a.s) + | ^ + 80 | println('$a.s') + 81 | } +vlib/v/checker/tests/shared_bad_args.vv:80:14: error: `a.s` is `shared` and must be `rlock`ed or `lock`ed to be used as non-mut interpolation object + 78 | a := Ab{ s: St{ a: 3 } } + 79 | println(a.s) + 80 | println('$a.s') + | ^ + 81 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.vv b/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.vv new file mode 100644 index 0000000..f0d4913 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_bad_args.vv @@ -0,0 +1,81 @@ +struct St { +mut: + a int +} + +struct Qr { +mut: + a int +} + +fn (mut r Qr) s_mut(mut s St) { + r.a = 5 + s.a = 7 +} + +fn (r Qr) s_val(s St) int { + return r.a * s.a +} + +fn m_mut(mut a map[string]f64) { + a['yxcv'] = -2.25 +} + +fn m_val(a map[string]f64) f64 { + x := a['yxcv'] + return x +} + +fn a_mut(mut a []int) { + a[2] = 42 +} + +fn a_val(a []int) int { + return a[1] +} + +fn test_shared_as_value() { + shared s := St{ a: 5 } + shared a := [3, 4, 6, 13, -23] + shared m := map{'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} + shared r := Qr{ a: 7 } + lock s { + u := r.s_val(s) + println(u) + } + lock r { + v := r.s_val(s) + println(v) + } + w := m_val(m) + x := a_val(a) + println('$w $x') +} + +fn test_shared_as_mut() { + shared s := St{ a: 5 } + shared a := [3, 4, 6, 13, -23] + shared m := map{'qw': 12.75, 'yxcv': -3.125, 'poiu': 88.0625} + shared r := Qr{ a: 7 } + lock s { + r.s_mut(mut s) + } + lock r { + r.s_mut(mut s) + } + m_mut(mut m) + a_mut(mut a) +} + +struct Ab { + s shared St +} + +fn main() { + shared y := St{ a: 5 } + println(y) + println('$y') + a := Ab{ s: St{ a: 3 } } + println(a.s) + println('$a.s') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.out b/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.out new file mode 100644 index 0000000..f392a1f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.out @@ -0,0 +1,27 @@ +vlib/v/checker/tests/shared_element_lock.vv:36:5: error: `pr.pe` is `shared` and needs explicit lock for `v.ast.SelectorExpr` + 34 | } + 35 | } + 36 | pr.pe.color = 3 + | ~~ + 37 | shared y := pr.pe + 38 | rlock y { +vlib/v/checker/tests/shared_element_lock.vv:42:2: error: `g` is `shared` and needs explicit lock for `v.ast.SelectorExpr` + 40 | } + 41 | shared g := Pro{} + 42 | g.pers.age = 42 + | ^ + 43 | mut h := []shared Pro{len: 3} + 44 | h[2].pers.age = 42 +vlib/v/checker/tests/shared_element_lock.vv:44:2: error: you have to create a handle and `lock` it to modify `shared` array element + 42 | g.pers.age = 42 + 43 | mut h := []shared Pro{len: 3} + 44 | h[2].pers.age = 42 + | ~~~~ + 45 | println(h[2].pers.age) + 46 | } +vlib/v/checker/tests/shared_element_lock.vv:45:10: error: you have to create a handle and `rlock` it to use a `shared` element as non-mut argument to print + 43 | mut h := []shared Pro{len: 3} + 44 | h[2].pers.age = 42 + 45 | println(h[2].pers.age) + | ~~~~ + 46 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.vv b/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.vv new file mode 100644 index 0000000..de61ad9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_element_lock.vv @@ -0,0 +1,46 @@ +struct Person { +mut: + name string + age int +} + +struct Pet { +mut: + name string + color int +} + +struct Programmer { +mut: + pers Person + pe shared Pet +} + +struct Pro { +mut: + pers Person + pe Pet +} + +fn main() { + mut pr := Programmer{ + pers: Person{ + name: 'Qwe' + age: 44 + } + pe: Pet{ + name: 'Ghj' + color: 7 + } + } + pr.pe.color = 3 + shared y := pr.pe + rlock y { + println(y.color) + } + shared g := Pro{} + g.pers.age = 42 + mut h := []shared Pro{len: 3} + h[2].pers.age = 42 + println(h[2].pers.age) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_lock.out b/v_windows/v/old/vlib/v/checker/tests/shared_lock.out new file mode 100644 index 0000000..62d7130 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_lock.out @@ -0,0 +1,21 @@ +vlib/v/checker/tests/shared_lock.vv:19:5: error: method with `shared` receiver cannot be called inside `lock`/`rlock` block + 17 | } + 18 | lock x { + 19 | x.r(x) + | ~~~~ + 20 | x.m(x) + 21 | f(0, x) +vlib/v/checker/tests/shared_lock.vv:20:7: error: method with `shared` arguments cannot be called inside `lock`/`rlock` block + 18 | lock x { + 19 | x.r(x) + 20 | x.m(x) + | ^ + 21 | f(0, x) + 22 | } +vlib/v/checker/tests/shared_lock.vv:21:8: error: function with `shared` arguments cannot be called inside `lock`/`rlock` block + 19 | x.r(x) + 20 | x.m(x) + 21 | f(0, x) + | ^ + 22 | } + 23 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_lock.vv b/v_windows/v/old/vlib/v/checker/tests/shared_lock.vv new file mode 100644 index 0000000..9af8111 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_lock.vv @@ -0,0 +1,23 @@ +struct St { +mut: + a int +} +fn (shared s St) r(x St) { +} +fn (s St) m(shared x St) { +} + + +fn f(w int, shared x St) { +} + +fn g() { + shared x := St{ + a: 5 + } + lock x { + x.r(x) + x.m(x) + f(0, x) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.out b/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.out new file mode 100644 index 0000000..32e16d9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/shared_type_mismatch.vv:13:3: error: wrong return type `St` in the `or {}` block, expected `shared St` + 11 | fn test_shared_opt_bad() { + 12 | shared yy := f() or { + 13 | St{ x: 37.5 } + | ~~~~~~~~~~~~~ + 14 | } + 15 | rlock yy { diff --git a/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.vv b/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.vv new file mode 100644 index 0000000..9d85636 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shared_type_mismatch.vv @@ -0,0 +1,18 @@ +struct St { +mut: + x f64 +} + +fn f() ?shared St { + shared x := St{ x: 12.75 } + return x +} + +fn test_shared_opt_bad() { + shared yy := f() or { + St{ x: 37.5 } + } + rlock yy { + println(yy.x) + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.out b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.out new file mode 100644 index 0000000..1bdeb5e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/shift_op_wrong_left_type_err.vv:2:10: error: invalid operation: shift on type `float literal` + 1 | fn main() { + 2 | println(0.5 << 1) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv new file mode 100644 index 0000000..87409eb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(0.5 << 1) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.out b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.out new file mode 100644 index 0000000..87d0a44 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/shift_op_wrong_right_type_err.vv:2:15: error: cannot shift non-integer type `float literal` into type `int literal` + 1 | fn main() { + 2 | println(1 << 0.5) + | ~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv new file mode 100644 index 0000000..0eb1328 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(1 << 0.5) +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.out b/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.out new file mode 100644 index 0000000..fa6044b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/short_struct_wrong_number.vv:7:6: error: too few fields in `Test` literal (expecting 2, got 1) + 5 | + 6 | fn main() { + 7 | _ = Test{true} + | ~~~~~~~~~~ + 8 | _ = Test{true, false, true} + 9 | } +vlib/v/checker/tests/short_struct_wrong_number.vv:8:6: error: too many fields in `Test` literal (expecting 2, got 3) + 6 | fn main() { + 7 | _ = Test{true} + 8 | _ = Test{true, false, true} + | ~~~~~~~~~~~~~~~~~~~~~~~ + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.vv b/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.vv new file mode 100644 index 0000000..393ca5e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/short_struct_wrong_number.vv @@ -0,0 +1,9 @@ +struct Test { + foo bool + bar bool +} + +fn main() { + _ = Test{true} + _ = Test{true, false, true} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.out b/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.out new file mode 100644 index 0000000..7ab478f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/slice_reassignment.vv:3:5: error: cannot reassign using range expression on the left side of an assignment + 1 | fn main() { + 2 | mut arr := [1, 2, 3, 4, 5] + 3 | arr[..2] = [0, 0] + | ~~~~~ + 4 | println(arr) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.vv b/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.vv new file mode 100644 index 0000000..602bd64 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/slice_reassignment.vv @@ -0,0 +1,5 @@ +fn main() { + mut arr := [1, 2, 3, 4, 5] + arr[..2] = [0, 0] + println(arr) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.out b/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.out new file mode 100644 index 0000000..d588267 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/sort_method_called_on_immutable_receiver.vv:2:2: error: `a` is immutable, declare it with `mut` to make it mutable + 1 | fn abc (a []int) { + 2 | a.sort() + | ^ + 3 | } + 4 | +vlib/v/checker/tests/sort_method_called_on_immutable_receiver.vv:7:2: error: `a` is immutable, declare it with `mut` to make it mutable + 5 | fn main() { + 6 | a := [2,30,10,20,1] + 7 | a.sort(a>b) + | ^ + 8 | eprintln(' a: $a') + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.vv b/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.vv new file mode 100644 index 0000000..b2dafa5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sort_method_called_on_immutable_receiver.vv @@ -0,0 +1,9 @@ +fn abc (a []int) { + a.sort() +} + +fn main() { + a := [2,30,10,20,1] + a.sort(a>b) + eprintln(' a: $a') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.out b/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.out new file mode 100644 index 0000000..18c297a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/static_vars_in_translated_mode.vv:2:13: error: static variables are supported only in -translated mode or in [unsafe] fn + 1 | fn counter() int { + 2 | mut static icounter := 0 + | ~~~~~~~~ + 3 | icounter++ + 4 | return icounter diff --git a/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.vv b/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.vv new file mode 100644 index 0000000..0f153c8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/static_vars_in_translated_mode.vv @@ -0,0 +1,12 @@ +fn counter() int { + mut static icounter := 0 + icounter++ + return icounter +} + +fn main() { + println(unsafe { counter() }) + println(unsafe { counter() }) + println(unsafe { counter() }) + println(unsafe { counter() }) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/store_string_err.out b/v_windows/v/old/vlib/v/checker/tests/store_string_err.out new file mode 100644 index 0000000..b0a44bf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/store_string_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/store_string_err.vv:5:26: error: wrong return type `IError` in the `or {}` block, expected `int` + 3 | } + 4 | + 5 | err := return_err() or { err } + | ~~~ + 6 | eprintln(err) diff --git a/v_windows/v/old/vlib/v/checker/tests/store_string_err.vv b/v_windows/v/old/vlib/v/checker/tests/store_string_err.vv new file mode 100644 index 0000000..7f8b3ff --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/store_string_err.vv @@ -0,0 +1,6 @@ +fn return_err() ?int { + return error('') +} + +err := return_err() or { err } +eprintln(err) diff --git a/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.out b/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.out new file mode 100644 index 0000000..9b8f1df --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/str_method_0_arguments.vv:5:1: error: .str() methods should have 0 arguments + 3 | } + 4 | + 5 | fn (z Zzz) str(x int) string { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | return 'z: $z.x' + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.vv b/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.vv new file mode 100644 index 0000000..28ef0ef --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/str_method_0_arguments.vv @@ -0,0 +1,11 @@ +struct Zzz { + x int +} + +fn (z Zzz) str(x int) string { + return 'z: $z.x' +} + +fn main() { + println(Zzz{123}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.out b/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.out new file mode 100644 index 0000000..43bb36a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/str_method_return_string.vv:5:1: error: .str() methods should return `string` + 3 | } + 4 | + 5 | fn (z Zzz) str(x int) int { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 6 | return z.x + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.vv b/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.vv new file mode 100644 index 0000000..a3f6952 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/str_method_return_string.vv @@ -0,0 +1,11 @@ +struct Zzz { + x int +} + +fn (z Zzz) str(x int) int { + return z.x +} + +fn main() { + println(Zzz{123}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.out b/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.out new file mode 100644 index 0000000..60e1f7a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/string_char_null_err.vv:2:31: error: cannot use `\0` (NULL character) in the string literal + 1 | fn main() { + 2 | println('Null character: \0') + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.vv b/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.vv new file mode 100644 index 0000000..d60854f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_char_null_err.vv @@ -0,0 +1,3 @@ +fn main() { + println('Null character: \0') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.out b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.out new file mode 100644 index 0000000..607c240 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/string_escape_u_err_a.vv:2:15: error: `\u` incomplete unicode character value + 1 | fn main() { + 2 | println('\u') + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.vv new file mode 100644 index 0000000..ad7aee7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_a.vv @@ -0,0 +1,3 @@ +fn main() { + println('\u') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.out b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.out new file mode 100644 index 0000000..d81d688 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/string_escape_u_err_b.vv:2:15: error: `\u` incomplete unicode character value + 1 | fn main() { + 2 | println('\u345') + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.vv new file mode 100644 index 0000000..650f8d6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_u_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + println('\u345') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.out b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.out new file mode 100644 index 0000000..f441565 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/string_escape_x_err_a.vv:2:15: error: `\x` used with no following hex digits + 1 | fn main() { + 2 | println('\x') + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.vv new file mode 100644 index 0000000..fdbd44b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_a.vv @@ -0,0 +1,3 @@ +fn main() { + println('\x') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.out b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.out new file mode 100644 index 0000000..da90fd1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/string_escape_x_err_b.vv:2:15: error: `\x` used with no following hex digits + 1 | fn main() { + 2 | println('\xhh') + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.vv new file mode 100644 index 0000000..deabe28 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_escape_x_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + println('\xhh') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.out b/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.out new file mode 100644 index 0000000..be9369e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/string_index_assign_error.vv:3:6: error: cannot assign to s[i] since V strings are immutable +(note, that variables may be mutable but string values are always immutable, like in Go and Java) + 1 | fn main() { + 2 | mut a := 'V is great!!' + 3 | a[0] = `R` + | ~~~ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.vv b/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.vv new file mode 100644 index 0000000..161b215 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_index_assign_error.vv @@ -0,0 +1,4 @@ +fn main() { + mut a := 'V is great!!' + a[0] = `R` +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.out b/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.out new file mode 100644 index 0000000..81e574a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/string_index_non_int_err.vv:3:14: error: non-integer string index `string` + 1 | fn main() { + 2 | v := 'foo' + 3 | println(v['f']) + | ~~~~~ + 4 | println(v[true]) + 5 | println(v[[23]]) +vlib/v/checker/tests/string_index_non_int_err.vv:4:14: error: non-integer string index `bool` + 2 | v := 'foo' + 3 | println(v['f']) + 4 | println(v[true]) + | ~~~~~~ + 5 | println(v[[23]]) + 6 | } +vlib/v/checker/tests/string_index_non_int_err.vv:5:14: error: non-integer string index `[]int` + 3 | println(v['f']) + 4 | println(v[true]) + 5 | println(v[[23]]) + | ~~~~~~ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.vv b/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.vv new file mode 100644 index 0000000..6619e47 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_index_non_int_err.vv @@ -0,0 +1,6 @@ +fn main() { + v := 'foo' + println(v['f']) + println(v[true]) + println(v[[23]]) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.out b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.out new file mode 100644 index 0000000..6ac3efe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/string_interpolation_invalid_fmt.vv:3:12: error: format specifier may only be one letter + 1 | fn interpolate_wrong() string { + 2 | a := 5 + 3 | x := '${a:xy}' + | ~~ + 4 | return x + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.vv b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.vv new file mode 100644 index 0000000..bfc8db4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_invalid_fmt.vv @@ -0,0 +1,5 @@ +fn interpolate_wrong() string { + a := 5 + x := '${a:xy}' + return x +} diff --git a/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.out b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.out new file mode 100644 index 0000000..4c9d7ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.out @@ -0,0 +1,63 @@ +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:3:16: error: precision specification only valid for float types + 1 | fn interpolate_str() string { + 2 | a := 'hallo' + 3 | x := '>${a:8.3s}<' + | ^ + 4 | y := '${a:G}' + 5 | z := '${a:d}' +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:4:12: error: illegal format specifier `G` for type `string` + 2 | a := 'hallo' + 3 | x := '>${a:8.3s}<' + 4 | y := '${a:G}' + | ^ + 5 | z := '${a:d}' + 6 | return x + y + z +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:5:12: error: illegal format specifier `d` for type `string` + 3 | x := '>${a:8.3s}<' + 4 | y := '${a:G}' + 5 | z := '${a:d}' + | ^ + 6 | return x + y + z + 7 | } +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:11:15: error: illegal format specifier `s` for type `f64` + 9 | fn interpolate_f64() string { + 10 | b := 1367.57 + 11 | x := '>${b:20s}<' + | ^ + 12 | y := '${b:d}' + 13 | return x + y +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:12:12: error: illegal format specifier `d` for type `f64` + 10 | b := 1367.57 + 11 | x := '>${b:20s}<' + 12 | y := '${b:d}' + | ^ + 13 | return x + y + 14 | } +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:19:14: error: illegal format specifier `d` for type `u32` + 17 | u := u32(15) + 18 | s := -12 + 19 | x := '${u:13d}' + | ^ + 20 | y := '${s:04u}' + 21 | z := '${s:f}' +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:20:14: error: illegal format specifier `u` for type `int` + 18 | s := -12 + 19 | x := '${u:13d}' + 20 | y := '${s:04u}' + | ^ + 21 | z := '${s:f}' + 22 | q := '${u:v}' +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:21:12: error: illegal format specifier `f` for type `int` + 19 | x := '${u:13d}' + 20 | y := '${s:04u}' + 21 | z := '${s:f}' + | ^ + 22 | q := '${u:v}' + 23 | return x + y + z + q +vlib/v/checker/tests/string_interpolation_wrong_fmt.vv:22:12: error: unknown format specifier `v` + 20 | y := '${s:04u}' + 21 | z := '${s:f}' + 22 | q := '${u:v}' + | ^ + 23 | return x + y + z + q + 24 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.vv b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.vv new file mode 100644 index 0000000..38aa5f3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/string_interpolation_wrong_fmt.vv @@ -0,0 +1,24 @@ +fn interpolate_str() string { + a := 'hallo' + x := '>${a:8.3s}<' + y := '${a:G}' + z := '${a:d}' + return x + y + z +} + +fn interpolate_f64() string { + b := 1367.57 + x := '>${b:20s}<' + y := '${b:d}' + return x + y +} + +fn interpolate_int() string { + u := u32(15) + s := -12 + x := '${u:13d}' + y := '${s:04u}' + z := '${s:f}' + q := '${u:v}' + return x + y + z + q +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.out b/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.out new file mode 100644 index 0000000..54b047e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.vv:5:4: error: mismatched types `&Foo` and `Foo` + 3 | fn main() { + 4 | mut f := &Foo{ 10 } + 5 | f = Foo{ x: 20 } + | ^ + 6 | _ = f + 7 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.vv b/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.vv new file mode 100644 index 0000000..5e96349 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_assigned_to_pointer_to_struct.vv @@ -0,0 +1,7 @@ +struct Foo { x int } + +fn main() { + mut f := &Foo{ 10 } + f = Foo{ x: 20 } + _ = f +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.out b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.out new file mode 100644 index 0000000..62cb81a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_cast_to_struct_generic_err.vv:11:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 9 | fn main() { + 10 | abc := Abc<int>{} + 11 | _ := Xyz(abc) + | ~~~~~~~~ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.vv b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.vv new file mode 100644 index 0000000..ce81ba5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_generic_err.vv @@ -0,0 +1,12 @@ +struct Abc<T> { + name T +} + +struct Xyz { + name string +} + +fn main() { + abc := Abc<int>{} + _ := Xyz(abc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.out b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.out new file mode 100644 index 0000000..baafe70 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.vv:12:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 10 | fn main() { + 11 | abc := Abc{} + 12 | _ := Xyz(abc) + | ~~~~~~~~ + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.vv new file mode 100644 index 0000000..7a5e4a3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_a.vv @@ -0,0 +1,13 @@ +struct Abc { +mut: + name string +} + +struct Xyz { + name string +} + +fn main() { + abc := Abc{} + _ := Xyz(abc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.out b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.out new file mode 100644 index 0000000..aa6f232 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.vv:12:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 10 | fn main() { + 11 | abc := Abc{} + 12 | _ := Xyz(abc) + | ~~~~~~~~ + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.vv new file mode 100644 index 0000000..ff34dca --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_mut_err_b.vv @@ -0,0 +1,13 @@ +struct Abc { + name string +} + +struct Xyz { +mut: + name string +} + +fn main() { + abc := Abc{} + _ := Xyz(abc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.out b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.out new file mode 100644 index 0000000..0a2778b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.vv:12:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 10 | fn main() { + 11 | abc := Abc{} + 12 | _ := Xyz(abc) + | ~~~~~~~~ + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.vv new file mode 100644 index 0000000..7c559e4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_a.vv @@ -0,0 +1,13 @@ +struct Abc { +pub: + name string +} + +struct Xyz { + name string +} + +fn main() { + abc := Abc{} + _ := Xyz(abc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.out b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.out new file mode 100644 index 0000000..bbc7e33 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.vv:12:7: error: casting to struct is deprecated, use e.g. `Struct{...expr}` instead + 10 | fn main() { + 11 | abc := Abc{} + 12 | _ := Xyz(abc) + | ~~~~~~~~ + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.vv new file mode 100644 index 0000000..aa92278 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_cast_to_struct_pub_err_b.vv @@ -0,0 +1,13 @@ +struct Abc { + name string +} + +struct Xyz { +pub: + name string +} + +fn main() { + abc := Abc{} + _ := Xyz(abc) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.out b/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.out new file mode 100644 index 0000000..d85190f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_embed_invalid_type.vv:4:2: error: `Foo` is not a struct + 2 | + 3 | struct Bar { + 4 | Foo + | ~~~ + 5 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.vv b/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.vv new file mode 100644 index 0000000..13f3c52 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_embed_invalid_type.vv @@ -0,0 +1,5 @@ +type Foo = int + +struct Bar { + Foo +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.out b/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.out new file mode 100644 index 0000000..691268c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_field_name_duplicate_err.vv:3:2: error: field name `a` duplicate + 1 | struct Aaa { + 2 | a int + 3 | a string + | ~~~~~~~~ + 4 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.vv b/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.vv new file mode 100644 index 0000000..487b0a7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_field_name_duplicate_err.vv @@ -0,0 +1,4 @@ +struct Aaa { + a int + a string +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.out b/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.out new file mode 100644 index 0000000..6c8e6df --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.out @@ -0,0 +1,43 @@ +vlib/v/checker/tests/struct_field_type_err.vv:12:3: error: cannot assign to field `n`: expected `int`, not `bool` + 10 | fn main() { + 11 | mut data := Data{ + 12 | n: true + | ~~~~~~~ + 13 | b: 0 + 14 | f1: fn (v ...voidptr) {} +vlib/v/checker/tests/struct_field_type_err.vv:13:3: error: cannot assign to field `b`: expected `bool`, not `int literal` + 11 | mut data := Data{ + 12 | n: true + 13 | b: 0 + | ~~~~ + 14 | f1: fn (v ...voidptr) {} + 15 | f2: fn (v voidptr) {} +vlib/v/checker/tests/struct_field_type_err.vv:14:3: error: cannot assign to field `f1`: expected `fn (voidptr)`, not `fn (...voidptr)` + 12 | n: true + 13 | b: 0 + 14 | f1: fn (v ...voidptr) {} + | ~~~~~~~~~~~~~~~~~~~~~~~~ + 15 | f2: fn (v voidptr) {} + 16 | data: true +Details: ``'s expected fn argument: `` is a pointer, but the passed fn argument: `v` is NOT a pointer +vlib/v/checker/tests/struct_field_type_err.vv:15:3: error: cannot assign to field `f2`: expected `fn (...voidptr)`, not `fn (voidptr)` + 13 | b: 0 + 14 | f1: fn (v ...voidptr) {} + 15 | f2: fn (v voidptr) {} + | ~~~~~~~~~~~~~~~~~~~~~ + 16 | data: true + 17 | } +Details: ``'s expected fn argument: `` is NOT a pointer, but the passed fn argument: `v` is a pointer +vlib/v/checker/tests/struct_field_type_err.vv:16:3: error: cannot assign to field `data`: expected `&Data`, not `bool` + 14 | f1: fn (v ...voidptr) {} + 15 | f2: fn (v voidptr) {} + 16 | data: true + | ~~~~~~~~~~ + 17 | } + 18 | +vlib/v/checker/tests/struct_field_type_err.vv:19:11: error: cannot assign to `data.n`: expected `int`, not `bool` + 17 | } + 18 | + 19 | data.n = true + | ~~~~ + 20 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.vv new file mode 100644 index 0000000..44850c2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_field_type_err.vv @@ -0,0 +1,20 @@ +struct Data { +mut: + n int + b bool + f1 fn (voidptr) + f2 fn (...voidptr) + data &Data +} + +fn main() { + mut data := Data{ + n: true + b: 0 + f1: fn (v ...voidptr) {} + f2: fn (v voidptr) {} + data: true + } + + data.n = true +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.out b/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.out new file mode 100644 index 0000000..c0eab9e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.out @@ -0,0 +1,35 @@ +vlib/v/checker/tests/struct_init_update_type_err.vv:11:6: error: expected struct, found `int` + 9 | i := 2 + 10 | _ := Foo{ + 11 | ...i + | ^ + 12 | name: 'f2' + 13 | } +vlib/v/checker/tests/struct_init_update_type_err.vv:16:6: error: expected struct, found `&int` + 14 | p := &i + 15 | _ = Foo{ + 16 | ...p + | ^ + 17 | } + 18 | f2 := Foo2{} +vlib/v/checker/tests/struct_init_update_type_err.vv:20:6: error: struct `Foo2` is not compatible with struct `Foo` + 18 | f2 := Foo2{} + 19 | _ = Foo{ + 20 | ...f2 + | ~~ + 21 | } + 22 | _ = Foo{ +vlib/v/checker/tests/struct_init_update_type_err.vv:23:6: error: expression is not an lvalue + 21 | } + 22 | _ = Foo{ + 23 | ...Foo{} + | ~~~~~ + 24 | } + 25 | } +vlib/v/checker/tests/struct_init_update_type_err.vv:32:6: error: struct `Empty` is not compatible with struct `Foo` + 30 | e := Empty{} + 31 | _ = Foo{ + 32 | ...e + | ^ + 33 | } + 34 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.vv b/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.vv new file mode 100644 index 0000000..6f8deeb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_init_update_type_err.vv @@ -0,0 +1,35 @@ +struct Foo { + name string + age int +} + +struct Foo2 {b bool} + +fn main() { + i := 2 + _ := Foo{ + ...i + name: 'f2' + } + p := &i + _ = Foo{ + ...p + } + f2 := Foo2{} + _ = Foo{ + ...f2 + } + _ = Foo{ + ...Foo{} + } +} + +struct Empty {} + +fn empty() { + e := Empty{} + _ = Foo{ + ...e + } +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.out b/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.out new file mode 100644 index 0000000..c0c34c7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/struct_pub_field.vv:9:4: error: field `i` of struct `Foo` is immutable + 7 | i: 1 + 8 | } + 9 | a.i = 2 + | ^ + 10 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.vv b/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.vv new file mode 100644 index 0000000..1f104ca --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_pub_field.vv @@ -0,0 +1,10 @@ +struct Foo { + i int +} + +fn main() { + a := Foo{ + i: 1 + } + a.i = 2 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_required_field.out b/v_windows/v/old/vlib/v/checker/tests/struct_required_field.out new file mode 100644 index 0000000..212ca63 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_required_field.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/struct_required_field.vv:12:6: error: field `Abc.f3` must be initialized + 10 | f3: 789 + 11 | } + 12 | _ = Abc{ + | ~~~~ + 13 | f1: 123 + 14 | f2: 789 diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_required_field.vv b/v_windows/v/old/vlib/v/checker/tests/struct_required_field.vv new file mode 100644 index 0000000..85b2a4d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_required_field.vv @@ -0,0 +1,16 @@ +struct Abc { + f1 int [required] + f2 int + f3 int [required] +} + +fn main() { + _ = Abc{ + f1: 123 + f3: 789 + } + _ = Abc{ + f1: 123 + f2: 789 + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.out b/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.out new file mode 100644 index 0000000..25d6ee8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/struct_required_fn_field.vv:12:6: error: field `Abc.f3` must be initialized + 10 | f3: fn () {} + 11 | } + 12 | _ = Abc{ + | ~~~~ + 13 | f1: 123 + 14 | f2: 789 diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.vv b/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.vv new file mode 100644 index 0000000..e72cfe6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_required_fn_field.vv @@ -0,0 +1,16 @@ +struct Abc { + f1 int [required] + f2 int + f3 fn () [attr1; required; attr2] +} + +fn main() { + _ = Abc{ + f1: 123 + f3: fn () {} + } + _ = Abc{ + f1: 123 + f2: 789 + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.out b/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.out new file mode 100644 index 0000000..41daa52 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/struct_short_init_warning.vv:6:9: warning: short struct initalization is deprecated, use explicit struct name + 4 | + 5 | fn f(foo Foo) Foo { + 6 | return {v: foo.v} + | ~~~~~~~~~~ + 7 | } + 8 | +vlib/v/checker/tests/struct_short_init_warning.vv:10:4: warning: short struct initalization is deprecated, use explicit struct name + 8 | + 9 | fn main() { + 10 | f({v: 10}) + | ~~~~~~~ + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.vv b/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.vv new file mode 100644 index 0000000..74bd02f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_short_init_warning.vv @@ -0,0 +1,11 @@ +struct Foo { + v int +} + +fn f(foo Foo) Foo { + return {v: foo.v} +} + +fn main() { + f({v: 10}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.out b/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.out new file mode 100644 index 0000000..4648a27 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.out @@ -0,0 +1,63 @@ +vlib/v/checker/tests/struct_type_cast_err.vv:5:10: error: cannot cast struct to `string` + 3 | fn main() { + 4 | foo := Foo{} + 5 | _ := string(foo) + | ~~~~~~~~~~~ + 6 | _ := int(foo) + 7 | _ := u64(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:6:10: error: cannot cast struct to `int` + 4 | foo := Foo{} + 5 | _ := string(foo) + 6 | _ := int(foo) + | ~~~~~~~~ + 7 | _ := u64(foo) + 8 | _ := u32(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:7:10: error: cannot cast struct to `u64` + 5 | _ := string(foo) + 6 | _ := int(foo) + 7 | _ := u64(foo) + | ~~~~~~~~ + 8 | _ := u32(foo) + 9 | _ := rune(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:8:10: error: cannot cast struct to `u32` + 6 | _ := int(foo) + 7 | _ := u64(foo) + 8 | _ := u32(foo) + | ~~~~~~~~ + 9 | _ := rune(foo) + 10 | _ := byte(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:9:10: error: cannot cast struct to `rune` + 7 | _ := u64(foo) + 8 | _ := u32(foo) + 9 | _ := rune(foo) + | ~~~~~~~~~ + 10 | _ := byte(foo) + 11 | _ := i8(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:10:10: error: cannot cast type `Foo` to `byte` + 8 | _ := u32(foo) + 9 | _ := rune(foo) + 10 | _ := byte(foo) + | ~~~~~~~~~ + 11 | _ := i8(foo) + 12 | _ := i64(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:11:10: error: cannot cast struct to `i8` + 9 | _ := rune(foo) + 10 | _ := byte(foo) + 11 | _ := i8(foo) + | ~~~~~~~ + 12 | _ := i64(foo) + 13 | _ := int(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:12:10: error: cannot cast struct to `i64` + 10 | _ := byte(foo) + 11 | _ := i8(foo) + 12 | _ := i64(foo) + | ~~~~~~~~ + 13 | _ := int(foo) + 14 | _ = &I1(foo) +vlib/v/checker/tests/struct_type_cast_err.vv:13:10: error: cannot cast struct to `int` + 11 | _ := i8(foo) + 12 | _ := i64(foo) + 13 | _ := int(foo) + | ~~~~~~~~ + 14 | _ = &I1(foo) + 15 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.vv b/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.vv new file mode 100644 index 0000000..a27eefd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_type_cast_err.vv @@ -0,0 +1,17 @@ +struct Foo{} + +fn main() { + foo := Foo{} + _ := string(foo) + _ := int(foo) + _ := u64(foo) + _ := u32(foo) + _ := rune(foo) + _ := byte(foo) + _ := i8(foo) + _ := i64(foo) + _ := int(foo) + _ = &I1(foo) +} + +interface I1{} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.out b/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.out new file mode 100644 index 0000000..2c544b0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/struct_unknown_field.vv:8:3: error: unknown field `bar` in struct literal of type `Test` + 6 | t := Test{ + 7 | foo: true + 8 | bar: false + | ~~~~~~~~~~ + 9 | } + 10 | _ = t diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.vv b/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.vv new file mode 100644 index 0000000..018bcef --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_unknown_field.vv @@ -0,0 +1,11 @@ +struct Test { + foo bool +} + +fn main() { + t := Test{ + foo: true + bar: false + } + _ = t +} diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.out b/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.out new file mode 100644 index 0000000..029f9fe --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/struct_unneeded_default.vv:2:10: error: unnecessary default value of `0`: struct fields are zeroed by default + 1 | struct Test { + 2 | n int = 0 + | ^ + 3 | s string = '' + 4 | b bool = false +vlib/v/checker/tests/struct_unneeded_default.vv:3:13: error: unnecessary default value of '': struct fields are zeroed by default + 1 | struct Test { + 2 | n int = 0 + 3 | s string = '' + | ~~ + 4 | b bool = false + 5 | } +vlib/v/checker/tests/struct_unneeded_default.vv:4:11: error: unnecessary default value `false`: struct fields are zeroed by default + 2 | n int = 0 + 3 | s string = '' + 4 | b bool = false + | ~~~~~ + 5 | } + 6 |
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.vv b/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.vv new file mode 100644 index 0000000..7ddc066 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/struct_unneeded_default.vv @@ -0,0 +1,8 @@ +struct Test { + n int = 0 + s string = '' + b bool = false +} + +fn main() { +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum.out b/v_windows/v/old/vlib/v/checker/tests/sum.out new file mode 100644 index 0000000..5c92692 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum.out @@ -0,0 +1,28 @@ +vlib/v/checker/tests/sum.vv:5:8: error: cannot cast non-sum type `int` using `as` + 3 | fn non_sum() { + 4 | v := 4 + 5 | _ = v as rune + | ~~ + 6 | _ = v as Var + 7 | } +vlib/v/checker/tests/sum.vv:6:8: error: cannot cast non-sum type `int` using `as` - use e.g. `Var(some_expr)` instead. + 4 | v := 4 + 5 | _ = v as rune + 6 | _ = v as Var + | ~~ + 7 | } + 8 | +vlib/v/checker/tests/sum.vv:10:7: error: cannot cast `rune` to `Var` + 8 | + 9 | fn sum() { + 10 | _ := Var(`J`) + | ~~~~~~~~ + 11 | mut s2 := Var('') + 12 | s2 = true +vlib/v/checker/tests/sum.vv:12:7: error: cannot assign to `s2`: expected `Var`, not `bool` + 10 | _ := Var(`J`) + 11 | mut s2 := Var('') + 12 | s2 = true + | ~~~~ + 13 | _ = s2 + 14 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum.vv b/v_windows/v/old/vlib/v/checker/tests/sum.vv new file mode 100644 index 0000000..6796a2e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum.vv @@ -0,0 +1,14 @@ +type Var = int | string + +fn non_sum() { + v := 4 + _ = v as rune + _ = v as Var +} + +fn sum() { + _ := Var(`J`) + mut s2 := Var('') + s2 = true + _ = s2 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.out new file mode 100644 index 0000000..1a9ea99 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/sum_type_assign_non_variant_err.vv:11:6: error: cannot assign to `w`: expected `Stmt`, not `IfExpr` + 9 | fn main() { + 10 | mut w := Stmt(AnotherThing{}) + 11 | w = IfExpr{} + | ~~~~~~~~ + 12 | _ = w + 13 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.vv new file mode 100644 index 0000000..1ab9a2c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_assign_non_variant_err.vv @@ -0,0 +1,13 @@ +type Expr = IfExpr | CallExpr | MatchExpr +struct MatchExpr {} +struct IfExpr {} +struct CallExpr {} + +type Stmt = Expr | AnotherThing +struct AnotherThing {} + +fn main() { + mut w := Stmt(AnotherThing{}) + w = IfExpr{} + _ = w +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.out new file mode 100644 index 0000000..20c3b00 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:35:14: error: field `name` does not exist or have the same type in all sumtype variants + 33 | } + 34 | println(m) + 35 | assert m[0].name == 'abc' + | ~~~~ + 36 | assert m[1].name == 'def' + 37 | assert m[2].name == 'xyz' +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:36:14: error: field `name` does not exist or have the same type in all sumtype variants + 34 | println(m) + 35 | assert m[0].name == 'abc' + 36 | assert m[1].name == 'def' + | ~~~~ + 37 | assert m[2].name == 'xyz' + 38 | } +vlib/v/checker/tests/sum_type_common_fields_alias_error.vv:37:14: error: field `name` does not exist or have the same type in all sumtype variants + 35 | assert m[0].name == 'abc' + 36 | assert m[1].name == 'def' + 37 | assert m[2].name == 'xyz' + | ~~~~ + 38 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.vv new file mode 100644 index 0000000..9a296b8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_alias_error.vv @@ -0,0 +1,38 @@ +type Main = Sub1 | Sub2 | Sub3 + +// NB: the subtypes will have a common `name` field, of the same `string` +// type, except Sub3, which has `name` of type AliasedString. + +type AliasedString = string + +struct Sub1 { +mut: + name string +} + +struct Sub2 { +mut: + name string +} + +struct Sub3 { +mut: + name AliasedString +} + +fn main() { + mut m := []Main{} + m << Sub1{ + name: 'abc' + } + m << Sub2{ + name: 'def' + } + m << Sub3{ + name: 'xyz' + } + println(m) + assert m[0].name == 'abc' + assert m[1].name == 'def' + assert m[2].name == 'xyz' +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.out new file mode 100644 index 0000000..9dce91a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/sum_type_common_fields_error.vv:53:14: error: field `val` does not exist or have the same type in all sumtype variants + 51 | assert m[2].name == '64bit integer' + 52 | assert m[3].name == 'string' + 53 | assert m[0].val == 123 + | ~~~ + 54 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.vv new file mode 100644 index 0000000..2da560a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_common_fields_error.vv @@ -0,0 +1,54 @@ +type Main = Sub1 | Sub2 | Sub3 | Sub4 + +// NB: all subtypes have a common name field, of the same `string` type +// but they also have a field `val` that is of a different type in the +// different subtypes => accessing `m[0].name` is fine, but *not* `m[0].val` +struct Sub1 { +mut: + val int + name string +} + +struct Sub2 { +mut: + val f32 + name string +} + +struct Sub3 { +mut: + val i64 + name string +} + +struct Sub4 { +mut: + val string + name string +} + +fn main() { + mut m := []Main{} + m << Sub1{ + val: 123 + name: 'integer' + } + m << Sub2{ + val: 3.14 + name: 'float' + } + m << Sub3{ + val: 9_876_543_210 + name: '64bit integer' + } + m << Sub4{ + val: 'abcd' + name: 'string' + } + println(m) + assert m[0].name == 'integer' + assert m[1].name == 'float' + assert m[2].name == '64bit integer' + assert m[3].name == 'string' + assert m[0].val == 123 +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.out new file mode 100644 index 0000000..a580ba0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/sum_type_exists.vv:1:22: error: unknown type `Inexistant` + 1 | type Miscellaneous = Inexistant | Nope | int + | ~~~~~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.vv new file mode 100644 index 0000000..28a4475 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_exists.vv @@ -0,0 +1 @@ +type Miscellaneous = Inexistant | Nope | int diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.out new file mode 100644 index 0000000..6a06f1b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/sum_type_infix_err.vv:5:9: error: cannot use operator `+` with `Abc` + 3 | fn main() { + 4 | x := Abc(0) + 5 | _ := x + Abc(5) + | ^ + 6 | _ := 123 + x + 7 | _ = unsafe{&x + 5} +vlib/v/checker/tests/sum_type_infix_err.vv:6:11: error: cannot use operator `+` with `Abc` + 4 | x := Abc(0) + 5 | _ := x + Abc(5) + 6 | _ := 123 + x + | ^ + 7 | _ = unsafe{&x + 5} + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.vv new file mode 100644 index 0000000..938dd6f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_infix_err.vv @@ -0,0 +1,8 @@ +type Abc = int | string + +fn main() { + x := Abc(0) + _ := x + Abc(5) + _ := 123 + x + _ = unsafe{&x + 5} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.out new file mode 100644 index 0000000..7052f3b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/sum_type_multiple_type_define.vv:3:22: error: sum type FooType cannot hold the type `Foo` more than once + 1 | struct Foo {} + 2 | + 3 | type FooType = Foo | Foo + | ~~~ diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.vv new file mode 100644 index 0000000..7ec43d0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_multiple_type_define.vv @@ -0,0 +1,3 @@ +struct Foo {} + +type FooType = Foo | Foo diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.out new file mode 100644 index 0000000..a880221 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.out @@ -0,0 +1,14 @@ +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 + | ^ + 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 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.vv new file mode 100644 index 0000000..d122a12 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_mutable_cast_err.vv @@ -0,0 +1,21 @@ +type Abc = int | string + +struct Bar { +mut: + a Abc +} + +struct Foo { + b Bar +} + +fn main() { + mut x := Abc(0) + if x is int { + _ := x + 5 + } + mut f := Foo{Bar{Abc(0)}} + if f.b.a is int { + _ := f.b.a + 5 + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.out b/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.out new file mode 100644 index 0000000..d893a2b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.out @@ -0,0 +1,18 @@ +vlib/v/checker/tests/sum_type_ref_variant_err.vv:7:33: error: sum type cannot hold a reference type + 5 | foo string + 6 | } + 7 | type Alphabet1 = Abc | string | &Xyz + | ~~~~ + 8 | type Alphabet2 = Abc | &Xyz | string + 9 | type Alphabet3 = &Xyz | Abc | string +vlib/v/checker/tests/sum_type_ref_variant_err.vv:8:24: error: sum type cannot hold a reference type + 6 | } + 7 | type Alphabet1 = Abc | string | &Xyz + 8 | type Alphabet2 = Abc | &Xyz | string + | ~~~~ + 9 | type Alphabet3 = &Xyz | Abc | string +vlib/v/checker/tests/sum_type_ref_variant_err.vv:9:18: error: sum type cannot hold a reference type + 7 | type Alphabet1 = Abc | string | &Xyz + 8 | type Alphabet2 = Abc | &Xyz | string + 9 | type Alphabet3 = &Xyz | Abc | string + | ~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.vv b/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.vv new file mode 100644 index 0000000..def2a54 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sum_type_ref_variant_err.vv @@ -0,0 +1,9 @@ +struct Abc { + val string +} +struct Xyz { + foo string +} +type Alphabet1 = Abc | string | &Xyz +type Alphabet2 = Abc | &Xyz | string +type Alphabet3 = &Xyz | Abc | string
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.out b/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.out new file mode 100644 index 0000000..f491079 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.out @@ -0,0 +1,3 @@ +vlib/v/checker/tests/sumtype_in_sumtype_err.vv:1:11: error: sum type cannot hold itself + 1 | type AA = AA | int + | ~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.vv b/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.vv new file mode 100644 index 0000000..7e53df8 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sumtype_in_sumtype_err.vv @@ -0,0 +1 @@ +type AA = AA | int diff --git a/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.out b/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.out new file mode 100644 index 0000000..813f472 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/sumtype_mismatched_type.vv:4:8: error: infix expr: cannot use `int literal` (right expression) as `AA` + 2 | + 3 | a := AA(3) + 4 | assert a == 3 + | ~~~~~~
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.vv b/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.vv new file mode 100644 index 0000000..d6a998b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/sumtype_mismatched_type.vv @@ -0,0 +1,4 @@ +type AA = int | string + +a := AA(3) +assert a == 3 diff --git a/v_windows/v/old/vlib/v/checker/tests/templates/index.html b/v_windows/v/old/vlib/v/checker/tests/templates/index.html new file mode 100644 index 0000000..7624de1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/templates/index.html @@ -0,0 +1 @@ +@test diff --git a/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.out b/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.out new file mode 100644 index 0000000..0972921 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/test_functions_should_not_return_test.vv:9:1: error: test functions should either return nothing at all, or be marked to return `?` + 7 | + 8 | // should be disallowed: + 9 | fn test_returning_int() int { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 10 | + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.vv b/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.vv new file mode 100644 index 0000000..3bebcea --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/test_functions_should_not_return_test.vv @@ -0,0 +1,17 @@ +// ordinary functions can return whatever they like, +// since they are not called by V's testing system +// in the generated main(): +fn abc() int { + return 1 +} + +// should be disallowed: +fn test_returning_int() int { + +} + +// NB: this is allowed explicitly now, to allow for shorter tests +// of functions returning optionals. +fn test_returning_opt() ? { + assert true +} diff --git a/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.out b/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.out new file mode 100644 index 0000000..eed55bd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/trailing_comma_struct_attr.vv:3:31: error: unexpected token `]`, expecting name + 1 | struct User { + 2 | name string + 3 | jobs []string [json:jobss;] + | ^ + 4 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.vv b/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.vv new file mode 100644 index 0000000..d20a3d4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/trailing_comma_struct_attr.vv @@ -0,0 +1,4 @@ +struct User { + name string + jobs []string [json:jobss;] +}
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.out b/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.out new file mode 100644 index 0000000..bb52bad --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/type_cast_optional_err.vv:2:13: error: cannot type cast an optional + 1 | fn main() { + 2 | println(int('hi'.last_index('i'))) + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.vv b/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.vv new file mode 100644 index 0000000..982559c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/type_cast_optional_err.vv @@ -0,0 +1,3 @@ +fn main() { + println(int('hi'.last_index('i'))) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.out b/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.out new file mode 100644 index 0000000..0253fba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/typedef_attr_v_struct_err.vv:2:1: error: `typedef` attribute can only be used with C structs + 1 | [typedef] + 2 | struct Point{} + | ~~~~~~~~~~~~ + 3 | + 4 | fn main() { diff --git a/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.vv b/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.vv new file mode 100644 index 0000000..421b635 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/typedef_attr_v_struct_err.vv @@ -0,0 +1,7 @@ +[typedef] +struct Point{} + +fn main() { + p := Point{} + println(p) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.out b/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.out new file mode 100644 index 0000000..35e0a6c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/undefined_ident_of_struct.vv:4:2: error: undefined ident: `f` + 2 | + 3 | fn get() { + 4 | f.a = 'test' + | ^ + 5 | } + 6 | diff --git a/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.vv b/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.vv new file mode 100644 index 0000000..a426195 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/undefined_ident_of_struct.vv @@ -0,0 +1,9 @@ +module main + +fn get() { + f.a = 'test' +} + +fn main() { + println('hello') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unexpected_or.out b/v_windows/v/old/vlib/v/checker/tests/unexpected_or.out new file mode 100644 index 0000000..ab1e077 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unexpected_or.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unexpected_or.vv:6:17: error: unexpected `or` block, the function `ret_zero` does not return an optional + 4 | + 5 | fn main() { + 6 | _ = ret_zero() or { 1 } + | ~~~~~~~~ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unexpected_or.vv b/v_windows/v/old/vlib/v/checker/tests/unexpected_or.vv new file mode 100644 index 0000000..48a8696 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unexpected_or.vv @@ -0,0 +1,7 @@ +fn ret_zero() int { + return 0 +} + +fn main() { + _ = ret_zero() or { 1 } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.out b/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.out new file mode 100644 index 0000000..411748d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unexpected_or_propagate.vv:6:17: error: unexpected `?`, the function `ret_zero` does not return an optional + 4 | + 5 | fn opt_fn() ?int { + 6 | a := ret_zero()? + | ^ + 7 | return a + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.vv b/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.vv new file mode 100644 index 0000000..16ef7b0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unexpected_or_propagate.vv @@ -0,0 +1,12 @@ +fn ret_zero() int { + return 0 +} + +fn opt_fn() ?int { + a := ret_zero()? + return a +} + +fn main() { + opt_fn() or {} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unfinished_string.out b/v_windows/v/old/vlib/v/checker/tests/unfinished_string.out new file mode 100644 index 0000000..c42f70a --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unfinished_string.out @@ -0,0 +1,2 @@ +vlib/v/checker/tests/unfinished_string.vv:2:1: error: unfinished string literal + 1 | a := ' diff --git a/v_windows/v/old/vlib/v/checker/tests/unfinished_string.vv b/v_windows/v/old/vlib/v/checker/tests/unfinished_string.vv new file mode 100644 index 0000000..e6374fb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unfinished_string.vv @@ -0,0 +1 @@ +a := ' diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.out new file mode 100644 index 0000000..225ccd0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unimplemented_interface_a.vv:10:6: error: `Cat` doesn't implement method `name` of interface `Animal` + 8 | + 9 | fn main() { + 10 | foo(Cat{}) + | ~~~~~ + 11 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.vv new file mode 100644 index 0000000..fad1194 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_a.vv @@ -0,0 +1,11 @@ +interface Animal { + name() string +} + +struct Cat {} + +fn foo(a Animal) {} + +fn main() { + foo(Cat{}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.out new file mode 100644 index 0000000..edb00d0 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unimplemented_interface_b.vv:13:6: error: `Cat` incorrectly implements method `name` of interface `Animal`: expected return type `string` + 11 | fn main() { + 12 | c := Cat{} + 13 | foo(c) + | ^ + 14 | } +Details: main.Animal has `name() string` diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.vv new file mode 100644 index 0000000..0b07a78 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_b.vv @@ -0,0 +1,14 @@ +interface Animal { + name() string +} + +struct Cat {} + +fn (c Cat) name() {} + +fn foo(a Animal) {} + +fn main() { + c := Cat{} + foo(c) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.out new file mode 100644 index 0000000..43060d4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unimplemented_interface_c.vv:12:6: error: `Cat` incorrectly implements method `name` of interface `Animal`: expected 1 parameter(s), not 2 + 10 | + 11 | fn main() { + 12 | foo(Cat{}) + | ~~~~~ + 13 | } +Details: main.Animal has `name()` diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.vv new file mode 100644 index 0000000..46960da --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_c.vv @@ -0,0 +1,13 @@ +interface Animal { + name() +} + +struct Cat {} + +fn (c Cat) name(s string) {} + +fn foo(a Animal) {} + +fn main() { + foo(Cat{}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.out new file mode 100644 index 0000000..5e39c5e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unimplemented_interface_d.vv:12:6: error: `Cat` incorrectly implements method `speak` of interface `Animal`: expected 2 parameter(s), not 1 + 10 | + 11 | fn main() { + 12 | foo(Cat{}) + | ~~~~~ + 13 | } +Details: main.Animal has `speak(s string)` diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.vv new file mode 100644 index 0000000..51b3724 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_d.vv @@ -0,0 +1,13 @@ +interface Animal { + speak(s string) +} + +struct Cat {} + +fn (c Cat) speak() {} + +fn foo(a Animal) {} + +fn main() { + foo(Cat{}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.out new file mode 100644 index 0000000..f388cb2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.out @@ -0,0 +1,15 @@ +vlib/v/checker/tests/unimplemented_interface_e.vv:12:6: error: `Cat` incorrectly implements method `speak` of interface `Animal`: expected `string`, not `&string` for parameter 1 + 10 | + 11 | fn main() { + 12 | foo(Cat{}) + | ~~~~~ + 13 | _ = Animal(Cat{}) + 14 | } +Details: main.Animal has `speak(s string)` +vlib/v/checker/tests/unimplemented_interface_e.vv:13:6: error: `Cat` incorrectly implements method `speak` of interface `Animal`: expected `string`, not `&string` for parameter 1 + 11 | fn main() { + 12 | foo(Cat{}) + 13 | _ = Animal(Cat{}) + | ~~~~~~~~~~~~~ + 14 | } +Details: main.Animal has `speak(s string)` diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.vv new file mode 100644 index 0000000..85cee42 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_e.vv @@ -0,0 +1,14 @@ +interface Animal { + speak(s string) +} + +struct Cat {} + +fn (c Cat) speak(s &string) {} + +fn foo(a Animal) {} + +fn main() { + foo(Cat{}) + _ = Animal(Cat{}) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.out new file mode 100644 index 0000000..3bdc2ac --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unimplemented_interface_f.vv:11:13: error: `Cat` incorrectly implements method `speak` of interface `Animal`: expected 2 parameter(s), not 1 + 9 | fn main() { + 10 | mut animals := []Animal{} + 11 | animals << Cat{} + | ~~~~~ + 12 | } +Details: main.Animal has `speak(s string)` diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.vv new file mode 100644 index 0000000..3fd767d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_f.vv @@ -0,0 +1,12 @@ +interface Animal { + speak(s string) +} + +struct Cat {} + +fn (c Cat) speak() {} + +fn main() { + mut animals := []Animal{} + animals << Cat{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.out new file mode 100644 index 0000000..61c2cd3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unimplemented_interface_g.vv:12:13: error: `Cat` incorrectly implements method `speak` of interface `Animal`, expected `speak(s string)` + 10 | mut animals := []Animal{} + 11 | mut cats := []Cat{} + 12 | animals << cats + | ~~~~ + 13 | } + 14 | diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.vv.disabled b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.vv.disabled new file mode 100644 index 0000000..fca4beb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_g.vv.disabled @@ -0,0 +1,14 @@ +interface Animal { + speak(s string) +} + +struct Cat {} + +fn (c Cat) speak() {} + +fn main() { + mut animals := []Animal{} + mut cats := []Cat{} + animals << cats +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.out new file mode 100644 index 0000000..0731050 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unimplemented_interface_h.vv:9:13: error: `Cat` doesn't implement field `name` of interface `Animal` + 7 | fn main() { + 8 | mut animals := []Animal{} + 9 | animals << Cat{} + | ~~~~~ + 10 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.vv new file mode 100644 index 0000000..cd00881 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_h.vv @@ -0,0 +1,10 @@ +interface Animal { + name string +} + +struct Cat {} + +fn main() { + mut animals := []Animal{} + animals << Cat{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.out new file mode 100644 index 0000000..073e248 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unimplemented_interface_i.vv:11:13: error: `Cat` incorrectly implements field `name` of interface `Animal`, expected `string`, got `int` + 9 | fn main() { + 10 | mut animals := []Animal{} + 11 | animals << Cat{} + | ~~~~~ + 12 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.vv new file mode 100644 index 0000000..4c50f0e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_i.vv @@ -0,0 +1,12 @@ +interface Animal { + name string +} + +struct Cat { + name int +} + +fn main() { + mut animals := []Animal{} + animals << Cat{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.out b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.out new file mode 100644 index 0000000..4c85238 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unimplemented_interface_j.vv:12:13: error: `Cat` incorrectly implements interface `Animal`, field `name` must be mutable + 10 | fn main() { + 11 | mut animals := []Animal{} + 12 | animals << Cat{} + | ~~~~~ + 13 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.vv b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.vv new file mode 100644 index 0000000..f54dab3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unimplemented_interface_j.vv @@ -0,0 +1,13 @@ +interface Animal { +mut: + name string +} + +struct Cat { + name string +} + +fn main() { + mut animals := []Animal{} + animals << Cat{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.out b/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.out new file mode 100644 index 0000000..be40d1b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/union_unsafe_fields.vv:10:9: error: reading a union field (or its address) requires `unsafe` + 8 | mut u := Uf32{u: 3} + 9 | u.f = 3.3 // ok + 10 | _ := u.u + | ^ + 11 | return &u.f + 12 | } +vlib/v/checker/tests/union_unsafe_fields.vv:11:12: error: reading a union field (or its address) requires `unsafe` + 9 | u.f = 3.3 // ok + 10 | _ := u.u + 11 | return &u.f + | ^ + 12 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.vv b/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.vv new file mode 100644 index 0000000..6a1bc0f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/union_unsafe_fields.vv @@ -0,0 +1,12 @@ +union Uf32 { +mut: + f f32 + u u32 +} + +fn f() f32 { + mut u := Uf32{u: 3} + u.f = 3.3 // ok + _ := u.u + return &u.f +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.out b/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.out new file mode 100644 index 0000000..2efc456 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unknown_array_element_type_b.vv:2:6: error: unknown type `abc`. +Did you mean `Aaa`? + 1 | struct Aaa { + 2 | a []abc + | ~~~ + 3 | } + 4 | diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.vv new file mode 100644 index 0000000..0fc059f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_array_element_type_b.vv @@ -0,0 +1,9 @@ +struct Aaa { + a []abc +} + +fn main() { + s := Aaa{} + println(s) +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.out b/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.out new file mode 100644 index 0000000..e520655 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.out @@ -0,0 +1,8 @@ +vlib/v/checker/tests/unknown_as_type.vv:7:9: error: unknown type `Stringg`. +Did you mean `String`? + 5 | + 6 | fn foo(e Expr) { + 7 | x := e as Stringg + | ~~ + 8 | println(x) + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.vv new file mode 100644 index 0000000..66c2a57 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_as_type.vv @@ -0,0 +1,13 @@ +type Expr = Int | String + +struct Int {} +struct String {} + +fn foo(e Expr) { + x := e as Stringg + println(x) +} + +fn main() { + +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.out b/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.out new file mode 100644 index 0000000..b97e13d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.out @@ -0,0 +1,42 @@ +vlib/v/checker/tests/unknown_comptime_expr.vv:5:6: error: `foo` is mut and may have changed since its definition + 3 | fn main() { + 4 | mut foo := 0 + 5 | $if foo == 0 {} + | ~~~ + 6 | + 7 | bar := unknown_at_ct() +vlib/v/checker/tests/unknown_comptime_expr.vv:8:6: error: definition of `bar` is unknown at compile time + 6 | + 7 | bar := unknown_at_ct() + 8 | $if bar == 0 {} + | ~~~ + 9 | } + 10 | +vlib/v/checker/tests/unknown_comptime_expr.vv:13:6: error: undefined ident: `huh` + 11 | fn if_is() { + 12 | s := S1{} + 13 | $if huh.typ is T {} + | ~~~ + 14 | $if s is int {} + 15 | $if s.i is 5 {} +vlib/v/checker/tests/unknown_comptime_expr.vv:14:6: error: invalid `$if` condition: expected a type or a selector expression or an interface check + 12 | s := S1{} + 13 | $if huh.typ is T {} + 14 | $if s is int {} + | ^ + 15 | $if s.i is 5 {} + 16 | $if s.i is T {} +vlib/v/checker/tests/unknown_comptime_expr.vv:15:13: error: invalid `$if` condition: expected a type + 13 | $if huh.typ is T {} + 14 | $if s is int {} + 15 | $if s.i is 5 {} + | ^ + 16 | $if s.i is T {} + 17 | } +vlib/v/checker/tests/unknown_comptime_expr.vv:16:13: error: unknown type `T` + 14 | $if s is int {} + 15 | $if s.i is 5 {} + 16 | $if s.i is T {} + | ^ + 17 | } + 18 | diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.vv new file mode 100644 index 0000000..c3734ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_comptime_expr.vv @@ -0,0 +1,22 @@ +fn unknown_at_ct() int { return 0 } + +fn main() { + mut foo := 0 + $if foo == 0 {} + + bar := unknown_at_ct() + $if bar == 0 {} +} + +fn if_is() { + s := S1{} + $if huh.typ is T {} + $if s is int {} + $if s.i is 5 {} + $if s.i is T {} +} + +struct S1 { + i int +} + diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_field.out b/v_windows/v/old/vlib/v/checker/tests/unknown_field.out new file mode 100644 index 0000000..395eedf --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_field.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unknown_field.vv:7:12: error: type `Test` has no field named `sdd` + 5 | fn main() { + 6 | t := Test{} + 7 | println(t.sdd) + | ~~~ + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_field.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_field.vv new file mode 100644 index 0000000..8cf14a9 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_field.vv @@ -0,0 +1,8 @@ +module main + +struct Test {} + +fn main() { + t := Test{} + println(t.sdd) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.out b/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.out new file mode 100644 index 0000000..ea09b5e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unknown_generic_type.vv:6:13: error: unknown type `Foo` + 4 | + 5 | fn main() { + 6 | x := decode<Foo>('{"name": "test"}')? + | ~~~~~ + 7 | println(x) + 8 | }
\ No newline at end of file diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.vv new file mode 100644 index 0000000..1b88eb2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_generic_type.vv @@ -0,0 +1,8 @@ +fn decode<T>(raw_data string) ?T { + return none +} + +fn main() { + x := decode<Foo>('{"name": "test"}')? + println(x) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_method.out b/v_windows/v/old/vlib/v/checker/tests/unknown_method.out new file mode 100644 index 0000000..037d2f3 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_method.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unknown_method.vv:7:12: error: unknown method or field: `Test.sdd` + 5 | fn main() { + 6 | t := Test{} + 7 | println(t.sdd()) + | ~~~~~ + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_method.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_method.vv new file mode 100644 index 0000000..879b372 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_method.vv @@ -0,0 +1,8 @@ +module main + +struct Test {} + +fn main() { + t := Test{} + println(t.sdd()) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.out b/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.out new file mode 100644 index 0000000..f80de09 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.out @@ -0,0 +1,22 @@ +vlib/v/checker/tests/unknown_method_suggest_name.vv:13:12: error: unknown type `hash.crc32.Crc33`. +Did you mean `crc32.Crc32`? + 11 | y int + 12 | z int + 13 | ccc crc32.Crc33 + | ~~~~~ + 14 | } + 15 | +vlib/v/checker/tests/unknown_method_suggest_name.vv:27:9: error: unknown method or field: `Point.tranzlate`. +Did you mean `translate`? + 25 | p := Point{1, 2, 3} + 26 | v := Vector{x: 5, y: 5, z: 10} + 27 | z := p.tranzlate(v) + | ~~~~~~~~~~~~ + 28 | println('p: $p') + 29 | println('v: $v') +vlib/v/checker/tests/unknown_method_suggest_name.vv:30:15: error: expression does not return a value + 28 | println('p: $p') + 29 | println('v: $v') + 30 | println('z: $z') + | ^ + 31 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.vv new file mode 100644 index 0000000..52af44c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_method_suggest_name.vv @@ -0,0 +1,31 @@ +import hash.crc32 + +struct Point { + x int + y int + z int +} + +struct Vector { + x int + y int + z int + ccc crc32.Crc33 +} + +fn (p Point) translate(v Vector) Point { + return Point{p.x + v.x, p.y + v.y, p.z + v.z} +} + +fn (p Point) identity() Point { + return Point{1, 1, 1} +} + +fn main() { + p := Point{1, 2, 3} + v := Vector{x: 5, y: 5, z: 10} + z := p.tranzlate(v) + println('p: $p') + println('v: $v') + println('z: $z') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.out b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.out new file mode 100644 index 0000000..5c6e6cb --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unknown_sizeof_type_err_a.vv:14:34: cgen error: unknown type `T` + 12 | println("size of Abc: ${sizeof(Abc)}") + 13 | println("size of Xyz: ${sizeof(Xyz)}") + 14 | println("size of Test: ${sizeof(T)}") + | ^ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.vv new file mode 100644 index 0000000..dd15843 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_a.vv @@ -0,0 +1,15 @@ +struct Abc { + i int +} + +struct Xyz { + f f64 +} + +type Test = Abc | Xyz + +fn main() { + println("size of Abc: ${sizeof(Abc)}") + println("size of Xyz: ${sizeof(Xyz)}") + println("size of Test: ${sizeof(T)}") +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.out b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.out new file mode 100644 index 0000000..7daa009 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unknown_sizeof_type_err_b.vv:14:34: cgen error: unknown type `Zabc` + 12 | println("size of Abc: ${sizeof(Abc)}") + 13 | println("size of Xyz: ${sizeof(Xyz)}") + 14 | println("size of Test: ${sizeof(Zabc)}") + | ~~~~ + 15 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.vv new file mode 100644 index 0000000..154f406 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_sizeof_type_err_b.vv @@ -0,0 +1,15 @@ +struct Abc { + i int +} + +struct Xyz { + f f64 +} + +type Test = Abc | Xyz + +fn main() { + println("size of Abc: ${sizeof(Abc)}") + println("size of Xyz: ${sizeof(Xyz)}") + println("size of Test: ${sizeof(Zabc)}") +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.out b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.out new file mode 100644 index 0000000..98347d6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.out @@ -0,0 +1,15 @@ +vlib/v/checker/tests/unknown_struct_field_suggest_name.vv:11:16: error: type `Points` has no field named `xxxa`. +Did you mean `xxxx`? + 9 | p := Points{[1], [2], [3]} + 10 | println('p: $p') + 11 | for x in p.xxxa { + | ~~~~ + 12 | println('x: $x') + 13 | } +vlib/v/checker/tests/unknown_struct_field_suggest_name.vv:12:19: error: expression does not return a value + 10 | println('p: $p') + 11 | for x in p.xxxa { + 12 | println('x: $x') + | ^ + 13 | } + 14 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.vv new file mode 100644 index 0000000..aebdcea --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_field_suggest_name.vv @@ -0,0 +1,14 @@ + +struct Points { + xxxx []int + yyyy []int + zzzz []int +} + +fn main() { + p := Points{[1], [2], [3]} + println('p: $p') + for x in p.xxxa { + println('x: $x') + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.out b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.out new file mode 100644 index 0000000..d21f02d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unknown_struct_name.vv:4:7: error: unknown struct `F` + 2 | + 3 | fn main() { + 4 | _ := F{} + | ~~~ + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.vv new file mode 100644 index 0000000..52a4330 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_struct_name.vv @@ -0,0 +1,5 @@ +module main + +fn main() { + _ := F{} +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.out b/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.out new file mode 100644 index 0000000..6a12a8c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/unknown_var_assign.vv:2:5: error: undefined ident: `x` (use `:=` to declare a variable) + 1 | fn main() { + 2 | x = 'hello v' + | ^ + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.vv b/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.vv new file mode 100644 index 0000000..d7ed530 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unknown_var_assign.vv @@ -0,0 +1,3 @@ +fn main() { + x = 'hello v' +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.out b/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.out new file mode 100644 index 0000000..eee14f7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/unnecessary_parenthesis.vv:2:2: error: unnecessary `()` in `if` condition, use `if expr {` instead of `if (expr) {`. + 1 | fn main() { + 2 | if (1 == 1) { + | ~~~~~~~~~~~ + 3 | println('yeay') + 4 | } else if (1 == 2) { +vlib/v/checker/tests/unnecessary_parenthesis.vv:4:4: error: unnecessary `()` in `if` condition, use `if expr {` instead of `if (expr) {`. + 2 | if (1 == 1) { + 3 | println('yeay') + 4 | } else if (1 == 2) { + | ~~~~~~~~~~~~~~~~ + 5 | println("oh no :'(") + 6 | } else if (1 == 3) { +vlib/v/checker/tests/unnecessary_parenthesis.vv:6:4: error: unnecessary `()` in `if` condition, use `if expr {` instead of `if (expr) {`. + 4 | } else if (1 == 2) { + 5 | println("oh no :'(") + 6 | } else if (1 == 3) { + | ~~~~~~~~~~~~~~~~ + 7 | println("what's wrong with physics ????") + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.vv b/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.vv new file mode 100644 index 0000000..c1eb1ae --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unnecessary_parenthesis.vv @@ -0,0 +1,9 @@ +fn main() { + if (1 == 1) { + println('yeay') + } else if (1 == 2) { + println("oh no :'(") + } else if (1 == 3) { + println("what's wrong with physics ????") + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unreachable_code.out b/v_windows/v/old/vlib/v/checker/tests/unreachable_code.out new file mode 100644 index 0000000..ae0dc92 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unreachable_code.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unreachable_code.vv:3:4: error: unreachable code + 1 | fn foo() int { + 2 | return if 1 == 1 { 1 } else { 2 } + 3 | a := 1 + | ~~ + 4 | println(a) + 5 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unreachable_code.vv b/v_windows/v/old/vlib/v/checker/tests/unreachable_code.vv new file mode 100644 index 0000000..7da480f --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unreachable_code.vv @@ -0,0 +1,8 @@ +fn foo() int { + return if 1 == 1 { 1 } else { 2 } + a := 1 + println(a) +} +fn main() { + foo() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.out b/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.out new file mode 100644 index 0000000..3d791c4 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.out @@ -0,0 +1,13 @@ +vlib/v/checker/tests/unsafe_c_calls_should_be_checked.vv:3:16: error: function `C.malloc` must be called from an `unsafe` block + 1 | + 2 | fn test_c() { + 3 | mut p := C.malloc(4) + | ~~~~~~~~~ + 4 | s := 'hope' + 5 | C.memcpy(p, s.str, 4) +vlib/v/checker/tests/unsafe_c_calls_should_be_checked.vv:5:7: error: function `C.memcpy` must be called from an `unsafe` block + 3 | mut p := C.malloc(4) + 4 | s := 'hope' + 5 | C.memcpy(p, s.str, 4) + | ~~~~~~~~~~~~~~~~~~~ + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.vv b/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.vv new file mode 100644 index 0000000..092fe2c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_c_calls_should_be_checked.vv @@ -0,0 +1,6 @@ + +fn test_c() { + mut p := C.malloc(4) + s := 'hope' + C.memcpy(p, s.str, 4) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.out b/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.out new file mode 100644 index 0000000..fae8c95 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/unsafe_fixed_array_assign.vv:8:7: error: assignment from one fixed array to another with a pointer element type is prohibited outside of `unsafe` + 6 | mut box := Box { num: 10 } + 7 | a := [&box]! + 8 | mut b := a + | ~~ + 9 | b[0].num = 0 + 10 | println(a) diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.vv b/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.vv new file mode 100644 index 0000000..38defbd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_fixed_array_assign.vv @@ -0,0 +1,10 @@ +struct Box { +mut: + num int +} + +mut box := Box { num: 10 } +a := [&box]! +mut b := a +b[0].num = 0 +println(a) diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.out b/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.out new file mode 100644 index 0000000..9ac0225 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.out @@ -0,0 +1,28 @@ +vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv:4:6: error: pointer arithmetic is only allowed in `unsafe` blocks + 2 | mut v := 5 + 3 | mut p := &v + 4 | p++ + | ~~ + 5 | p += 2 + 6 | _ := v +vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv:5:7: error: pointer arithmetic is only allowed in `unsafe` blocks + 3 | mut p := &v + 4 | p++ + 5 | p += 2 + | ~~ + 6 | _ := v + 7 | } +vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv:11:14: error: pointer arithmetic is only allowed in `unsafe` blocks + 9 | fn test_ptr_infix() { + 10 | v := 4 + 11 | mut q := &v - 1 + | ~~~~~~ + 12 | q = q + 3 + 13 | _ := q +vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv:12:9: error: pointer arithmetic is only allowed in `unsafe` blocks + 10 | v := 4 + 11 | mut q := &v - 1 + 12 | q = q + 3 + | ~~~~~ + 13 | _ := q + 14 | _ := v diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv b/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv new file mode 100644 index 0000000..b83630b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_pointer_arithmetic_should_be_checked.vv @@ -0,0 +1,15 @@ +fn test_ptr_assign() { + mut v := 5 + mut p := &v + p++ + p += 2 + _ := v +} + +fn test_ptr_infix() { + v := 4 + mut q := &v - 1 + q = q + 3 + _ := q + _ := v +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_required.out b/v_windows/v/old/vlib/v/checker/tests/unsafe_required.out new file mode 100644 index 0000000..463a6a2 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_required.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/unsafe_required.vv:8:7: error: method `S1.f` must be called from an `unsafe` block + 6 | fn test_funcs() { + 7 | s := S1{} + 8 | s.f() + | ~~~ + 9 | } + 10 | +vlib/v/checker/tests/unsafe_required.vv:16:7: error: pointer indexing is only allowed in `unsafe` blocks + 14 | _ = b[0] // OK + 15 | c := &b + 16 | _ = c[0] + | ~~~ + 17 | + 18 | v := 4 +vlib/v/checker/tests/unsafe_required.vv:20:10: error: pointer indexing is only allowed in `unsafe` blocks + 18 | v := 4 + 19 | p := &v + 20 | _ = p[0] + | ~~~ + 21 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/unsafe_required.vv b/v_windows/v/old/vlib/v/checker/tests/unsafe_required.vv new file mode 100644 index 0000000..e47a90e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unsafe_required.vv @@ -0,0 +1,21 @@ +struct S1 {} + +[unsafe] +fn (s S1) f(){} + +fn test_funcs() { + s := S1{} + s.f() +} + +fn test_ptr_index(mut a []string) { + _ = a[0] // OK + b := ['jo'] + _ = b[0] // OK + c := &b + _ = c[0] + + v := 4 + p := &v + _ = p[0] +} diff --git a/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.out b/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.out new file mode 100644 index 0000000..146e7e6 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/unwrapped_optional_infix.vv:5:9: error: unwrapped optional cannot be used in an infix expression + 3 | } + 4 | + 5 | println(test() == "") + | ~~~~~~~~~~~~ + diff --git a/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.vv b/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.vv new file mode 100644 index 0000000..432b0cc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/unwrapped_optional_infix.vv @@ -0,0 +1,5 @@ +fn test() ?string { + return "" +} + +println(test() == "") diff --git a/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.out b/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.out new file mode 100644 index 0000000..9cffcba --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.out @@ -0,0 +1,20 @@ +vlib/v/checker/tests/use_deprecated_function_warning.vv:12:2: error: function `xyz` has been deprecated + 10 | + 11 | fn main() { + 12 | xyz() + | ~~~~~ + 13 | abc() + 14 | } +vlib/v/checker/tests/use_deprecated_function_warning.vv:13:2: error: function `abc` has been deprecated; use foo2 instead + 11 | fn main() { + 12 | xyz() + 13 | abc() + | ~~~~~ + 14 | } + 15 | +vlib/v/checker/tests/use_deprecated_function_warning.vv:23:4: error: method `S1.m` has been deprecated; use bar instead + 21 | fn method() { + 22 | s := S1{} + 23 | s.m() + | ~~~ + 24 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.vv b/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.vv new file mode 100644 index 0000000..d5f95ef --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/use_deprecated_function_warning.vv @@ -0,0 +1,24 @@ +[deprecated] +fn xyz() { + println('hi') +} + +[deprecated: 'use foo2 instead'] +fn abc() { + println('hi') +} + +fn main() { + xyz() + abc() +} + +struct S1 {} + +[deprecated: 'use bar instead'] +fn (s S1) m() {} + +fn method() { + s := S1{} + s.m() +} diff --git a/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.out b/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.out new file mode 100644 index 0000000..b7b4633 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/var_duplicate_const.vv:4:5: error: duplicate of a const name `size` + 2 | + 3 | fn main() { + 4 | size := 11 + | ~~~~ + 5 | println(main.size) + 6 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.vv b/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.vv new file mode 100644 index 0000000..4275e7b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_duplicate_const.vv @@ -0,0 +1,6 @@ +const size = 22 + +fn main() { + size := 11 + println(main.size) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.out b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.out new file mode 100644 index 0000000..2cb3593 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/var_eval_not_used.vv:6:2: error: `c` evaluated but not used + 4 | + 5 | fn main() { + 6 | c + | ^ + 7 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.vv b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.vv new file mode 100644 index 0000000..57642a1 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used.vv @@ -0,0 +1,7 @@ +const ( + c = 1 +) + +fn main() { + c +} diff --git a/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.out b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.out new file mode 100644 index 0000000..89c4afd --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/var_eval_not_used_scope.vv:7:3: error: `c` evaluated but not used + 5 | fn main() { + 6 | { + 7 | c + | ^ + 8 | } + 9 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.vv b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.vv new file mode 100644 index 0000000..298e35b --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_eval_not_used_scope.vv @@ -0,0 +1,9 @@ +const ( + c = 1 +) + +fn main() { + { + c + } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.out b/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.out new file mode 100644 index 0000000..b3ea361 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/var_used_before_declaration.vv:2:13: error: undefined variable `x` (used before declaration) + 1 | fn main() { + 2 | println(x) + | ^ + 3 | x := 'hello v' + 4 | _ = x diff --git a/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.vv b/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.vv new file mode 100644 index 0000000..1a2b63d --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/var_used_before_declaration.vv @@ -0,0 +1,5 @@ +fn main() { + println(x) + x := 'hello v' + _ = x +} diff --git a/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.out b/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.out new file mode 100644 index 0000000..9898c19 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/void_fn_as_value.vv:5:7: error: unknown function: x + 3 | fn main() { + 4 | mut a := 'aa' + 5 | a += x('a','b') + | ~~~~~~~~~~ + 6 | mut b := 'abcdef' + 7 | _ = b diff --git a/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.vv b/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.vv new file mode 100644 index 0000000..012019e --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_fn_as_value.vv @@ -0,0 +1,9 @@ +module main + +fn main() { + mut a := 'aa' + a += x('a','b') + mut b := 'abcdef' + _ = b + _ = a +} diff --git a/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.out b/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.out new file mode 100644 index 0000000..b04d39c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/void_function_assign_to_string.vv:6:4: error: assignment mismatch: 1 variable(s) but `x()` returns 0 value(s) + 4 | fn main(){ + 5 | mut a := '' + 6 | a = x(1,2) // hello + | ^ + 7 | eprintln('a: $a') + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.vv b/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.vv new file mode 100644 index 0000000..fddd5fc --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_function_assign_to_string.vv @@ -0,0 +1,8 @@ +fn x(x int,y int) { + +} +fn main(){ + mut a := '' + a = x(1,2) // hello + eprintln('a: $a') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/void_optional_err.out b/v_windows/v/old/vlib/v/checker/tests/void_optional_err.out new file mode 100644 index 0000000..c9efcb7 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_optional_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/void_optional_err.vv:1:16: error: use `?` instead of `?void` + 1 | fn ret_void() ?void { + | ~~~~ + 2 | return error('error') + 3 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/void_optional_err.vv b/v_windows/v/old/vlib/v/checker/tests/void_optional_err.vv new file mode 100644 index 0000000..136e6e5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/void_optional_err.vv @@ -0,0 +1,7 @@ +fn ret_void() ?void { + return error('error') +} + +fn main() { + _ = ret_void() or { panic('$err') } +} diff --git a/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.out b/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.out new file mode 100644 index 0000000..141d7b5 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.out @@ -0,0 +1,14 @@ +vlib/v/checker/tests/vweb_routing_checks.vv:20:1: error: mismatched parameters count between vweb method `App.bar` (1) and route attribute ['/bar'] (0) + 18 | // segfault because path taks 0 vars and fcn takes 1 arg + 19 | ['/bar'] + 20 | pub fn (mut app App) bar(a string) vweb.Result { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 21 | return app.html('works') + 22 | } +vlib/v/checker/tests/vweb_routing_checks.vv:26:1: error: mismatched parameters count between vweb method `App.cow` (0) and route attribute ['/cow/:low'] (1) + 24 | // no segfault, but it shouldnt compile + 25 | ['/cow/:low'] + 26 | pub fn (mut app App) cow() vweb.Result { + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 27 | return app.html('works') + 28 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.vv b/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.vv new file mode 100644 index 0000000..53f1d09 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/vweb_routing_checks.vv @@ -0,0 +1,47 @@ +import vweb + +struct App { + vweb.Context +} + +pub fn (mut app App) no_attributes(a string) vweb.Result { + return app.text('ok') +} + +// works fine, as long as fcn gets 1 arg and route takes 1 var +['/foo/:bar'] +pub fn (mut app App) foo(a string) vweb.Result { + eprintln('foo') + return app.html('works') +} + +// segfault because path taks 0 vars and fcn takes 1 arg +['/bar'] +pub fn (mut app App) bar(a string) vweb.Result { + return app.html('works') +} + +// no segfault, but it shouldnt compile +['/cow/:low'] +pub fn (mut app App) cow() vweb.Result { + return app.html('works') +} + +/* +pub fn (app App) init_server() { + // +} + +pub fn (app App) before_request() { + // +} +*/ + +pub fn (mut app App) index() { + app.html('hello') +} + +fn main() { + port := 8181 + vweb.run<App>(&App{}, port) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.out b/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.out new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.out @@ -0,0 +1 @@ + diff --git a/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.vv b/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.vv new file mode 100644 index 0000000..13cdbec --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/vweb_tmpl_used_var.vv @@ -0,0 +1,14 @@ +import vweb + +struct App { + vweb.Context +} + +pub fn (mut app App) index() vweb.Result { + test := 'test' + return $vweb.html() +} + +fn main() { + vweb.run<App>(&App{}, 8181) +} diff --git a/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.out b/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.out new file mode 100644 index 0000000..f570847 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/warnings_for_string_c2v_calls.vv:8:7: error: to convert a C string buffer pointer to a V string, use x.vstring() instead of string(x) + 6 | p[2] = `z` + 7 | } + 8 | x := string(p) + | ~~~~~~~~~ + 9 | eprintln('x: $x') + 10 | eprintln('x.len: $x.len') diff --git a/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.vv b/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.vv new file mode 100644 index 0000000..7f4dade --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/warnings_for_string_c2v_calls.vv @@ -0,0 +1,11 @@ +fn main() { + mut p := vcalloc(20) + unsafe { + p[0] = `A` + p[1] = `B` + p[2] = `z` + } + x := string(p) + eprintln('x: $x') + eprintln('x.len: $x.len') +} diff --git a/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.out b/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.out new file mode 100644 index 0000000..af8d737 --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/wrong_propagate_ret_type.vv:6:17: error: to propagate the optional call, `opt_call` must return an optional + 4 | + 5 | fn opt_call() int { + 6 | a := ret_none()? + | ^ + 7 | return a + 8 | } diff --git a/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.vv b/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.vv new file mode 100644 index 0000000..82ef06c --- /dev/null +++ b/v_windows/v/old/vlib/v/checker/tests/wrong_propagate_ret_type.vv @@ -0,0 +1,8 @@ +fn ret_none() ?int { + return none +} + +fn opt_call() int { + a := ret_none()? + return a +} |