-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Fix T_*_CAST syntax issues that caused argument list edge cases #1667
Conversation
30e5133
to
2fb43e8
Compare
2fb43e8
to
366e054
Compare
366e054
to
0c118cd
Compare
Hi! @nikic, @TazeTSchnitzel do you think this fix is doable? |
This issue had been bothering me for a long time. While I'd rather we just drop the cast tokens entirely and make the type names reserved words, we probably can't do that any time soon. This at least fixes the |
@marcioAlmada there are conflicts, and this should target 7.0 ... if it will rebase clean then please just fix the conflicts ;) ping me directly when you have done it ... ta |
@krakjoe As this is a major change to lexer output, I don't think it can target a patch release. For example, it will break PHP-Parser. |
okay then @marcioAlmada make that 7.1 ... |
"object"| | ||
"unset" | ||
){TABS_AND_SPACES}")" { | ||
zend_copy_value(zendlval, (yytext+1), (yyleng-2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't take into account possible whitespace around the cast name.
|
||
zend_ast_destroy(cast_ast); | ||
|
||
return zend_ast_create_ex(ZEND_AST_CAST, cast_type, op0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be in a .c file.
Not sure about this change in general. For example, doesn't the same issue also apply to a number of other places using parenthesized expressions? This PR would allow writing I remember there is some reason for it, but doesn't come immediately to mind. Why is it that we handle this in the lexer instead of parsing |
I guess the reason is that we'd have a shift/reduce conflict on |
Ideally we'd reserve these words properly and then add |
@krakjoe this PR was created because of the callable types RFC, that if passed would have made it mandatory to fix the following edge case: function x(callable(int):int $callback) {
# ^^^^^
} But the callable types RFC was rejected. Considering important tools like PHP-Parser will break, this is the kind of technical debt we can live with until the next major release IMMO, specially if it doesn't get in the way of some important language feature until there. I'd suggest to close this PR for now. If there is any urge to address this issue it will be trivial to resume. I just don't feel very comfortable to deliver a BC break now "just" for the sake of correctness. |
Changes Unknown when pulling 466159a on marcioAlmada:cleanup/T_CAST into ** on php:master**. |
Second, and more complete, attempt after #1629. Example of edge case: https://3v4l.org/eE5bq
Relates to #1633, in some way