mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
33d379d530
commit
1032cf5c04
@ -119,9 +119,11 @@ fn (mut c Checker) for_in_stmt(mut node ast.ForInStmt) {
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
root_ident := node.cond.root_ident() or { node.cond.expr as ast.Ident }
|
||||
if !(root_ident.obj as ast.Var).is_mut {
|
||||
c.error('field `$node.cond.field_name` is immutable, it cannot be changed',
|
||||
node.cond.pos)
|
||||
if root_ident.kind != .unresolved {
|
||||
if !(root_ident.obj as ast.Var).is_mut {
|
||||
c.error('field `$node.cond.field_name` is immutable, it cannot be changed',
|
||||
node.cond.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {}
|
||||
|
13
vlib/v/checker/tests/for_in_invalid_identifier.out
Normal file
13
vlib/v/checker/tests/for_in_invalid_identifier.out
Normal file
@ -0,0 +1,13 @@
|
||||
vlib/v/checker/tests/for_in_invalid_identifier.vv:2:26: error: undefined ident: `s`
|
||||
1 | fn main() {
|
||||
2 | for index, mut value in s.statements {
|
||||
| ^
|
||||
3 | println('Hello $index $value')
|
||||
4 | }
|
||||
vlib/v/checker/tests/for_in_invalid_identifier.vv:3:26: error: no known default format for type `void`
|
||||
1 | fn main() {
|
||||
2 | for index, mut value in s.statements {
|
||||
3 | println('Hello $index $value')
|
||||
| ~~~~~
|
||||
4 | }
|
||||
5 | }
|
5
vlib/v/checker/tests/for_in_invalid_identifier.vv
Normal file
5
vlib/v/checker/tests/for_in_invalid_identifier.vv
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
for index, mut value in s.statements {
|
||||
println('Hello $index $value')
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user