From 2daf915371fddbf4eea0389ce6a39fabbee0f049 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 16 Jun 2020 17:06:53 +0800 Subject: [PATCH] parser: `expression evaluated but not used` error --- .../tests/add_op_wrong_left_type_err_a.out | 6 ++--- .../tests/add_op_wrong_left_type_err_a.vv | 2 +- .../tests/add_op_wrong_left_type_err_b.out | 6 ++--- .../tests/add_op_wrong_left_type_err_b.vv | 2 +- .../tests/add_op_wrong_left_type_err_c.out | 6 ++--- .../tests/add_op_wrong_left_type_err_c.vv | 2 +- .../tests/add_op_wrong_right_type_err_a.out | 6 ++--- .../tests/add_op_wrong_right_type_err_a.vv | 2 +- .../tests/add_op_wrong_right_type_err_b.out | 6 ++--- .../tests/add_op_wrong_right_type_err_b.vv | 2 +- .../tests/add_op_wrong_right_type_err_c.out | 6 ++--- .../tests/add_op_wrong_right_type_err_c.vv | 2 +- .../tests/bit_op_wrong_left_type_err.out | 6 ++--- .../tests/bit_op_wrong_left_type_err.vv | 2 +- .../tests/bit_op_wrong_right_type_err.out | 6 ++--- .../tests/bit_op_wrong_right_type_err.vv | 2 +- .../tests/div_op_wrong_left_type_err_a.out | 6 ++--- .../tests/div_op_wrong_left_type_err_a.vv | 2 +- .../tests/div_op_wrong_left_type_err_b.out | 6 ++--- .../tests/div_op_wrong_left_type_err_b.vv | 2 +- .../tests/div_op_wrong_left_type_err_c.out | 6 ++--- .../tests/div_op_wrong_left_type_err_c.vv | 2 +- .../tests/div_op_wrong_right_type_err_a.out | 6 ++--- .../tests/div_op_wrong_right_type_err_a.vv | 2 +- .../tests/div_op_wrong_right_type_err_b.out | 6 ++--- .../tests/div_op_wrong_right_type_err_b.vv | 2 +- .../tests/div_op_wrong_right_type_err_c.out | 6 ++--- .../tests/div_op_wrong_right_type_err_c.vv | 2 +- .../tests/minus_op_wrong_left_type_err_a.out | 6 ++--- .../tests/minus_op_wrong_left_type_err_a.vv | 2 +- .../tests/minus_op_wrong_left_type_err_b.out | 6 ++--- .../tests/minus_op_wrong_left_type_err_b.vv | 2 +- .../tests/minus_op_wrong_left_type_err_c.out | 6 ++--- .../tests/minus_op_wrong_left_type_err_c.vv | 2 +- .../tests/minus_op_wrong_right_type_err_a.out | 6 ++--- .../tests/minus_op_wrong_right_type_err_a.vv | 2 +- .../tests/minus_op_wrong_right_type_err_b.out | 6 ++--- .../tests/minus_op_wrong_right_type_err_b.vv | 2 +- .../tests/minus_op_wrong_right_type_err_c.out | 6 ++--- .../tests/minus_op_wrong_right_type_err_c.vv | 2 +- .../tests/mod_op_wrong_left_type_err_a.out | 6 ++--- .../tests/mod_op_wrong_left_type_err_a.vv | 2 +- .../tests/mod_op_wrong_left_type_err_b.out | 6 ++--- .../tests/mod_op_wrong_left_type_err_b.vv | 2 +- .../tests/mod_op_wrong_left_type_err_c.out | 6 ++--- .../tests/mod_op_wrong_left_type_err_c.vv | 2 +- .../tests/mod_op_wrong_left_type_err_d.out | 6 ++--- .../tests/mod_op_wrong_left_type_err_d.vv | 2 +- .../tests/mod_op_wrong_right_type_err_a.out | 6 ++--- .../tests/mod_op_wrong_right_type_err_a.vv | 2 +- .../tests/mod_op_wrong_right_type_err_b.out | 6 ++--- .../tests/mod_op_wrong_right_type_err_b.vv | 2 +- .../tests/mod_op_wrong_right_type_err_c.out | 6 ++--- .../tests/mod_op_wrong_right_type_err_c.vv | 2 +- .../tests/mod_op_wrong_right_type_err_d.out | 6 ++--- .../tests/mod_op_wrong_right_type_err_d.vv | 2 +- .../tests/mul_op_wrong_left_type_err_a.out | 6 ++--- .../tests/mul_op_wrong_left_type_err_a.vv | 2 +- .../tests/mul_op_wrong_left_type_err_b.out | 6 ++--- .../tests/mul_op_wrong_left_type_err_b.vv | 2 +- .../tests/mul_op_wrong_left_type_err_c.out | 6 ++--- .../tests/mul_op_wrong_left_type_err_c.vv | 2 +- .../tests/mul_op_wrong_right_type_err_a.out | 6 ++--- .../tests/mul_op_wrong_right_type_err_a.vv | 2 +- .../tests/mul_op_wrong_right_type_err_b.out | 6 ++--- .../tests/mul_op_wrong_right_type_err_b.vv | 2 +- .../tests/mul_op_wrong_right_type_err_c.out | 6 ++--- .../tests/mul_op_wrong_right_type_err_c.vv | 2 +- .../tests/rshift_op_wrong_left_type_err.out | 6 ++--- .../tests/rshift_op_wrong_left_type_err.vv | 2 +- .../tests/rshift_op_wrong_right_type_err.out | 6 ++--- .../tests/rshift_op_wrong_right_type_err.vv | 2 +- .../tests/shift_op_wrong_left_type_err.out | 6 ++--- .../tests/shift_op_wrong_left_type_err.vv | 2 +- .../tests/shift_op_wrong_right_type_err.out | 6 ++--- .../tests/shift_op_wrong_right_type_err.vv | 2 +- .../v/fmt/tests/char_literal_backtick_keep.vv | 2 +- vlib/v/fmt/tests/functions_input.vv | 2 +- vlib/v/fmt/tests/string_quotes_expected.vv | 10 ++++----- vlib/v/fmt/tests/string_quotes_input.vv | 10 ++++----- vlib/v/parser/parser.v | 22 ++++++++++++------- .../tests/expr_evaluated_but_not_used_a.out | 5 +++++ .../tests/expr_evaluated_but_not_used_a.vv | 3 +++ .../tests/expr_evaluated_but_not_used_b.out | 5 +++++ .../tests/expr_evaluated_but_not_used_b.vv | 3 +++ .../tests/expr_evaluated_but_not_used_c.out | 7 ++++++ .../tests/expr_evaluated_but_not_used_c.vv | 5 +++++ .../tests/expr_evaluated_but_not_used_d.out | 7 ++++++ .../tests/expr_evaluated_but_not_used_d.vv | 6 +++++ 89 files changed, 219 insertions(+), 172 deletions(-) create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_a.out create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_a.vv create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_b.out create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_b.vv create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_c.out create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_c.vv create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_d.out create mode 100644 vlib/v/parser/tests/expr_evaluated_but_not_used_d.vv diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/add_op_wrong_left_type_err_a.out index 5218880bc..a42c15343 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_a.out +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int` +vlib/v/checker/tests/add_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int` 1 | struct Aaa{} 2 | fn main() { - 3 | Aaa{} + 10 - | ~~~~~ + 3 | println(Aaa{} + 10) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/add_op_wrong_left_type_err_a.vv index 625abda67..72c631994 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_a.vv +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - Aaa{} + 10 + println(Aaa{} + 10) } diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/add_op_wrong_left_type_err_b.out index 864151db2..bb221eb92 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_b.out +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int` +vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int` 1 | fn main() { - 2 | [1,2,3] + 10 - | ~~~~~~~ + 2 | println([1,2,3] + 10) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/add_op_wrong_left_type_err_b.vv index f75bfb8c6..c87da722a 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_b.vv +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - [1,2,3] + 10 + println([1,2,3] + 10) } diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/add_op_wrong_left_type_err_c.out index 7f260d0c2..af6d21b9e 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_c.out +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/add_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int` +vlib/v/checker/tests/add_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int` 1 | fn main() { 2 | a := map[string]int - 3 | a + 10 - | ^ + 3 | println(a + 10) + | ^ 4 | } diff --git a/vlib/v/checker/tests/add_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/add_op_wrong_left_type_err_c.vv index 497b3f95a..fba4f3a25 100644 --- a/vlib/v/checker/tests/add_op_wrong_left_type_err_c.vv +++ b/vlib/v/checker/tests/add_op_wrong_left_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - a + 10 + println(a + 10) } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/add_op_wrong_right_type_err_a.out index 922ea4c65..dd7eb74cf 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_a.out +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa` +vlib/v/checker/tests/add_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa` 1 | struct Aaa{} 2 | fn main() { - 3 | 10 + Aaa{} - | ~~~~~ + 3 | println(10 + Aaa{}) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/add_op_wrong_right_type_err_a.vv index 01af6499a..1be1ffb7f 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_a.vv +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - 10 + Aaa{} + println(10 + Aaa{}) } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/add_op_wrong_right_type_err_b.out index 8d61f81c2..2704f8439 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_b.out +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int` +vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int` 1 | fn main() { - 2 | 10 + [1,2,3] - | ~~~~~~~ + 2 | println(10 + [1,2,3]) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/add_op_wrong_right_type_err_b.vv index ad55530f7..4987ddb2b 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_b.vv +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - 10 + [1,2,3] + println(10 + [1,2,3]) } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/add_op_wrong_right_type_err_c.out index 085c32fb8..221531184 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_c.out +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/add_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int` +vlib/v/checker/tests/add_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int` 1 | fn main() { 2 | a := map[string]int - 3 | 10 + a - | ^ + 3 | println(10 + a) + | ^ 4 | } diff --git a/vlib/v/checker/tests/add_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/add_op_wrong_right_type_err_c.vv index 1be140247..dd18d5237 100644 --- a/vlib/v/checker/tests/add_op_wrong_right_type_err_c.vv +++ b/vlib/v/checker/tests/add_op_wrong_right_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - 10 + a + println(10 + a) } diff --git a/vlib/v/checker/tests/bit_op_wrong_left_type_err.out b/vlib/v/checker/tests/bit_op_wrong_left_type_err.out index 0077eeff0..d2f2394b3 100644 --- a/vlib/v/checker/tests/bit_op_wrong_left_type_err.out +++ b/vlib/v/checker/tests/bit_op_wrong_left_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/bit_op_wrong_left_type_err.v:2:2: error: left type of `&` cannot be non-integer type any_float +vlib/v/checker/tests/bit_op_wrong_left_type_err.v:2:10: error: left type of `&` cannot be non-integer type any_float 1 | fn main() { - 2 | 0.5 & 1 - | ~~~ + 2 | println(0.5 & 1) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv b/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv index 362cba79b..60b0da585 100644 --- a/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv +++ b/vlib/v/checker/tests/bit_op_wrong_left_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 0.5 & 1 + println(0.5 & 1) } \ No newline at end of file diff --git a/vlib/v/checker/tests/bit_op_wrong_right_type_err.out b/vlib/v/checker/tests/bit_op_wrong_right_type_err.out index 3e36bb91a..68f735965 100644 --- a/vlib/v/checker/tests/bit_op_wrong_right_type_err.out +++ b/vlib/v/checker/tests/bit_op_wrong_right_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/bit_op_wrong_right_type_err.v:2:6: error: right type of `|` cannot be non-integer type any_float +vlib/v/checker/tests/bit_op_wrong_right_type_err.v:2:14: error: right type of `|` cannot be non-integer type any_float 1 | fn main() { - 2 | 1 | 0.5 - | ~~~ + 2 | println(1 | 0.5) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv b/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv index 8bdcbc593..d9da95c0c 100644 --- a/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv +++ b/vlib/v/checker/tests/bit_op_wrong_right_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 1 | 0.5 + println(1 | 0.5) } \ No newline at end of file diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/div_op_wrong_left_type_err_a.out index 83027ae65..78bd4d8a6 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_a.out +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int` +vlib/v/checker/tests/div_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int` 1 | struct Aaa{} 2 | fn main() { - 3 | Aaa{} / 10 - | ~~~~~ + 3 | println(Aaa{} / 10) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/div_op_wrong_left_type_err_a.vv index a8286b703..82984d021 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_a.vv +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - Aaa{} / 10 + println(Aaa{} / 10) } diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/div_op_wrong_left_type_err_b.out index 3706ba254..d00607cb7 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_b.out +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int` +vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int` 1 | fn main() { - 2 | [1,2,3] / 10 - | ~~~~~~~ + 2 | println([1,2,3] / 10) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/div_op_wrong_left_type_err_b.vv index 4dc9bc6ac..4e89fc2a2 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_b.vv +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - [1,2,3] / 10 + println([1,2,3] / 10) } diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/div_op_wrong_left_type_err_c.out index 336adaf5d..240fa6ea4 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_c.out +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/div_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int` +vlib/v/checker/tests/div_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int` 1 | fn main() { 2 | a := map[string]int - 3 | a / 10 - | ^ + 3 | println(a / 10) + | ^ 4 | } diff --git a/vlib/v/checker/tests/div_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/div_op_wrong_left_type_err_c.vv index b326b6872..fca64f9ff 100644 --- a/vlib/v/checker/tests/div_op_wrong_left_type_err_c.vv +++ b/vlib/v/checker/tests/div_op_wrong_left_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - a / 10 + println(a / 10) } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/div_op_wrong_right_type_err_a.out index 017990d29..ef62bd695 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_a.out +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa` +vlib/v/checker/tests/div_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa` 1 | struct Aaa{} 2 | fn main() { - 3 | 10 / Aaa{} - | ~~~~~ + 3 | println(10 / Aaa{}) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/div_op_wrong_right_type_err_a.vv index 5abff6d9f..b2e48704f 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_a.vv +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - 10 / Aaa{} + println(10 / Aaa{}) } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/div_op_wrong_right_type_err_b.out index 4dca5f2ce..f10d236c1 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_b.out +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int` +vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int` 1 | fn main() { - 2 | 10 / [1,2,3] - | ~~~~~~~ + 2 | println(10 / [1,2,3]) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/div_op_wrong_right_type_err_b.vv index 0870d80a3..5e0186de5 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_b.vv +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - 10 / [1,2,3] + println(10 / [1,2,3]) } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/div_op_wrong_right_type_err_c.out index 834c6f72e..0b7df6bae 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_c.out +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/div_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int` +vlib/v/checker/tests/div_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int` 1 | fn main() { 2 | a := map[string]int - 3 | 10 / a - | ^ + 3 | println(10 / a) + | ^ 4 | } diff --git a/vlib/v/checker/tests/div_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/div_op_wrong_right_type_err_c.vv index f784c8c0e..220a8baea 100644 --- a/vlib/v/checker/tests/div_op_wrong_right_type_err_c.vv +++ b/vlib/v/checker/tests/div_op_wrong_right_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - 10 / a + println(10 / a) } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.out index 72c338486..8f5aa743f 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.out +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int` +vlib/v/checker/tests/minus_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int` 1 | struct Aaa{} 2 | fn main() { - 3 | Aaa{} - 10 - | ~~~~~ + 3 | println(Aaa{} - 10) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.vv index a4cbb0903..26ed6d6f4 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.vv +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - Aaa{} - 10 + println(Aaa{} - 10) } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.out index 65e835c09..ecb834e24 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.out +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/minus_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int` +vlib/v/checker/tests/minus_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int` 1 | fn main() { - 2 | [1,2,3] - 10 - | ~~~~~~~ + 2 | println([1,2,3] - 10) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.vv index 25a7ed323..b213660e9 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.vv +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - [1,2,3] - 10 + println([1,2,3] - 10) } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.out index 714a7ee5b..f676a63f2 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.out +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/minus_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int` +vlib/v/checker/tests/minus_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int` 1 | fn main() { 2 | a := map[string]int - 3 | a - 10 - | ^ + 3 | println(a - 10) + | ^ 4 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.vv index 083d54b3a..815a7ae2f 100644 --- a/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.vv +++ b/vlib/v/checker/tests/minus_op_wrong_left_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - a - 10 + println(a - 10) } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.out index 68f30a760..2f30a9c2b 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.out +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/minus_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa` +vlib/v/checker/tests/minus_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa` 1 | struct Aaa{} 2 | fn main() { - 3 | 10 - Aaa{} - | ~~~~~ + 3 | println(10 - Aaa{}) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.vv index 8a2d4511f..24acd1866 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.vv +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - 10 - Aaa{} + println(10 - Aaa{}) } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.out index 76a786551..b35e4014b 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.out +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/minus_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int` +vlib/v/checker/tests/minus_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int` 1 | fn main() { - 2 | 10 - [1,2,3] - | ~~~~~~~ + 2 | println(10 - [1,2,3]) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.vv index d001d9bd2..7db598d81 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.vv +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - 10 - [1,2,3] + println(10 - [1,2,3]) } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.out index 25c618462..e3245d5c7 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.out +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/minus_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int` +vlib/v/checker/tests/minus_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int` 1 | fn main() { 2 | a := map[string]int - 3 | 10 - a - | ^ + 3 | println(10 - a) + | ^ 4 | } diff --git a/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.vv index 7c73df41f..76ff12d80 100644 --- a/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.vv +++ b/vlib/v/checker/tests/minus_op_wrong_right_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - 10 - a + println(10 - a) } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.out index 86fb06751..207bb9341 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.out +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mod_op_wrong_left_type_err_a.v:2:2: error: float modulo not allowed, use math.fmod() instead +vlib/v/checker/tests/mod_op_wrong_left_type_err_a.v:2:10: error: float modulo not allowed, use math.fmod() instead 1 | fn main() { - 2 | 0.5 % 1 - | ~~~ + 2 | println(0.5 % 1) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.vv index 175974c6a..cc7217f26 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.vv +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_a.vv @@ -1,3 +1,3 @@ fn main() { - 0.5 % 1 + println(0.5 % 1) } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.out index ac813150f..4a00b7fd5 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.out +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mod_op_wrong_left_type_err_b.v:2:2: error: mismatched types `array_int` and `any_int` +vlib/v/checker/tests/mod_op_wrong_left_type_err_b.v:2:10: error: mismatched types `array_int` and `any_int` 1 | fn main() { - 2 | [1,2,3] % 1 - | ~~~~~~~ + 2 | println([1,2,3] % 1) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.vv index 8e33fbbb6..963fccd89 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.vv +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - [1,2,3] % 1 + println([1,2,3] % 1) } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.out index 04ac5bb15..c8343b9a0 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.out +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:2: error: mismatched types `Aaa` and `any_int` +vlib/v/checker/tests/mod_op_wrong_left_type_err_c.v:4:10: error: mismatched types `Aaa` and `any_int` 2 | fn main() { 3 | a := Aaa{} - 4 | a % 1 - | ^ + 4 | println(a % 1) + | ^ 5 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.vv index 9042a6b57..f05db5c2b 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.vv +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_c.vv @@ -1,5 +1,5 @@ struct Aaa{} fn main() { a := Aaa{} - a % 1 + println(a % 1) } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.out b/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.out index bbf5235c3..89081346f 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.out +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mod_op_wrong_left_type_err_d.v:3:2: error: mismatched types `map_string_int` and `any_int` +vlib/v/checker/tests/mod_op_wrong_left_type_err_d.v:3:10: error: mismatched types `map_string_int` and `any_int` 1 | fn main() { 2 | a := map[string]int - 3 | a % 1 - | ^ + 3 | println(a % 1) + | ^ 4 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.vv b/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.vv index d4f76d671..03b383196 100644 --- a/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.vv +++ b/vlib/v/checker/tests/mod_op_wrong_left_type_err_d.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - a % 1 + println(a % 1) } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.out index 989c42d4d..82b6bb1e2 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.out +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mod_op_wrong_right_type_err_a.v:2:6: error: float modulo not allowed, use math.fmod() instead +vlib/v/checker/tests/mod_op_wrong_right_type_err_a.v:2:14: error: float modulo not allowed, use math.fmod() instead 1 | fn main() { - 2 | 1 % 0.5 - | ~~~ + 2 | println(1 % 0.5) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.vv index 9db1022bc..eb573a51d 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.vv +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_a.vv @@ -1,3 +1,3 @@ fn main() { - 1 % 0.5 + println(1 % 0.5) } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.out index d43282c50..b75db1d40 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.out +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mod_op_wrong_right_type_err_b.v:2:6: error: mismatched types `any_int` and `array_int` +vlib/v/checker/tests/mod_op_wrong_right_type_err_b.v:2:14: error: mismatched types `any_int` and `array_int` 1 | fn main() { - 2 | 1 % [1,2,3] - | ~~~~~~~ + 2 | println(1 % [1,2,3]) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.vv index 2322fed1e..bc6a3c627 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.vv +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - 1 % [1,2,3] + println(1 % [1,2,3]) } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.out index 29e91389f..aa275ffb7 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.out +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:6: error: mismatched types `any_int` and `Aaa` +vlib/v/checker/tests/mod_op_wrong_right_type_err_c.v:4:14: error: mismatched types `any_int` and `Aaa` 2 | fn main() { 3 | a := Aaa{} - 4 | 1 % a - | ^ + 4 | println(1 % a) + | ^ 5 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.vv index 2cea370b6..dd691cf97 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.vv +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_c.vv @@ -1,5 +1,5 @@ struct Aaa{} fn main() { a := Aaa{} - 1 % a + println(1 % a) } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.out b/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.out index 2dd072bd1..592f608e9 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.out +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mod_op_wrong_right_type_err_d.v:3:6: error: mismatched types `any_int` and `map_string_int` +vlib/v/checker/tests/mod_op_wrong_right_type_err_d.v:3:14: error: mismatched types `any_int` and `map_string_int` 1 | fn main() { 2 | a := map[string]int - 3 | 1 % a - | ^ + 3 | println(1 % a) + | ^ 4 | } diff --git a/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.vv b/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.vv index ca3730dec..6478d580c 100644 --- a/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.vv +++ b/vlib/v/checker/tests/mod_op_wrong_right_type_err_d.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - 1 % a + println(1 % a) } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.out index 4f51e39b5..5dc293a4b 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.out +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:5: error: mismatched types `Aaa` and `any_int` +vlib/v/checker/tests/mul_op_wrong_left_type_err_a.v:3:13: error: mismatched types `Aaa` and `any_int` 1 | struct Aaa{} 2 | fn main() { - 3 | Aaa{} * 10 - | ~~~~~ + 3 | println(Aaa{} * 10) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.vv index d5eb305ed..67193c9dd 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.vv +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - Aaa{} * 10 + println(Aaa{} * 10) } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.out index 342042bc3..dca3eec12 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.out +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mul_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `any_int` +vlib/v/checker/tests/mul_op_wrong_left_type_err_b.v:2:13: error: mismatched types `array_int` and `any_int` 1 | fn main() { - 2 | [1,2,3] * 10 - | ~~~~~~~ + 2 | println([1,2,3] * 10) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.vv index d3db01f01..26f7682ff 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.vv +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - [1,2,3] * 10 + println([1,2,3] * 10) } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.out index 3d1f7c543..6d4b72728 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.out +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mul_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `any_int` +vlib/v/checker/tests/mul_op_wrong_left_type_err_c.v:3:13: error: mismatched types `map_string_int` and `any_int` 1 | fn main() { 2 | a := map[string]int - 3 | a * 10 - | ^ + 3 | println(a * 10) + | ^ 4 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.vv index 315f88286..305b40156 100644 --- a/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.vv +++ b/vlib/v/checker/tests/mul_op_wrong_left_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - a * 10 + println(a * 10) } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.out index 5c7a6358c..6b1bfdfcd 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.out +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mul_op_wrong_right_type_err_a.v:3:10: error: mismatched types `any_int` and `Aaa` +vlib/v/checker/tests/mul_op_wrong_right_type_err_a.v:3:18: error: mismatched types `any_int` and `Aaa` 1 | struct Aaa{} 2 | fn main() { - 3 | 10 * Aaa{} - | ~~~~~ + 3 | println(10 * Aaa{}) + | ~~~~~ 4 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.vv index 19b900b19..d98f0297b 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.vv +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_a.vv @@ -1,4 +1,4 @@ struct Aaa{} fn main() { - 10 * Aaa{} + println(10 * Aaa{}) } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.out index 210d9022a..72f872432 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.out +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/mul_op_wrong_right_type_err_b.v:2:10: error: mismatched types `any_int` and `array_int` +vlib/v/checker/tests/mul_op_wrong_right_type_err_b.v:2:18: error: mismatched types `any_int` and `array_int` 1 | fn main() { - 2 | 10 * [1,2,3] - | ~~~~~~~ + 2 | println(10 * [1,2,3]) + | ~~~~~~~ 3 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.vv index 29a136b9e..0b30519af 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.vv +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_b.vv @@ -1,3 +1,3 @@ fn main() { - 10 * [1,2,3] + println(10 * [1,2,3]) } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.out index c32652ebc..b6004066b 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.out +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.out @@ -1,6 +1,6 @@ -vlib/v/checker/tests/mul_op_wrong_right_type_err_c.v:3:10: error: mismatched types `any_int` and `map_string_int` +vlib/v/checker/tests/mul_op_wrong_right_type_err_c.v:3:18: error: mismatched types `any_int` and `map_string_int` 1 | fn main() { 2 | a := map[string]int - 3 | 10 * a - | ^ + 3 | println(10 * a) + | ^ 4 | } diff --git a/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.vv index 80ef96194..c4b2d947a 100644 --- a/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.vv +++ b/vlib/v/checker/tests/mul_op_wrong_right_type_err_c.vv @@ -1,4 +1,4 @@ fn main() { a := map[string]int - 10 * a + println(10 * a) } diff --git a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out index 761219a2a..34b462142 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out +++ b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/rshift_op_wrong_left_type_err.v:2:2: error: cannot shift type any_int into non-integer type any_float +vlib/v/checker/tests/rshift_op_wrong_left_type_err.v:2:10: error: cannot shift type any_int into non-integer type any_float 1 | fn main() { - 2 | 0.5 >> 1 - | ~~~ + 2 | println(0.5 >> 1) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv index 5e4a47180..5ea584132 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv +++ b/vlib/v/checker/tests/rshift_op_wrong_left_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 0.5 >> 1 + println(0.5 >> 1) } diff --git a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out index a7103b858..8d62e7bb6 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out +++ b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/rshift_op_wrong_right_type_err.v:2:7: error: cannot shift non-integer type any_float into type any_int +vlib/v/checker/tests/rshift_op_wrong_right_type_err.v:2:15: error: cannot shift non-integer type any_float into type any_int 1 | fn main() { - 2 | 1 >> 0.5 - | ~~~ + 2 | println(1 >> 0.5) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv index 22abd553d..cd5534409 100644 --- a/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv +++ b/vlib/v/checker/tests/rshift_op_wrong_right_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 1 >> 0.5 + println(1 >> 0.5) } diff --git a/vlib/v/checker/tests/shift_op_wrong_left_type_err.out b/vlib/v/checker/tests/shift_op_wrong_left_type_err.out index 29e58a57f..209ae4dfe 100644 --- a/vlib/v/checker/tests/shift_op_wrong_left_type_err.out +++ b/vlib/v/checker/tests/shift_op_wrong_left_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/shift_op_wrong_left_type_err.v:2:2: error: cannot shift type any_int into non-integer type any_float +vlib/v/checker/tests/shift_op_wrong_left_type_err.v:2:10: error: cannot shift type any_int into non-integer type any_float 1 | fn main() { - 2 | 0.5 << 1 - | ~~~ + 2 | println(0.5 << 1) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv b/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv index 5c0a8cb6f..87409eb3d 100644 --- a/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv +++ b/vlib/v/checker/tests/shift_op_wrong_left_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 0.5 << 1 + println(0.5 << 1) } \ No newline at end of file diff --git a/vlib/v/checker/tests/shift_op_wrong_right_type_err.out b/vlib/v/checker/tests/shift_op_wrong_right_type_err.out index 71ccb5e14..9d22d5023 100644 --- a/vlib/v/checker/tests/shift_op_wrong_right_type_err.out +++ b/vlib/v/checker/tests/shift_op_wrong_right_type_err.out @@ -1,5 +1,5 @@ -vlib/v/checker/tests/shift_op_wrong_right_type_err.v:2:7: error: cannot shift non-integer type any_float into type any_int +vlib/v/checker/tests/shift_op_wrong_right_type_err.v:2:15: error: cannot shift non-integer type any_float into type any_int 1 | fn main() { - 2 | 1 << 0.5 - | ~~~ + 2 | println(1 << 0.5) + | ~~~ 3 | } diff --git a/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv b/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv index 5e8a85d17..0eb1328f3 100644 --- a/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv +++ b/vlib/v/checker/tests/shift_op_wrong_right_type_err.vv @@ -1,3 +1,3 @@ fn main() { - 1 << 0.5 + println(1 << 0.5) } \ No newline at end of file diff --git a/vlib/v/fmt/tests/char_literal_backtick_keep.vv b/vlib/v/fmt/tests/char_literal_backtick_keep.vv index 24205a457..6979e95bb 100644 --- a/vlib/v/fmt/tests/char_literal_backtick_keep.vv +++ b/vlib/v/fmt/tests/char_literal_backtick_keep.vv @@ -1,3 +1,3 @@ fn char_backtick() { - `\`` + println(`\``) } diff --git a/vlib/v/fmt/tests/functions_input.vv b/vlib/v/fmt/tests/functions_input.vv index 9498dcfec..f0341a7fa 100644 --- a/vlib/v/fmt/tests/functions_input.vv +++ b/vlib/v/fmt/tests/functions_input.vv @@ -50,7 +50,7 @@ fn (f Foo) fn_with_optional() ?int { return 40 } -fn mut_array(a mut []int) { +fn mut_array(mut a []int) { println(1) } diff --git a/vlib/v/fmt/tests/string_quotes_expected.vv b/vlib/v/fmt/tests/string_quotes_expected.vv index be1a0c652..b1730ce36 100644 --- a/vlib/v/fmt/tests/string_quotes_expected.vv +++ b/vlib/v/fmt/tests/string_quotes_expected.vv @@ -1,11 +1,11 @@ fn main() { - 'Hello world !' - 'This is correct !' - "It's okay" - 'This is "too"' + println('Hello world !') + println('This is correct !') + println("It's okay") + println('This is "too"') // TODO // 'I\'m not correctly formatted' => "I'm not correctly formatted" // "\"Everything on the internet is true\" - Albert Einstein, 1965" => '"Everything on the internet is true" - Albert Einstein, 1965' - 'I\'m out of idea "_"' + println('I\'m out of idea "_"') // "Definitely out \":'(\"" => 'Definitely out ":\'("' } diff --git a/vlib/v/fmt/tests/string_quotes_input.vv b/vlib/v/fmt/tests/string_quotes_input.vv index b83fabfe5..6db23a4d8 100644 --- a/vlib/v/fmt/tests/string_quotes_input.vv +++ b/vlib/v/fmt/tests/string_quotes_input.vv @@ -1,11 +1,11 @@ fn main() { - "Hello world !" - 'This is correct !' - "It's okay" - 'This is "too"' + println("Hello world !") + println('This is correct !') + println("It's okay") + println('This is "too"') // TODO // 'I\'m not correctly formatted' => "I'm not correctly formatted" // "\"Everything on the internet is true\" - Albert Einstein, 1965" => '"Everything on the internet is true" - Albert Einstein, 1965' - 'I\'m out of idea "_"' + println('I\'m out of idea "_"') // "Definitely out \":'(\"" => 'Definitely out ":\'("' } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 1db78c45a..232ed44b7 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -73,7 +73,7 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt { } p.init_parse_fns() p.read_first_token() - return p.stmt() + return p.stmt(false) } pub fn parse_text(text string, b_table &table.Table, pref &pref.Preferences, scope, global_scope &ast.Scope) ast.File { @@ -317,7 +317,7 @@ pub fn (mut p Parser) parse_block_no_scope(is_top_level bool) []ast.Stmt { mut stmts := []ast.Stmt{} if p.tok.kind != .rcbr { for { - stmts << p.stmt() + stmts << p.stmt(is_top_level) // p.warn('after stmt(): tok=$p.tok.str()') if p.tok.kind in [.eof, .rcbr] { break @@ -464,7 +464,7 @@ pub fn (mut p Parser) top_stmt() ast.Stmt { if p.pref.is_script && !p.pref.is_test { mut stmts := []ast.Stmt{} for p.tok.kind != .eof { - stmts << p.stmt() + stmts << p.stmt(false) } return ast.FnDecl{ name: 'main' @@ -500,7 +500,7 @@ pub fn (mut p Parser) comment() ast.Comment { } } -pub fn (mut p Parser) stmt() ast.Stmt { +pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt { p.is_stmt_ident = p.tok.kind == .name match p.tok.kind { .lcbr { @@ -530,7 +530,7 @@ pub fn (mut p Parser) stmt() ast.Stmt { return p.assign_stmt() } else if p.peek_tok.kind == .comma { // `a, b ...` - return p.parse_multi_expr() + return p.parse_multi_expr(is_top_level) } else if p.peek_tok.kind == .colon { // `label:` name := p.check_name() @@ -544,7 +544,7 @@ pub fn (mut p Parser) stmt() ast.Stmt { [.rcbr, .eof] { p.error_with_pos('`$p.tok.lit` evaluated but not used', p.tok.position()) } - return p.parse_multi_expr() + return p.parse_multi_expr(is_top_level) } .comment { return p.comment() @@ -613,7 +613,7 @@ pub fn (mut p Parser) stmt() ast.Stmt { } // literals, 'if', etc. in here else { - return p.parse_multi_expr() + return p.parse_multi_expr(is_top_level) } } } @@ -733,11 +733,12 @@ pub fn (mut p Parser) warn_with_pos(s string, pos token.Position) { } } -fn (mut p Parser) parse_multi_expr() ast.Stmt { +fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt { // in here might be 1) multi-expr 2) multi-assign // 1, a, c ... } // multi-expression // a, mut b ... :=/= // multi-assign // collect things upto hard boundaries + tok_kind := p.tok.kind mut collected := []ast.Expr{} for { collected << p.expr(0) @@ -773,6 +774,11 @@ fn (mut p Parser) parse_multi_expr() ast.Stmt { }) pos: epos } + } else if is_top_level && collected.len > 0 && collected[0] !is ast.AssignExpr && + collected[0] !is ast.CallExpr && collected[0] !is ast.PostfixExpr && + !(collected[0] is ast.InfixExpr && (collected[0] as ast.InfixExpr).op == .left_shift) && + collected[0] !is ast.ComptimeCall && tok_kind !in [.key_if, .key_match] { + p.error_with_pos('expression evaluated but not used', collected[0].position()) } else { if collected.len == 1 { return ast.ExprStmt{ diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_a.out b/vlib/v/parser/tests/expr_evaluated_but_not_used_a.out new file mode 100644 index 000000000..faf61f6df --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_a.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/expr_evaluated_but_not_used_a.v:2:2: error: expression evaluated but not used + 1 | fn main() { + 2 | 'hello' + | ~~~~~~~ + 3 | } diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_a.vv b/vlib/v/parser/tests/expr_evaluated_but_not_used_a.vv new file mode 100644 index 000000000..c4b651520 --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_a.vv @@ -0,0 +1,3 @@ +fn main() { + 'hello' +} \ No newline at end of file diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_b.out b/vlib/v/parser/tests/expr_evaluated_but_not_used_b.out new file mode 100644 index 000000000..592abd5dd --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_b.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/expr_evaluated_but_not_used_b.v:2:2: error: expression evaluated but not used + 1 | fn main() { + 2 | 22 + | ~~ + 3 | } diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_b.vv b/vlib/v/parser/tests/expr_evaluated_but_not_used_b.vv new file mode 100644 index 000000000..cac3734e3 --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_b.vv @@ -0,0 +1,3 @@ +fn main() { + 22 +} \ No newline at end of file diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_c.out b/vlib/v/parser/tests/expr_evaluated_but_not_used_c.out new file mode 100644 index 000000000..98a9669d0 --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_c.out @@ -0,0 +1,7 @@ +vlib/v/parser/tests/expr_evaluated_but_not_used_c.v:3:5: error: expression evaluated but not used + 1 | fn main() { + 2 | a := 10 + 3 | `b` + | ~~~ + 4 | println(a) + 5 | } diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_c.vv b/vlib/v/parser/tests/expr_evaluated_but_not_used_c.vv new file mode 100644 index 000000000..863ce2fbf --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_c.vv @@ -0,0 +1,5 @@ +fn main() { + a := 10 + `b` + println(a) +} \ No newline at end of file diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_d.out b/vlib/v/parser/tests/expr_evaluated_but_not_used_d.out new file mode 100644 index 000000000..0f88cbbb6 --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_d.out @@ -0,0 +1,7 @@ +vlib/v/parser/tests/expr_evaluated_but_not_used_d.v:4:5: error: expression evaluated but not used + 2 | a := 1 + 3 | b := 2 + 4 | a+b + | ~~~ + 5 | println(a*b) + 6 | } diff --git a/vlib/v/parser/tests/expr_evaluated_but_not_used_d.vv b/vlib/v/parser/tests/expr_evaluated_but_not_used_d.vv new file mode 100644 index 000000000..d4cb9e154 --- /dev/null +++ b/vlib/v/parser/tests/expr_evaluated_but_not_used_d.vv @@ -0,0 +1,6 @@ +fn main() { + a := 1 + b := 2 + a+b + println(a*b) +} \ No newline at end of file -- 2.39.5