Skip to content

Spec allows function literals in initializer list #11509

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:
'file:..../initcall.dart': Error: line 3 pos 13: unexpected token ')'
 C() : x = (){ return 42; }();

The grammar allows the syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-specification (deprecated)Deprecated: use area-language and a language- label.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions