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

Common front end parser rejects some postfixExpressions #34315

Closed
eernstg opened this Issue Aug 30, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@eernstg
Copy link
Member

eernstg commented Aug 30, 2018

Consider the following program:

class C<X extends num, Y extends X> {}

Map<Type, Function> factories = {
  C: <X extends num, Y extends X>() => C<X, Y>(),
};

main() {
  factories[C]<num, int>();
}

With dart (version 2.1.0-dev.3.0) we get the following output:

n019.dart:8:16: Error: Expected ';' after this.
  factories[C]<num, int>();
               ^^^
n019.dart:8:19: Error: Expected an identifier, but got ','.
  factories[C]<num, int>();
                  ^
n019.dart:8:19: Error: Expected ';' after this.
  factories[C]<num, int>();
                  ^
n019.dart:8:19: Error: Getter not found: ''.
  factories[C]<num, int>();
                  ^
n019.dart:8:19: Error: Unexpected token ';'.
  factories[C]<num, int>();
                  ^
n019.dart:8:26: Error: Expected an identifier, but got ')'.
  factories[C]<num, int>();
                         ^
n019.dart:8:26: Error: Getter not found: ''.
  factories[C]<num, int>();
                         ^
n019.dart:8:15: Error: The method '<' isn't defined for the class 'dart.core::Function'.
Try correcting the name to the name of an existing method, or defining a method named '<'.
  factories[C]<num, int>();
              ^
n019.dart:8:24: Error: The method '>' isn't defined for the class 'dart.core::Type'.
Try correcting the name to the name of an existing method, or defining a method named '>'.
  factories[C]<num, int>();
                       ^

In other words, the program is rejected by the parser. But it should be accepted:

postfixExpression -->
primary selector selector -->
primary assignableSelector argumentPart -->
primary assignableSelector typeArguments arguments -->
primary unconditionalAssignableSelector '<num, int>' '()' -->
identifier '[' expression ']' '<num, int>()' -->
'factories[C]<num, int>()'.
@kmillikin

This comment has been minimized.

Copy link
Member

kmillikin commented Aug 30, 2018

@peter-ahe-google will you take this, or reassign it as you see fit?

@peter-ahe-google

This comment has been minimized.

Copy link
Contributor

peter-ahe-google commented Aug 31, 2018

@danrubel I seem to recall that you're looking at a similar issue a couple of months ago. Does it ring any bells?

@danrubel

This comment has been minimized.

Copy link
Member

danrubel commented Aug 31, 2018

Happy to investigate

@danrubel danrubel self-assigned this Aug 31, 2018

@dart-bot dart-bot closed this in 4cd6988 Sep 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.