From 49ab935ae9268264fe40177690292ea890f6a7e3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 8 Aug 2023 14:56:12 +0100 Subject: Disallow `for in` in favour of `for _ in` --- src/parser.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/parser.cpp') 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); } -- cgit v1.2.3