diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 52b0c1ffa9..6e969f094b 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -106,7 +106,7 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr, left_comments []ast.Comme for r in right { has_cross_var = p.check_cross_variables(left, r) if op !in [.assign, .decl_assign] { - p.error('unexpected $op.str(), expecting := or = or comma') + p.error_with_pos('unexpected $op.str(), expecting := or = or comma', pos) return ast.Stmt{} } if has_cross_var { diff --git a/vlib/v/parser/tests/multi_argumented_assign_err.out b/vlib/v/parser/tests/multi_argumented_assign_err.out new file mode 100644 index 0000000000..4e1a64ce1e --- /dev/null +++ b/vlib/v/parser/tests/multi_argumented_assign_err.out @@ -0,0 +1,7 @@ +vlib/v/parser/tests/multi_argumented_assign_err.vv:3:10: error: unexpected +=, expecting := or = or comma + 1 | fn main() { + 2 | mut a, mut b, mut c := 0,1, 2 + 3 | a, b, c += 1, 2, 4 + | ~~ + 4 | println('$a $b $c') + 5 | } diff --git a/vlib/v/parser/tests/multi_argumented_assign_err.vv b/vlib/v/parser/tests/multi_argumented_assign_err.vv new file mode 100644 index 0000000000..26257b8833 --- /dev/null +++ b/vlib/v/parser/tests/multi_argumented_assign_err.vv @@ -0,0 +1,5 @@ +fn main() { + mut a, mut b, mut c := 0,1, 2 + a, b, c += 1, 2, 4 + println('$a $b $c') +}