mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: disallow mut
keyword in right-hand side of assignment (#12318)
This commit is contained in:
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 {
|
||||
|
7
vlib/v/checker/tests/right_hand_side_mut.out
Normal file
7
vlib/v/checker/tests/right_hand_side_mut.out
Normal file
@ -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 | }
|
6
vlib/v/checker/tests/right_hand_side_mut.vv
Normal file
6
vlib/v/checker/tests/right_hand_side_mut.vv
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
mut flubbel := 123
|
||||
mut wubbel := 234
|
||||
_, _ := flubbel, mut wubbel
|
||||
print(wubbel)
|
||||
}
|
Loading…
Reference in New Issue
Block a user