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
Parser error with cascading #9823
Comments
Added this to the Later milestone. |
Added TriageForM5 label. |
Removed TriageForM5 label. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
Note: dartanalyzer and editor also error with this example. I'm guessing the parser implementations currently expect a ')', '}', or ';' after a sequence of cascades. It is curious that the spec allows a getter in a cascade ("A cascaded method invocation has the form e..suffix where e is an expression and suffix is a sequence of operator, method, getter or setter invocations.") and yet the cascade does not allow the value of the getter to be gotten: var x = new DateTime.now()..millisecondsSinceEpoch; // x is the DateTime instance. |
As far as I can see by looking at the grammar, the parser is correct. I believe that the cascade expression needs to be in parentheses for this to be correct: if ((new DateTime.now()..millisecondsSinceEpoch) == 42) { and even that is suspect, because it means to compare the DateTime with an int. (But perhaps that's really what the test wants to do; I haven't looked at it.) |
This comment was originally written by @mhausner Brian is correct. The grammar is: equalityExpression: A relationalExpression can't have cascades. So it seems to me that all parsers are correct. |
Not a bug. |
Not sure, but I think this is a parser error:
tests/language/crash_6725_test.dart:45:50: unexpected token '=='
if (new DateTime.now()..millisecondsSinceEpoch == 42) {
^^
The text was updated successfully, but these errors were encountered: