Skip to content

Commit 6a93b4c

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 70499ed commit 6a93b4c

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
@@ -3010,6 +3010,12 @@ class parser
30103010
next();
30113011
return {};
30123012
}
3013+
if ( // check if a single-expression function is followed by an extra second semicolon
3014+
decl->initializer && decl->initializer->is_expression()
3015+
&& !done() && curr().type() == lexeme::Semicolon
3016+
) {
3017+
error("a single-expression function should end with a single semicolon");
3018+
}
30133019
if (!(*func)->contracts.empty()) {
30143020
error("an unnamed function at expression scope currently cannot have contracts");
30153021
next();

0 commit comments

Comments
 (0)