mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
805a7d9713
commit
b482c0512b
@ -82,7 +82,8 @@ fn (mut p Parser) for_stmt() ast.Stmt {
|
|||||||
}
|
}
|
||||||
p.close_scope()
|
p.close_scope()
|
||||||
return for_c_stmt
|
return for_c_stmt
|
||||||
} else if p.peek_tok.kind in [.key_in, .comma]
|
} else if (p.peek_tok.kind in [.key_in, .comma] && !(p.tok.kind == .name
|
||||||
|
&& p.peek_tok.kind == .key_in && p.scope.known_var(p.tok.lit)))
|
||||||
|| (p.tok.kind == .key_mut && p.peek_token(2).kind in [.key_in, .comma]) {
|
|| (p.tok.kind == .key_mut && p.peek_token(2).kind in [.key_in, .comma]) {
|
||||||
// `for i in vals`, `for i in start .. end`, `for mut user in users`, `for i, mut user in users`
|
// `for i in vals`, `for i in start .. end`, `for mut user in users`, `for i, mut user in users`
|
||||||
mut val_is_mut := p.tok.kind == .key_mut
|
mut val_is_mut := p.tok.kind == .key_mut
|
||||||
|
10
vlib/v/tests/for_cond_test.v
Normal file
10
vlib/v/tests/for_cond_test.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type TokenValue = rune | u64
|
||||||
|
|
||||||
|
fn test_for_cond() {
|
||||||
|
val := `+`
|
||||||
|
for val in [TokenValue(`+`), TokenValue(`-`)] {
|
||||||
|
println('ok')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user