Skip to content

Confusing error message from analyzer on incomplete mixinApplication #37009

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

Open
eernstg opened this issue May 20, 2019 · 1 comment
Open

Confusing error message from analyzer on incomplete mixinApplication #37009

eernstg opened this issue May 20, 2019 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) devexp-ux P4 type-enhancement A request for a change that isn't a bug

Comments

@eernstg
Copy link
Member

eernstg commented May 20, 2019

Cf. #36946, consider the following program:

class A<X> {}
class test<X extends num> = A<X>;
main() {}

With the analyzer (from e13b1b6) we get the following response:

ERROR|COMPILE_TIME_ERROR|MIXIN_OF_NON_CLASS|/usr/local/google/home/eernst/lang/dart/scratch/201905/n007.dart|2|33|0|Classes can only mixin other classes.
ERROR|SYNTACTIC_ERROR|EXPECTED_TOKEN|/usr/local/google/home/eernst/lang/dart/scratch/201905/n007.dart|2|33|1|Expected to find 'with'.
ERROR|STATIC_WARNING|UNDEFINED_CLASS|/usr/local/google/home/eernst/lang/dart/scratch/201905/n007.dart|2|33|0|Undefined class ''.

It looks like the analyzer sees A<X> and expects with (because it's parsing a <mixinApplication>); then it repairs the program by inventing with N where N is the empty identifier, and then it complains that N is not a class. It might be more helpful for developers to just report a syntax error in the <mixinApplication>, or at least to avoid describing properties of syntax that the developer did not write.

@eernstg eernstg added the legacy-area-analyzer Use area-devexp instead. label May 20, 2019
@srawlins
Copy link
Member

The "undefined class" error is gone. The analyzer now reports:

  • error • Classes can only mix in mixins and classes. • a.dart:2:33 • mixin_of_non_class
  • error • Expected to find 'with'. • a.dart:2:33 • expected_token

so still not ideal.

@srawlins srawlins added the P4 label Jan 12, 2021
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Nov 16, 2021
@srawlins srawlins added the contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) label May 20, 2022
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) devexp-ux P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants