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

Improve error message for mismatching parameters in redirecting factory constructor #60220

Open
Pante opened this issue Feb 27, 2025 · 0 comments
Labels
area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) P3 A lower priority bug or feature request

Comments

@Pante
Copy link

Pante commented Feb 27, 2025

When given the following invalid code:

class Foo {
  int a;
  int b;

  factory Foo.bar({required int a}) = Bar;

  Foo({required this.a, required this.b});
}

class Bar extends Foo {
  Bar({required super.a, required super.b});
}

Dart currently produces the following error message:

The redirected constructor 'Bar Function({required int a, required int b})' has incompatible parameters with 'Foo Function({required int a})'.

It will be great if the error message highlights which parameters are missing, i.e

The redirected constructor 'Bar Function({required int a, required int b})' has incompatible parameters with 'Foo Function({required int a})'.

The incompatible parameters are ...

The current error message is enough when there are a few parameters. However, when there are several parameters, the error message becomes something similar to:
Image

which is unreadable.

@mit-mit mit-mit added the area-model Use area-model for issues related to packages analyzer, front_end, and kernel. label Feb 27, 2025
@johnniwinther johnniwinther added area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) and removed area-model Use area-model for issues related to packages analyzer, front_end, and kernel. labels Feb 27, 2025
@bwilkerson bwilkerson added the P3 A lower priority bug or feature request label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp Developer Experience related issues (DevTools, IDEs, Analysis Server, completions, refactoring, etc) P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants