Skip to content
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

[analyzer] Report a compile-time error for external initializing formals #54485

Closed
eernstg opened this issue Jan 2, 2024 · 3 comments
Closed
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) P3 A lower priority bug or feature request

Comments

@eernstg
Copy link
Member

eernstg commented Jan 2, 2024

Consider the following program:

class A {
  final int i;
  external A(this.i);
}

void main() {}

The CFE reports a compile-time error on this library. The analyzer accepts it with no errors.

It was previously only mentioned in commentary that it is a compile-time error for an external generative constructor to have an initializing formal parameter, but in dart-lang/language#3517 the specification was clarified such that it is now clearly specified to be a compile-time error.

This issue is the implementation issue for that implementation effort. It is 'area-analyzer' rather than 'area-meta', with sub-issues, because there is nothing to implement in any other tool than the analyzer.

It is not a breaking change, because every external constructor declaration that has an initializing formal is reported as a compile-time error by the CFE already today.

@eernstg eernstg added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) labels Jan 2, 2024
@scheglov scheglov self-assigned this Jan 2, 2024
@scheglov
Copy link
Contributor

scheglov commented Jan 2, 2024

copybara-service bot pushed a commit that referenced this issue Jan 3, 2024
…l parameter.

Bug: #54485
Change-Id: Id2cec10b1c8bdb7bba5d608f28a3b55b8f4146ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344180
Reviewed-by: Kallen Tu <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov scheglov added the P3 A lower priority bug or feature request label Jan 3, 2024
@scheglov scheglov closed this as completed Jan 3, 2024
@sgrekhov
Copy link
Contributor

sgrekhov commented Jan 5, 2024

Seems that the issue still exists for optional parameters. The following tests fail (no expected errors):

co19/Language/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t02
co19/Language/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t03
co19/Language/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t04

@scheglov
Copy link
Contributor

scheglov commented Jan 5, 2024

copybara-service bot pushed a commit that referenced this issue Jan 5, 2024
…l parameter, optional.

Finishes https://dart-review.googlesource.com/c/sdk/+/344180

Bug: #54485
Change-Id: Ib743495b4b5a03c017ccca22f8efd1055fd919aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345081
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov scheglov closed this as completed Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants