From a8dc0ccbcdb7717da1f9c93dead252eabcebccd0 Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 21 Apr 2020 19:26:02 +0800 Subject: [PATCH] checker: add more op checks --- vlib/v/checker/checker.v | 17 +++++++++++++++-- .../inout/add_op_wrong_left_type_err_a.out | 6 ++++++ .../tests/inout/add_op_wrong_left_type_err_a.vv | 4 ++++ .../inout/add_op_wrong_left_type_err_b.out | 5 +++++ .../tests/inout/add_op_wrong_left_type_err_b.vv | 3 +++ .../inout/add_op_wrong_left_type_err_c.out | 6 ++++++ .../tests/inout/add_op_wrong_left_type_err_c.vv | 4 ++++ .../inout/add_op_wrong_right_type_err_a.out | 6 ++++++ .../inout/add_op_wrong_right_type_err_a.vv | 4 ++++ .../inout/add_op_wrong_right_type_err_b.out | 5 +++++ .../inout/add_op_wrong_right_type_err_b.vv | 3 +++ .../inout/add_op_wrong_right_type_err_c.out | 6 ++++++ .../inout/add_op_wrong_right_type_err_c.vv | 4 ++++ .../inout/div_op_wrong_left_type_err_a.out | 6 ++++++ .../tests/inout/div_op_wrong_left_type_err_a.vv | 4 ++++ .../inout/div_op_wrong_left_type_err_b.out | 5 +++++ .../tests/inout/div_op_wrong_left_type_err_b.vv | 3 +++ .../inout/div_op_wrong_left_type_err_c.out | 6 ++++++ .../tests/inout/div_op_wrong_left_type_err_c.vv | 4 ++++ .../inout/div_op_wrong_right_type_err_a.out | 6 ++++++ .../inout/div_op_wrong_right_type_err_a.vv | 4 ++++ .../inout/div_op_wrong_right_type_err_b.out | 5 +++++ .../inout/div_op_wrong_right_type_err_b.vv | 3 +++ .../inout/div_op_wrong_right_type_err_c.out | 6 ++++++ .../inout/div_op_wrong_right_type_err_c.vv | 4 ++++ .../inout/minus_op_wrong_left_type_err_a.out | 6 ++++++ .../inout/minus_op_wrong_left_type_err_a.vv | 4 ++++ .../inout/minus_op_wrong_left_type_err_b.out | 5 +++++ .../inout/minus_op_wrong_left_type_err_b.vv | 3 +++ .../inout/minus_op_wrong_left_type_err_c.out | 6 ++++++ .../inout/minus_op_wrong_left_type_err_c.vv | 4 ++++ .../inout/minus_op_wrong_right_type_err_a.out | 6 ++++++ .../inout/minus_op_wrong_right_type_err_a.vv | 4 ++++ .../inout/minus_op_wrong_right_type_err_b.out | 5 +++++ .../inout/minus_op_wrong_right_type_err_b.vv | 3 +++ .../inout/minus_op_wrong_right_type_err_c.out | 6 ++++++ .../inout/minus_op_wrong_right_type_err_c.vv | 4 ++++ .../tests/inout/mod_op_wrong_left_type_err.out | 5 ----- .../inout/mod_op_wrong_left_type_err_a.out | 5 +++++ ...e_err.vv => mod_op_wrong_left_type_err_a.vv} | 2 +- .../inout/mod_op_wrong_left_type_err_b.out | 5 +++++ .../tests/inout/mod_op_wrong_left_type_err_b.vv | 3 +++ .../inout/mod_op_wrong_left_type_err_c.out | 6 ++++++ .../tests/inout/mod_op_wrong_left_type_err_c.vv | 5 +++++ .../inout/mod_op_wrong_left_type_err_d.out | 6 ++++++ .../tests/inout/mod_op_wrong_left_type_err_d.vv | 4 ++++ .../tests/inout/mod_op_wrong_right_type_err.out | 5 ----- .../inout/mod_op_wrong_right_type_err_a.out | 5 +++++ ..._err.vv => mod_op_wrong_right_type_err_a.vv} | 2 +- .../inout/mod_op_wrong_right_type_err_b.out | 5 +++++ .../inout/mod_op_wrong_right_type_err_b.vv | 3 +++ .../inout/mod_op_wrong_right_type_err_c.out | 6 ++++++ .../inout/mod_op_wrong_right_type_err_c.vv | 5 +++++ .../inout/mod_op_wrong_right_type_err_d.out | 6 ++++++ .../inout/mod_op_wrong_right_type_err_d.vv | 4 ++++ .../inout/mul_op_wrong_left_type_err_a.out | 6 ++++++ .../tests/inout/mul_op_wrong_left_type_err_a.vv | 4 ++++ .../inout/mul_op_wrong_left_type_err_b.out | 5 +++++ .../tests/inout/mul_op_wrong_left_type_err_b.vv | 3 +++ .../inout/mul_op_wrong_left_type_err_c.out | 6 ++++++ .../tests/inout/mul_op_wrong_left_type_err_c.vv | 4 ++++ .../inout/mul_op_wrong_right_type_err_a.out | 6 ++++++ .../inout/mul_op_wrong_right_type_err_a.vv | 4 ++++ .../inout/mul_op_wrong_right_type_err_b.out | 5 +++++ .../inout/mul_op_wrong_right_type_err_b.vv | 3 +++ .../inout/mul_op_wrong_right_type_err_c.out | 6 ++++++ .../inout/mul_op_wrong_right_type_err_c.vv | 4 ++++ 67 files changed, 309 insertions(+), 14 deletions(-) create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.vv delete mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.out rename vlib/v/checker/tests/inout/{mod_op_wrong_left_type_err.vv => mod_op_wrong_left_type_err_a.vv} (91%) create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.vv delete mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.out rename vlib/v/checker/tests/inout/{mod_op_wrong_right_type_err.vv => mod_op_wrong_right_type_err_a.vv} (91%) create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.out create mode 100644 vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.vv create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.out create mode 100644 vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.vv diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 445ce7a5ae..6491370da4 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -313,9 +313,22 @@ pub fn (c mut Checker) infix_expr(infix_expr mut ast.InfixExpr) table.Type { } if infix_expr.op == .mod { if left.is_int() && !right.is_int() { - c.error('right type of `${infix_expr.op.str()}` cannot be non-integer type $right.name', infix_expr.right.position()) + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.right.position()) } else if !left.is_int() && right.is_int() { - c.error('left type of `${infix_expr.op.str()}` cannot be non-integer type $left.name', infix_expr.left.position()) + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.left.position()) + } else if left.kind in [.f32, .f64, .string, .array, .array_fixed, .map, .struct_] && + !left.has_method(infix_expr.op.str()) { + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.left.position()) + } else if right.kind in [.f32, .f64, .string, .array, .array_fixed, .map, .struct_] && + !right.has_method(infix_expr.op.str()) { + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.right.position()) + } + } + if infix_expr.op in [.plus, .minus, .mul, .div] { + if left.kind in [.array, .array_fixed, .map, .struct_] && !left.has_method(infix_expr.op.str()) { + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.left.position()) + } else if right.kind in [.array, .array_fixed, .map, .struct_] && !right.has_method(infix_expr.op.str()) { + c.error('mismatched types `$left.name` and `$right.name`', infix_expr.right.position()) } } if left_type == table.bool_type && !(infix_expr.op in [.eq, .ne, .logical_or, .and]) { diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.out new file mode 100644 index 0000000000..14543dbe80 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int` + 1| struct A{} + 2| fn main() { + 3| A{} + 10 + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.vv new file mode 100644 index 0000000000..5a3069eb14 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + A{} + 10 +} diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.out new file mode 100644 index 0000000000..8d63042b98 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int` + 1| fn main() { + 2| [1,2,3] + 10 + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000000..f75bfb8c6a --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + [1,2,3] + 10 +} diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.out new file mode 100644 index 0000000000..7dfc066c43 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int` + 1| fn main() { + 2| a := map[string]int + 3| a + 10 + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.vv new file mode 100644 index 0000000000..497b3f95aa --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_left_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + a + 10 +} diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.out new file mode 100644 index 0000000000..8f9cb31f8d --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A` + 1| struct A{} + 2| fn main() { + 3| 10 + A{} + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.vv new file mode 100644 index 0000000000..3a98920ac4 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + 10 + A{} +} diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.out new file mode 100644 index 0000000000..a55f7a8fe0 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int` + 1| fn main() { + 2| 10 + [1,2,3] + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000000..ad55530f74 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + 10 + [1,2,3] +} diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.out new file mode 100644 index 0000000000..051e86c9d4 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int` + 1| fn main() { + 2| a := map[string]int + 3| 10 + a + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.vv new file mode 100644 index 0000000000..1be1402479 --- /dev/null +++ b/vlib/v/checker/tests/inout/add_op_wrong_right_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + 10 + a +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.out new file mode 100644 index 0000000000..0a472f66cb --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int` + 1| struct A{} + 2| fn main() { + 3| A{} / 10 + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.vv new file mode 100644 index 0000000000..d52d510b99 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + A{} / 10 +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.out new file mode 100644 index 0000000000..720ebecdf0 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int` + 1| fn main() { + 2| [1,2,3] / 10 + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000000..4dc9bc6ac6 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + [1,2,3] / 10 +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.out new file mode 100644 index 0000000000..8cc5cf2e86 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int` + 1| fn main() { + 2| a := map[string]int + 3| a / 10 + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.vv new file mode 100644 index 0000000000..b326b68729 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_left_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + a / 10 +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.out new file mode 100644 index 0000000000..5fbdf8d206 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A` + 1| struct A{} + 2| fn main() { + 3| 10 / A{} + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.vv new file mode 100644 index 0000000000..ae12960e94 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + 10 / A{} +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.out new file mode 100644 index 0000000000..d4515b0bd7 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int` + 1| fn main() { + 2| 10 / [1,2,3] + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000000..0870d80a3d --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + 10 / [1,2,3] +} diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.out new file mode 100644 index 0000000000..3df975ccb3 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int` + 1| fn main() { + 2| a := map[string]int + 3| 10 / a + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.vv new file mode 100644 index 0000000000..f784c8c0e3 --- /dev/null +++ b/vlib/v/checker/tests/inout/div_op_wrong_right_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + 10 / a +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.out new file mode 100644 index 0000000000..29b8a0ca9e --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int` + 1| struct A{} + 2| fn main() { + 3| A{} - 10 + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.vv new file mode 100644 index 0000000000..3c1a5c0894 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + A{} - 10 +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.out new file mode 100644 index 0000000000..10d3b9e4ed --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int` + 1| fn main() { + 2| [1,2,3] - 10 + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000000..25a7ed323e --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + [1,2,3] - 10 +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.out new file mode 100644 index 0000000000..feb50e82b4 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int` + 1| fn main() { + 2| a := map[string]int + 3| a - 10 + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.vv new file mode 100644 index 0000000000..083d54b3a9 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_left_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + a - 10 +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.out new file mode 100644 index 0000000000..c47bfd697c --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A` + 1| struct A{} + 2| fn main() { + 3| 10 - A{} + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.vv new file mode 100644 index 0000000000..bce597e6d5 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + 10 - A{} +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.out new file mode 100644 index 0000000000..d24d801ff9 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int` + 1| fn main() { + 2| 10 - [1,2,3] + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000000..d001d9bd2b --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + 10 - [1,2,3] +} diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.out new file mode 100644 index 0000000000..2523a80052 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int` + 1| fn main() { + 2| a := map[string]int + 3| 10 - a + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.vv new file mode 100644 index 0000000000..7c73df41f3 --- /dev/null +++ b/vlib/v/checker/tests/inout/minus_op_wrong_right_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + 10 - a +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.out b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.out deleted file mode 100644 index 15db2ffbe9..0000000000 --- a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.out +++ /dev/null @@ -1,5 +0,0 @@ -vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.v:2:2: error: left type of `%` cannot be non-integer type f64 - 1| fn main() { - 2| 0.5 % 1 - ~~~ - 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.out new file mode 100644 index 0000000000..67e242b595 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.v:2:2: error: mismatched types `f64` and `int` + 1| fn main() { + 2| 0.5 % 1 + ~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.vv b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.vv similarity index 91% rename from vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.vv rename to vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.vv index 800b101fcd..175974c6a0 100644 --- a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err.vv +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_a.vv @@ -1,3 +1,3 @@ fn main() { 0.5 % 1 -} \ No newline at end of file +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.out new file mode 100644 index 0000000000..8753aa9e3d --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.v:2:2: error: mismatched types `array_int` and `int` + 1| fn main() { + 2| [1,2,3] % 1 + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000000..8e33fbbb6f --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + [1,2,3] % 1 +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.out new file mode 100644 index 0000000000..3fd24c0b36 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.v:4:2: error: mismatched types `A` and `int` + 2| fn main() { + 3| a := A{} + 4| a % 1 + ^ + 5| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.vv new file mode 100644 index 0000000000..7f88eafd62 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_c.vv @@ -0,0 +1,5 @@ +struct A{} +fn main() { + a := A{} + a % 1 +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.out b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.out new file mode 100644 index 0000000000..a8ec677e3b --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.v:3:2: error: mismatched types `map_string_int` and `int` + 1| fn main() { + 2| a := map[string]int + 3| a % 1 + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.vv b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.vv new file mode 100644 index 0000000000..d4f76d671f --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_left_type_err_d.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + a % 1 +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.out b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.out deleted file mode 100644 index e4d56aafac..0000000000 --- a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.out +++ /dev/null @@ -1,5 +0,0 @@ -vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.v:2:6: error: right type of `%` cannot be non-integer type f64 - 1| fn main() { - 2| 1 % 0.5 - ~~~ - 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.out new file mode 100644 index 0000000000..b6cdbf5501 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.v:2:6: error: mismatched types `int` and `f64` + 1| fn main() { + 2| 1 % 0.5 + ~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.vv b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.vv similarity index 91% rename from vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.vv rename to vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.vv index 0ee36d9b9b..9db1022bca 100644 --- a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err.vv +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_a.vv @@ -1,3 +1,3 @@ fn main() { 1 % 0.5 -} \ No newline at end of file +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.out new file mode 100644 index 0000000000..ebd4bded5d --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.v:2:6: error: mismatched types `int` and `array_int` + 1| fn main() { + 2| 1 % [1,2,3] + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000000..2322fed1e3 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + 1 % [1,2,3] +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.out new file mode 100644 index 0000000000..60c7fbb0f6 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.v:4:6: error: mismatched types `int` and `A` + 2| fn main() { + 3| a := A{} + 4| 1 % a + ^ + 5| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.vv new file mode 100644 index 0000000000..15c4feddb8 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_c.vv @@ -0,0 +1,5 @@ +struct A{} +fn main() { + a := A{} + 1 % a +} diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.out b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.out new file mode 100644 index 0000000000..9dc25c38b9 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.v:3:6: error: mismatched types `int` and `map_string_int` + 1| fn main() { + 2| a := map[string]int + 3| 1 % a + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.vv b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.vv new file mode 100644 index 0000000000..ca3730dec0 --- /dev/null +++ b/vlib/v/checker/tests/inout/mod_op_wrong_right_type_err_d.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + 1 % a +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.out b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.out new file mode 100644 index 0000000000..fa9b8298c5 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.v:3:5: error: mismatched types `A` and `int` + 1| struct A{} + 2| fn main() { + 3| A{} * 10 + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.vv b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.vv new file mode 100644 index 0000000000..a3afb73839 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + A{} * 10 +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.out b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.out new file mode 100644 index 0000000000..9872130bde --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.v:2:5: error: mismatched types `array_int` and `int` + 1| fn main() { + 2| [1,2,3] * 10 + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.vv b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.vv new file mode 100644 index 0000000000..d3db01f01f --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + [1,2,3] * 10 +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.out b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.out new file mode 100644 index 0000000000..4cf9da0fb7 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.v:3:5: error: mismatched types `map_string_int` and `int` + 1| fn main() { + 2| a := map[string]int + 3| a * 10 + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.vv b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.vv new file mode 100644 index 0000000000..315f882862 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_left_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + a * 10 +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.out b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.out new file mode 100644 index 0000000000..f5031c40c3 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.v:3:10: error: mismatched types `int` and `A` + 1| struct A{} + 2| fn main() { + 3| 10 * A{} + ~~~ + 4| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.vv b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.vv new file mode 100644 index 0000000000..452d5b5cd2 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_a.vv @@ -0,0 +1,4 @@ +struct A{} +fn main() { + 10 * A{} +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.out b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.out new file mode 100644 index 0000000000..e084e90a86 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.v:2:10: error: mismatched types `int` and `array_int` + 1| fn main() { + 2| 10 * [1,2,3] + ~~~~~~~ + 3| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.vv b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.vv new file mode 100644 index 0000000000..29a136b9e5 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_b.vv @@ -0,0 +1,3 @@ +fn main() { + 10 * [1,2,3] +} diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.out b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.out new file mode 100644 index 0000000000..1d4fc41407 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.out @@ -0,0 +1,6 @@ +vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.v:3:10: error: mismatched types `int` and `map_string_int` + 1| fn main() { + 2| a := map[string]int + 3| 10 * a + ^ + 4| } diff --git a/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.vv b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.vv new file mode 100644 index 0000000000..80ef961943 --- /dev/null +++ b/vlib/v/checker/tests/inout/mul_op_wrong_right_type_err_c.vv @@ -0,0 +1,4 @@ +fn main() { + a := map[string]int + 10 * a +}