Skip to content

Commit 050069b

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 6a93b4c commit 050069b

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
@@ -4507,6 +4507,11 @@ class parser
45074507
)
45084508
-> std::unique_ptr<statement_node>
45094509
{
4510+
if (!done() && curr().type() == lexeme::Semicolon) {
4511+
error("empty statement is not allowed - remove extra semicolon");
4512+
return {};
4513+
}
4514+
45104515
auto n = std::make_unique<statement_node>();
45114516

45124517
// Now handle the rest of the statement

0 commit comments

Comments
 (0)