Skip to content

Commit af3c071

Browse files
committed
Add diagnostics for semicolon at the end of while body
This change introduce diagnostics when there is a semicolon at the end of the while loop body: ```cpp i := 0; while i* < container.size() next i++ { std::cout << container[i] << std::endl; }; ``` generates: ``` error: while loop body shall not end with a semicolon (at ';') ```
1 parent f92a34c commit af3c071

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

source/parse.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4095,6 +4095,10 @@ class parser
40954095
if (!handle_logical_expression ()) { return {}; }
40964096
if (!handle_optional_next_clause()) { return {}; }
40974097
if (!handle_compound_statement ()) { return {}; }
4098+
if (!done() && curr().type() == lexeme::Semicolon) {
4099+
error("while loop body shall not end with a semicolon");
4100+
return {};
4101+
}
40984102
return n;
40994103
}
41004104

0 commit comments

Comments
 (0)