diff options
| author | gingerBill <bill@gingerbill.org> | 2023-08-08 14:56:12 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-08-08 14:56:12 +0100 |
| commit | 49ab935ae9268264fe40177690292ea890f6a7e3 (patch) | |
| tree | a39862556944b3637c2f1c3f9737a94bb0d37491 /src | |
| parent | 939bf4bb5dd2c94f0e67d3193becf56ec9c7abf1 (diff) | |
Disallow `for in` in favour of `for _ in`
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 56d1e2d6c..bfbd7b32a 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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); } |