checker: better << error

pull/4683/head
Alexander Medvednikov 2020-05-02 16:48:49 +02:00
parent fca11dd441
commit b0018ed594
2 changed files with 5 additions and 6 deletions

View File

@ -399,7 +399,7 @@ pub fn (mut c Checker) infix_expr(infix_expr mut ast.InfixExpr) table.Type {
// []T << []T // []T << []T
return table.void_type return table.void_type
} }
c.error('cannot shift type $right.name into $left.name', infix_expr.right.position()) c.error('cannot append `$right.name` to `$left.name`', infix_expr.right.position())
return table.void_type return table.void_type
} else if !left.is_int() { } else if !left.is_int() {
c.error('cannot shift type $right.name into non-integer type $left.name', infix_expr.left.position()) c.error('cannot shift type $right.name into non-integer type $left.name', infix_expr.left.position())
@ -1035,8 +1035,7 @@ pub fn (mut c Checker) assign_stmt(assign_stmt mut ast.AssignStmt) {
assign_stmt.pos) assign_stmt.pos)
return return
} }
} } else {
else {
if assign_stmt.left.len != assign_stmt.right.len { if assign_stmt.left.len != assign_stmt.right.len {
c.error('assignment mismatch: $assign_stmt.left.len variable(s) $assign_stmt.right.len value(s)', c.error('assignment mismatch: $assign_stmt.left.len variable(s) $assign_stmt.right.len value(s)',
assign_stmt.pos) assign_stmt.pos)

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/left_shift_err.v:3:7: error: cannot shift type string into array_int vlib/v/checker/tests/left_shift_err.v:3:7: error: cannot append `string` to `array_int`
1 | fn main() { 1 | fn main() {
2 | mut l := []int{} 2 | mut l := []int{}
3 | l << 'test' 3 | l << 'test'