Skip to content

Commit 6701b64

Browse files
committed
Add diagnostics for double semicolon at short lambda
This change introduce diagnostics when there is a double semicolon at the end of the short function body for unnamed function: ```cpp l2 := :() -> int = 24;; ``` Generates: ``` error: a short function syntax shall end with a single semicolon (at ';') ```
1 parent af3c071 commit 6701b64

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/parse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,12 @@ class parser
29132913
next();
29142914
return {};
29152915
}
2916+
if (
2917+
decl->initializer && decl->initializer->is_expression()
2918+
&& !done() && curr().type() == lexeme::Semicolon
2919+
) {
2920+
error("an unnamed function shall end with a single semicolon");
2921+
}
29162922
}
29172923
else {
29182924
error("(temporary alpha limitation) an unnamed declaration at expression scope must be a function or an object");

0 commit comments

Comments
 (0)