Revert "parser: fix 'val in array' as condition in for stmt (fix #14440) (#14451)"

This reverts commit b482c0512b.
master
Delyan Angelov 2022-05-19 08:29:30 +03:00
parent b482c0512b
commit 809b1ca3b4
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 1 additions and 12 deletions

View File

@ -82,8 +82,7 @@ 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] && !(p.tok.kind == .name } else if p.peek_tok.kind in [.key_in, .comma]
&& 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

View File

@ -1,10 +0,0 @@
type TokenValue = rune | u64
fn test_for_cond() {
val := `+`
for val in [TokenValue(`+`), TokenValue(`-`)] {
println('ok')
break
}
assert true
}