diff options
| author | gingerBill <bill@gingerbill.org> | 2023-08-08 15:07:00 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-08-08 15:07:00 +0100 |
| commit | 2181e0fc279b396710ac9b864e566243d15eaf86 (patch) | |
| tree | c0b3af37b22e9a22cae4e101ec96c35039f24049 /src/parser.cpp | |
| parent | cd74cdfdaf5157704b836c8de1c32b5a03dddcae (diff) | |
Make `for init; ; {}` an error without an explicit cond or post
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index a2de85d84..695f5c792 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4339,6 +4339,13 @@ gb_internal Ast *parse_for_stmt(AstFile *f) { } cond = convert_stmt_to_expr(f, cond, str_lit("boolean expression")); + if (init != nullptr && + cond == nullptr && + post == nullptr) { + syntax_error(init, "'for init; ; {' without an explicit condition nor post statement is not allowed, please prefer something like 'for init; true; /**/{'"); + } + + return ast_for_stmt(f, token, init, cond, post, body); } |