diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 12ebdb888a..f4fe75e070 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3717,6 +3717,11 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) { right.pos) } } + if right is ast.Ident { + if right.is_mut { + c.error('unexpected `mut` on right-hand side of assignment', right.mut_pos) + } + } } if node.left.len != right_len { if right_first is ast.CallExpr { diff --git a/vlib/v/checker/tests/right_hand_side_mut.out b/vlib/v/checker/tests/right_hand_side_mut.out new file mode 100644 index 0000000000..c52488c03a --- /dev/null +++ b/vlib/v/checker/tests/right_hand_side_mut.out @@ -0,0 +1,7 @@ +vlib/v/checker/tests/right_hand_side_mut.vv:4:19: error: unexpected `mut` on right-hand side of assignment + 2 | mut flubbel := 123 + 3 | mut wubbel := 234 + 4 | _, _ := flubbel, mut wubbel + | ~~~ + 5 | print(wubbel) + 6 | } diff --git a/vlib/v/checker/tests/right_hand_side_mut.vv b/vlib/v/checker/tests/right_hand_side_mut.vv new file mode 100644 index 0000000000..919efd63ce --- /dev/null +++ b/vlib/v/checker/tests/right_hand_side_mut.vv @@ -0,0 +1,6 @@ +fn main() { + mut flubbel := 123 + mut wubbel := 234 + _, _ := flubbel, mut wubbel + print(wubbel) +}