From da7adb5b1b7fb1a7e5d955c84a8df4f951bb27f7 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 13 Aug 2020 13:10:43 +0300 Subject: [PATCH] ci: fix failing tests for compiler_errors_test.v --- vlib/v/checker/checker.v | 12 ++++++------ .../v/checker/tests/add_op_wrong_left_type_err_b.out | 2 +- .../checker/tests/add_op_wrong_right_type_err_b.out | 2 +- vlib/v/checker/tests/cannot_assign_array.out | 2 +- .../v/checker/tests/div_op_wrong_left_type_err_b.out | 2 +- .../checker/tests/div_op_wrong_right_type_err_b.out | 2 +- vlib/v/checker/tests/index_expr.out | 6 +++--- vlib/v/checker/tests/match_expr_else.vv | 6 +++--- .../checker/tests/minus_op_wrong_left_type_err_b.out | 2 +- .../tests/minus_op_wrong_right_type_err_b.out | 2 +- .../v/checker/tests/mod_op_wrong_left_type_err_b.out | 2 +- .../checker/tests/mod_op_wrong_right_type_err_b.out | 2 +- .../v/checker/tests/mul_op_wrong_left_type_err_b.out | 2 +- .../checker/tests/mul_op_wrong_right_type_err_b.out | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 272877ce68..d8f204ca09 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1737,12 +1737,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { assign_stmt.op !in [.assign, .decl_assign] && !c.inside_unsafe { c.warn('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos) } - // Dual sides check (compatibility check) - if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) && - right_sym.kind != .placeholder { - c.error('cannot assign `$right_sym.name` to `$left.str()` of type `$left_sym.name`', - right.position()) - } if c.pref.translated { // TODO fix this in C2V instead, for example cast enums to int before using `|` on them. // TODO replace all c.pref.translated checks with `$if !translated` for performance @@ -1795,6 +1789,12 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { } else {} } + // Dual sides check (compatibility check) + if !is_blank_ident && !c.check_types(right_type_unwrapped, left_type_unwrapped) && + right_sym.kind != .placeholder { + c.error('cannot assign `$right_sym.name` to `$left.str()` of type `$left_sym.name`', + right.position()) + } } } 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 bb221eb923..4aad4aa2b1 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,4 +1,4 @@ -vlib/v/checker/tests/add_op_wrong_left_type_err_b.v:2:13: 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 `[]int` and `any_int` 1 | fn main() { 2 | println([1,2,3] + 10) | ~~~~~~~ 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 2704f84399..86a9effdcf 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,4 +1,4 @@ -vlib/v/checker/tests/add_op_wrong_right_type_err_b.v:2:18: 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 `[]int` 1 | fn main() { 2 | println(10 + [1,2,3]) | ~~~~~~~ diff --git a/vlib/v/checker/tests/cannot_assign_array.out b/vlib/v/checker/tests/cannot_assign_array.out index fadf5e887f..ea105b75dd 100644 --- a/vlib/v/checker/tests/cannot_assign_array.out +++ b/vlib/v/checker/tests/cannot_assign_array.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/cannot_assign_array.v:9:11: error: cannot assign `array_fixed_f64_8` to `ctx.vb` of type `string` +vlib/v/checker/tests/cannot_assign_array.v:9:11: error: cannot assign `[]fixed_f64_8` to `ctx.vb` of type `string` 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]!! 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 d00607cb77..fb6a6c8fb0 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,4 +1,4 @@ -vlib/v/checker/tests/div_op_wrong_left_type_err_b.v:2:13: 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 `[]int` and `any_int` 1 | fn main() { 2 | println([1,2,3] / 10) | ~~~~~~~ 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 f10d236c1d..5a819b1844 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,4 +1,4 @@ -vlib/v/checker/tests/div_op_wrong_right_type_err_b.v:2:18: 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 `[]int` 1 | fn main() { 2 | println(10 / [1,2,3]) | ~~~~~~~ diff --git a/vlib/v/checker/tests/index_expr.out b/vlib/v/checker/tests/index_expr.out index 7f901ef53e..0700c6dfaa 100644 --- a/vlib/v/checker/tests/index_expr.out +++ b/vlib/v/checker/tests/index_expr.out @@ -5,7 +5,7 @@ vlib/v/checker/tests/index_expr.v:3:7: error: type `int` does not support indexi | ~~~ 4 | 5 | a := [2] -vlib/v/checker/tests/index_expr.v:6:7: error: non-integer index `array_int` (array type `array_int`) +vlib/v/checker/tests/index_expr.v:6:7: error: non-integer index `[]int` (array type `[]int`) 4 | 5 | a := [2] 6 | _ = a[a] @@ -26,14 +26,14 @@ vlib/v/checker/tests/index_expr.v:12:7: error: type `int` does not support index | ~~~~~ 13 | 14 | a := [2] -vlib/v/checker/tests/index_expr.v:15:7: error: non-integer index `array_int` (array type `array_int`) +vlib/v/checker/tests/index_expr.v:15:7: error: non-integer index `[]int` (array type `[]int`) 13 | 14 | a := [2] 15 | _ = a[a..] | ~~~~~ 16 | _ = a[..a] 17 | } -vlib/v/checker/tests/index_expr.v:16:7: error: non-integer index `array_int` (array type `array_int`) +vlib/v/checker/tests/index_expr.v:16:7: error: non-integer index `[]int` (array type `[]int`) 14 | a := [2] 15 | _ = a[a..] 16 | _ = a[..a] diff --git a/vlib/v/checker/tests/match_expr_else.vv b/vlib/v/checker/tests/match_expr_else.vv index e31e7199e9..7c5551e2e1 100644 --- a/vlib/v/checker/tests/match_expr_else.vv +++ b/vlib/v/checker/tests/match_expr_else.vv @@ -31,11 +31,11 @@ fn main() { string { 'string' } - f64 { - 'f64' - } else { 'else' } + f64 { + 'f64' + } } } 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 ecb834e24c..b7e7f6d095 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,4 +1,4 @@ -vlib/v/checker/tests/minus_op_wrong_left_type_err_b.v:2:13: 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 `[]int` and `any_int` 1 | fn main() { 2 | println([1,2,3] - 10) | ~~~~~~~ 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 b35e4014b4..b5edf14805 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,4 +1,4 @@ -vlib/v/checker/tests/minus_op_wrong_right_type_err_b.v:2:18: 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 `[]int` 1 | fn main() { 2 | println(10 - [1,2,3]) | ~~~~~~~ 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 4a00b7fd53..8a672ba350 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,4 +1,4 @@ -vlib/v/checker/tests/mod_op_wrong_left_type_err_b.v:2:10: 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 `[]int` and `any_int` 1 | fn main() { 2 | println([1,2,3] % 1) | ~~~~~~~ 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 b75db1d409..523bb8f2b7 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,4 +1,4 @@ -vlib/v/checker/tests/mod_op_wrong_right_type_err_b.v:2:14: 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 `[]int` 1 | fn main() { 2 | println(1 % [1,2,3]) | ~~~~~~~ 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 dca3eec12b..c53f8857b9 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,4 +1,4 @@ -vlib/v/checker/tests/mul_op_wrong_left_type_err_b.v:2:13: 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 `[]int` and `any_int` 1 | fn main() { 2 | println([1,2,3] * 10) | ~~~~~~~ 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 72f872432c..c504ca8dcf 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,4 +1,4 @@ -vlib/v/checker/tests/mul_op_wrong_right_type_err_b.v:2:18: 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 `[]int` 1 | fn main() { 2 | println(10 * [1,2,3]) | ~~~~~~~