Skip to content
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

Closed
peter-ahe-google opened this issue Apr 10, 2013 · 9 comments
Closed

Parser error with cascading #9823

peter-ahe-google opened this issue Apr 10, 2013 · 9 comments

Comments

@peter-ahe-google
Copy link
Contributor

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) {
                                                 ^^

@kasperl
Copy link

kasperl commented Apr 22, 2013

Added this to the Later milestone.

@kasperl
Copy link

kasperl commented May 23, 2013

Added TriageForM5 label.

@kasperl
Copy link

kasperl commented May 28, 2013

Removed TriageForM5 label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@srawlins
Copy link
Member

srawlins commented Aug 4, 2014

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.

@bwilkerson
Copy link
Member

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.)

@DartBot
Copy link

DartBot commented Aug 4, 2014

This comment was originally written by @mhausner


Brian is correct. The grammar is:

equalityExpression:
  relationalExpression (equalityOperator relationalExpression)? | ....

A relationalExpression can't have cascades. So it seems to me that all parsers are correct.

@mhausner
Copy link
Contributor

mhausner commented Dec 4, 2015

Not a bug.

@mhausner mhausner closed this as completed Dec 4, 2015
@kevmoo kevmoo removed the triaged label Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants