mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-06 06:38:20 +00:00
When parsing an incorrect for loop, remove assert
// caused by this: ``` for a b, c := d() ```
This commit is contained in:
@@ -933,9 +933,10 @@ parse_for_stmt :: proc(p: ^Parser) -> ^ast.Stmt {
|
||||
next_token := peek_token(p)
|
||||
if next_token.kind == .In || next_token.kind == .Comma {
|
||||
cond = parse_simple_stmt(p, {.In})
|
||||
as := cond.derived_stmt.(^ast.Assign_Stmt)
|
||||
assert(as.op.kind == .In)
|
||||
is_range = true
|
||||
if as, ok := cond.derived_stmt.(^ast.Assign_Stmt); ok {
|
||||
assert(as.op.kind == .In)
|
||||
is_range = true
|
||||
}
|
||||
break general_conds
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4951,8 +4951,9 @@ gb_internal Ast *parse_for_stmt(AstFile *f) {
|
||||
Token next_token = peek_token(f);
|
||||
if (next_token.kind == Token_in || next_token.kind == Token_Comma) {
|
||||
cond = parse_simple_stmt(f, StmtAllowFlag_In);
|
||||
GB_ASSERT(cond->kind == Ast_AssignStmt && cond->AssignStmt.op.kind == Token_in);
|
||||
is_range = true;
|
||||
if (cond->kind == Ast_AssignStmt && cond->AssignStmt.op.kind == Token_in) {
|
||||
is_range = true;
|
||||
}
|
||||
goto range_skip;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user