Skip to content

Commit e7c25ea

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 b2f019c commit e7c25ea

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
@@ -4725,6 +4725,11 @@ class parser
47254725
)
47264726
-> std::unique_ptr<statement_node>
47274727
{
4728+
if (!done() && curr().type() == lexeme::Semicolon) {
4729+
error("empty statement is not allowed - remove extra semicolon");
4730+
return {};
4731+
}
4732+
47284733
auto n = std::make_unique<statement_node>();
47294734

47304735
// Now handle the rest of the statement

0 commit comments

Comments
 (0)