Skip to content

Compile-time error when using assignment initializer with anonymous functions. #865

Open
@hcbpassos

Description

@hcbpassos

Seems like Dart analysis gets confused when using assignment initializer with anonymous functions. For instance:

class Foo {
  final VoidCallback bar;
  Foo() : bar = () {}; // Expected an identifier.
}

When wrapping the function in parenthesis, the error goes away:

class Foo {
  final VoidCallback bar;
  Foo() : bar = (() {}); // Fine.
}

I'm not sure whether this behavior is expected, but I cannot see any reason why it should be.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions