-
Notifications
You must be signed in to change notification settings - Fork 260
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
[BUG] cppfront
confused by function expression in for
's (next
) expression
#432
Comments
diff --git a/source/parse.h b/source/parse.h
index f716925..3165ec0 100644
--- a/source/parse.h
+++ b/source/parse.h
@@ -3606,6 +3606,7 @@ private:
&& 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
+ && curr().type() != lexeme::Keyword // not as next expression
) {
// this is a fix for a short function syntax that should have double semicolon used
// (check comment in expression_statement(bool semicolon_required)) Additionally, Also, shall we allow statements as for-body? I was sure that it require a compound statement as ifs. |
When? Always? When not an expression-statement (the only case that would require double |
Ha! You are right, and I am mistaken. I am pretty sure it was required before. Maybe my memory failed here. The following code explains it (https://cpp2.godbolt.org/z/o11cYnKj6): main: () -> int = {
l := :() = std::cout << 42; // require one semicolon
l();
:() = std::cout << " >>instantly called<< ";(); // require one semicolon before ()
return fun(:() -> int = 0+1, :() = std::cout << 1); // semicolon is not required in both cases
}
fun: (f, g) -> int = {
g();
return f();
} |
By the way, I did try adding I was just wondering if you had the answer about I've thought about it some more, and I think the answer lies in this grammar: //G expression-statement:
//G expression ';'
//G expression So the
When the FE is in an expression-list, |
for
's (next
) expressioncppfront
confused by function expression in for
's (next
) expression
I've been exploring missing ; in short-body lambdas and tried to invent dangerously looking example, and want to share my attempt so far
|
Title: Confused by function expression in
for
's (next
) expression.Description:
It seems something enters a bad state.
Unparenthesized, it complains about a missing
do
.Parenthesized, lifetime analysis says the loop variable is uninitialized.
Minimal reproducer (https://cpp2.godbolt.org/z/Er81zc91E, https://cpp2.godbolt.org/z/a75sW77bs):
Commands:
Actual result and error:
The text was updated successfully, but these errors were encountered: