When parsing an incorrect for loop, remove assert

// caused by this:
```
for a
b, c := d()
```
This commit is contained in:
gingerBill
2026-03-30 11:50:59 +01:00
parent 377a9c7be8
commit 4dceffd049
2 changed files with 7 additions and 5 deletions

View File

@@ -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
}
}

View File

@@ -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;
}
}