parser: disallow index variable with range `for` (#6464)
parent
fb45e2e046
commit
3925c3fa20
|
@ -113,6 +113,9 @@ fn (mut p Parser) for_stmt() ast.Stmt {
|
|||
typ: table.int_type
|
||||
pos: val_var_pos
|
||||
})
|
||||
if key_var_name.len > 0 {
|
||||
p.error_with_pos('cannot declare index variable with range `for`', key_var_pos)
|
||||
}
|
||||
} else {
|
||||
// this type will be set in checker
|
||||
p.scope.register(val_var_name, ast.Var{
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
vlib/v/parser/tests/for.vv:1:5: error: cannot declare index variable with range `for`
|
||||
1 | for i, k in 0..5 {
|
||||
| ^
|
||||
2 | }
|
|
@ -0,0 +1,2 @@
|
|||
for i, k in 0..5 {
|
||||
}
|
Loading…
Reference in New Issue