-
Notifications
You must be signed in to change notification settings - Fork 249
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] Function expression can't be the left argument to is
/as
#435
Comments
I think your example code is wrong, because:
This is the correct example code (it needs parenthesis around the unnamed function): main: () = {
x: = (: () -> int = 0) is int; // true
} Or this one (it doesn't need parenthesis around the unnamed function): main: () = {
x: = : () = {} is int; // false
} |
I need to correct my build system to handle self-compilation by the previous version of cppfront. I will deliver the patch soon. |
By writing above messages I just realize that |
Just in case you would like to test the fix by yourself, or if I am not able to deliver fast, I am attaching a diff: diff --git a/source/parse.h b/source/parse.h
index f716925..65d2fb0 100644
--- a/source/parse.h
+++ b/source/parse.h
@@ -3606,6 +3606,10 @@ 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() != "is"
+ && curr() != "as"
+ && curr() != "do"
+ && curr() != "next"
) {
// this is a fix for a short function syntax that should have double semicolon used
// (check comment in expression_statement(bool semicolon_required)) |
It's still valid code. Not practically useful, but slide-ware/example-ware useful. Like for reporting bugs.
I think this should work to disambiguate when you want the
I didn't notice because the generated Cpp1 source files are checked in. |
My usual command worked as well but after I have added Nevertheless, I want my cmake to be able to build cppfront from scratch. |
The original code is not working, but the following is: main: () = {
(:() = 0;) is int;
} |
Title: Function expression can't be the left argument to
is
/as
.Minimal reproducer (https://cpp2.godbolt.org/z/K53erj1fh):
Commands:
Expected result:
Same as (https://cpp2.godbolt.org/z/8nszP1Wo4):
Actual result and error:
The text was updated successfully, but these errors were encountered: