checker: disallow `mut` keyword in right-hand side of assignment (#12318)
parent
a32dae335a
commit
f801ef5e17
|
@ -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 {
|
||||
|
|
|
@ -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 | }
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {
|
||||
mut flubbel := 123
|
||||
mut wubbel := 234
|
||||
_, _ := flubbel, mut wubbel
|
||||
print(wubbel)
|
||||
}
|
Loading…
Reference in New Issue