Skip to content

Commit 2c55d46

Browse files
committed
Add diagnostics for empty statements (extra semicolon)
This change introduce diagnostics when there is a semicolon without statement ```cpp ; ``` Generates: ``` error: empty statement is not allowed - remove extra semicolon (at ';') ``` That also handles cases when there is double semicolon after a proper statemnt: ```cpp i := 0;; ``` Generates: ``` error: empty statement is not allowed - remove extra semicolon (at ';') ```
1 parent 8d7f7f5 commit 2c55d46

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/parse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,11 @@ class parser
44964496
)
44974497
-> std::unique_ptr<statement_node>
44984498
{
4499+
if (!done() && curr().type() == lexeme::Semicolon) {
4500+
error("empty statement is not allowed - remove extra semicolon");
4501+
return {};
4502+
}
4503+
44994504
auto n = std::make_unique<statement_node>();
45004505

45014506
// Now handle the rest of the statement

0 commit comments

Comments
 (0)