Skip to content

Can an external constructor have an initializing formal? #3516

Closed
@eernstg

Description

@eernstg

Thanks to @sgrekhov for bringing this up. Consider the following library:

class C {
  num x;
  external C(this.x);
}

This declaration is rejected by the common front end, based on the claim that external constructors cannot declare initializing formals. It is accepted by the analyzer. The specification does not provide any information about this specific situation.

In other words, it is not a breaking change to say that it is a compile-time error for an external constructor to have an initializing formal parameter. Also, it is not at all clear (to me) what the dynamic semantics would be.

In any case, there might be a useful and meaningful way to define what it would do, in which case we might want to specify that it is allowed.

@dart-lang/language-team, WDYT? I tend to think we should just specify that it is an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions