Skip to content

Function literals not permitted inside string interpolation inside initializers #18102

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
stereotype441 opened this issue Apr 8, 2014 · 3 comments
Assignees

Comments

@stereotype441
Copy link
Member

Both the vm and dart2js reject the following code, which is allowed by the spec:

class C {
  String s;
  C(x) : s = "2x is ${() { return 2x; }()}"; // error
}

The problem only occurs inside initializers, so for example this works just fine:

String s = "2x is ${() { return 2x; }()}"; // ok

See also issue #11509.

Note: both the vm and dart2js have explicit logic to permit function literals inside parenthesized expressions, list literals, map literals, and function arguments. I suspect it was an oversight not to apply similar logic to string interpolation.

@lrhn
Copy link
Member

lrhn commented Apr 9, 2014

Filing as dart2js, copy for the VM as issue #18112


Added Area-Dart2JS, Triaged labels.

@floitschG
Copy link
Contributor

Set owner to @floitschG.
Added Started label.

@floitschG
Copy link
Contributor

Fixed in r34919.


Added Fixed label.

This issue was closed.
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

4 participants