mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: disallow index variable with range for
(#6464)
This commit is contained in:
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{
|
||||
|
4
vlib/v/parser/tests/for.out
Normal file
4
vlib/v/parser/tests/for.out
Normal file
@ -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 | }
|
2
vlib/v/parser/tests/for.vv
Normal file
2
vlib/v/parser/tests/for.vv
Normal file
@ -0,0 +1,2 @@
|
||||
for i, k in 0..5 {
|
||||
}
|
Loading…
Reference in New Issue
Block a user