checker: add error for arr1 <,>,>=,<= arr2 (#6243)
parent
88f75fc1d6
commit
39bf02ea68
|
@ -593,6 +593,11 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
|||
return_type = promoted_type
|
||||
}
|
||||
}
|
||||
.gt, .lt, .ge, .le {
|
||||
if left.kind in [.array, .array_fixed] && right.kind in [.array, .array_fixed] {
|
||||
c.error('only `==` and `!=` are defined on arrays', infix_expr.pos)
|
||||
}
|
||||
}
|
||||
.left_shift {
|
||||
if left.kind == .array {
|
||||
// `array << elm`
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
vlib/v/checker/tests/array_cmp_err.vv:2:26: error: only `==` and `!=` are defined on arrays
|
||||
1 | fn main() {
|
||||
2 | println([2, 3, 4, 6] < [2, 5])
|
||||
| ^
|
||||
3 | println([2, 3, 4, 6] > [2, 5])
|
||||
4 | println([2, 3, 1, 6] >= [3, 5, 7])
|
||||
vlib/v/checker/tests/array_cmp_err.vv:3:26: error: only `==` and `!=` are defined on arrays
|
||||
1 | fn main() {
|
||||
2 | println([2, 3, 4, 6] < [2, 5])
|
||||
3 | println([2, 3, 4, 6] > [2, 5])
|
||||
| ^
|
||||
4 | println([2, 3, 1, 6] >= [3, 5, 7])
|
||||
5 | println([2, 3, 6, 8] <= [2, 5, 8, 9])
|
||||
vlib/v/checker/tests/array_cmp_err.vv:4:26: error: only `==` and `!=` are defined on arrays
|
||||
2 | println([2, 3, 4, 6] < [2, 5])
|
||||
3 | println([2, 3, 4, 6] > [2, 5])
|
||||
4 | println([2, 3, 1, 6] >= [3, 5, 7])
|
||||
| ~~
|
||||
5 | println([2, 3, 6, 8] <= [2, 5, 8, 9])
|
||||
6 | }
|
||||
vlib/v/checker/tests/array_cmp_err.vv:5:26: error: only `==` and `!=` are defined on arrays
|
||||
3 | println([2, 3, 4, 6] > [2, 5])
|
||||
4 | println([2, 3, 1, 6] >= [3, 5, 7])
|
||||
5 | println([2, 3, 6, 8] <= [2, 5, 8, 9])
|
||||
| ~~
|
||||
6 | }
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
println([2, 3, 4, 6] < [2, 5])
|
||||
println([2, 3, 4, 6] > [2, 5])
|
||||
println([2, 3, 1, 6] >= [3, 5, 7])
|
||||
println([2, 3, 6, 8] <= [2, 5, 8, 9])
|
||||
}
|
Loading…
Reference in New Issue