ci: fix failing tests for compiler_errors_test.v

pull/6121/head
Delyan Angelov 2020-08-13 13:10:43 +03:00
parent fd5a76a8ad
commit da7adb5b1b
14 changed files with 23 additions and 23 deletions

View File

@ -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 { assign_stmt.op !in [.assign, .decl_assign] && !c.inside_unsafe {
c.warn('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos) 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 { if c.pref.translated {
// TODO fix this in C2V instead, for example cast enums to int before using `|` on them. // 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 // 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 {} 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())
}
} }
} }

View File

@ -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() { 1 | fn main() {
2 | println([1,2,3] + 10) 2 | println([1,2,3] + 10)
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println(10 + [1,2,3]) 2 | println(10 + [1,2,3])
| ~~~~~~~ | ~~~~~~~

View File

@ -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{} 7 | mut ctx := Context{}
8 | x := 2.32 8 | x := 2.32
9 | ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!! 9 | ctx.vb = [1.1, x, 3.3, 4.4, 5.0, 6.0, 7.0, 8.9]!!

View File

@ -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() { 1 | fn main() {
2 | println([1,2,3] / 10) 2 | println([1,2,3] / 10)
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println(10 / [1,2,3]) 2 | println(10 / [1,2,3])
| ~~~~~~~ | ~~~~~~~

View File

@ -5,7 +5,7 @@ vlib/v/checker/tests/index_expr.v:3:7: error: type `int` does not support indexi
| ~~~ | ~~~
4 | 4 |
5 | a := [2] 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 | 4 |
5 | a := [2] 5 | a := [2]
6 | _ = a[a] 6 | _ = a[a]
@ -26,14 +26,14 @@ vlib/v/checker/tests/index_expr.v:12:7: error: type `int` does not support index
| ~~~~~ | ~~~~~
13 | 13 |
14 | a := [2] 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 | 13 |
14 | a := [2] 14 | a := [2]
15 | _ = a[a..] 15 | _ = a[a..]
| ~~~~~ | ~~~~~
16 | _ = a[..a] 16 | _ = a[..a]
17 | } 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] 14 | a := [2]
15 | _ = a[a..] 15 | _ = a[a..]
16 | _ = a[..a] 16 | _ = a[..a]

View File

@ -31,11 +31,11 @@ fn main() {
string { string {
'string' 'string'
} }
f64 {
'f64'
}
else { else {
'else' 'else'
} }
f64 {
'f64'
}
} }
} }

View File

@ -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() { 1 | fn main() {
2 | println([1,2,3] - 10) 2 | println([1,2,3] - 10)
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println(10 - [1,2,3]) 2 | println(10 - [1,2,3])
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println([1,2,3] % 1) 2 | println([1,2,3] % 1)
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println(1 % [1,2,3]) 2 | println(1 % [1,2,3])
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println([1,2,3] * 10) 2 | println([1,2,3] * 10)
| ~~~~~~~ | ~~~~~~~

View File

@ -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() { 1 | fn main() {
2 | println(10 * [1,2,3]) 2 | println(10 * [1,2,3])
| ~~~~~~~ | ~~~~~~~