Skip to content

VM doesn't recognize new function type as type parameter. #29243

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

Closed
lrhn opened this issue Apr 4, 2017 · 4 comments
Closed

VM doesn't recognize new function type as type parameter. #29243

lrhn opened this issue Apr 4, 2017 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@lrhn
Copy link
Member

lrhn commented Apr 4, 2017

Example code:

int Function() x = () => 42;
int Function(int Function()) y = (int Function() x) => x();
List<int Function()> l = <int Function()>[()=>42, x];  // Error
main() {
  print(y(l[1]));
}

causes the error message:

'functype.dart': error: line 4 pos 1: unexpected token 'List'
List<int Function()> l = <int Function()>[()=>42, x];
^

Removing the <int Function()> on line 4 makes the code work. This runs in dart2js, but also crashes the analyzer.

@lrhn lrhn added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Apr 4, 2017
@crelier
Copy link
Contributor

crelier commented Apr 12, 2017

I just looked at this and it is a bug (even 2 separate bugs!) in the look-ahead parsing code in the VM, which does not recognize the line as a variable declaration.
I'll fix it tomorrow.

@crelier
Copy link
Contributor

crelier commented Apr 12, 2017

I fixed this issue, but I cannot upload the cl including the regression test, because dartfmt is not able to parse it :-)

I'll file a separate bug.

@crelier
Copy link
Contributor

crelier commented Apr 12, 2017

I filed dart-lang/dart_style#616

@crelier
Copy link
Contributor

crelier commented Apr 12, 2017

I also filed #29335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

2 participants