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

Possibly spurious error about mixin with constructor #59569

Open
lrhn opened this issue Nov 20, 2024 · 0 comments
Open

Possibly spurious error about mixin with constructor #59569

lrhn opened this issue Nov 20, 2024 · 0 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Nov 20, 2024

mixin M {
  M.baz();
}
class MA with M {}
void main(){}

gives a warning of

main.dart:2:3: Error: Mixins can't declare constructors.
  M.baz();
  ^
main.dart:5:7: Error: Can't use 'M' as a mixin because it has constructors.
class MA with M {}
      ^
main.dart:2:3: Context: This constructor prevents using 'M' as a mixin.
  M.baz();
  ^

The error in line 5, "Can't use 'M' as a mixin because it has constructors.", feels misplaced.
The mixin M doesn't have constructors, because mixins can't have constructors. That's not preventing using it as a mixin, it's preventing the program from compiling.

The only real error, and the only one reported by the analyzer, is that mixin M can't declare a constructor.

@lrhn lrhn added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Nov 20, 2024
@johnniwinther johnniwinther added the cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-messages Poor/undesirable messaging in errors/warnings emitted by the CFE. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants