Disallow for in in favour of for _ in

This commit is contained in:
gingerBill
2023-08-08 14:56:12 +01:00
parent 939bf4bb5d
commit 49ab935ae9
7 changed files with 13 additions and 10 deletions

View File

@@ -4271,6 +4271,8 @@ gb_internal Ast *parse_for_stmt(AstFile *f) {
if (f->curr_token.kind == Token_in) {
Token in_token = expect_token(f, Token_in);
syntax_error(in_token, "Prefer 'for _ in' over 'for in'");
Ast *rhs = nullptr;
bool prev_allow_range = f->allow_range;
f->allow_range = true;
@@ -4282,6 +4284,7 @@ gb_internal Ast *parse_for_stmt(AstFile *f) {
} else {
body = parse_block_stmt(f, false);
}
return ast_range_stmt(f, token, {}, in_token, rhs, body);
}