Skip to content

Correction for short function syntax, closes #356 #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,17 @@ class parser
next();
return {};
}
if (
peek(-1) && peek(-1)->type() != lexeme::RightBrace // it is short function syntax
&& curr().type() != lexeme::LeftParen // not imediatelly called
&& curr().type() != lexeme::RightParen // not as a last argument to function
&& curr().type() != lexeme::Comma // not as first or in-the-middle, function argument
) {
// this is a fix for a short function syntax that should have double semicolon used
// (check comment in expression_statement(bool semicolon_required))
// We simulate double semicolon by moving back to single semicolon.
next(-1);
}
}
else {
error("(temporary alpha limitation) an unnamed declaration at expression scope must be a function or an object");
Expand Down