Skip to content

Commit d41fc77

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 6701b64 commit d41fc77

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
@@ -4394,6 +4394,11 @@ class parser
43944394
)
43954395
-> std::unique_ptr<statement_node>
43964396
{
4397+
if (!done() && curr().type() == lexeme::Semicolon) {
4398+
error("empty statement is not allowed - remove extra semicolon");
4399+
return {};
4400+
}
4401+
43974402
auto n = std::make_unique<statement_node>();
43984403

43994404
// Now handle the rest of the statement

0 commit comments

Comments
 (0)