Skip to content

Dart2js does not accept "x = (){return 42;}()" in initializer list. #11508

Closed
@lrhn

Description

@lrhn

Example code:

class C {
 final int x;
 C() : x = (){ return 42; }();
}

main() {
  print(new C().x);
}

This errs with the message:
initcall.dart:3:28: unexpected token '('
 C() : x = (){ return 42; }();

The grammar allows the syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions