Skip to content

false positive for prefer_void_to_null w/ Never? #59388

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
pq opened this issue Feb 5, 2024 · 1 comment
Open

false positive for prefer_void_to_null w/ Never? #59388

pq opened this issue Feb 5, 2024 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive linter-set-recommended P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@pq
Copy link
Member

pq commented Feb 5, 2024

Follow-up from #54820 (comment)

Never? f() => null;

results in the lint Unnecessary use of the type 'Null'. Try using 'void' instead.. This seems like a poor message, at the very least.

@pq pq added the P3 A lower priority bug or feature request label Feb 5, 2024
@lrhn
Copy link
Member

lrhn commented Feb 5, 2024

It's technically correct in that Never? is equivalent to Null (according to NORM, which is what most people should think of as "the same type").

The coder just chose to write Null in a more cumbersome way than necessary.
I'd expect the same warning for:

typedef ArgleBargle = Null;
ArgleBargle f() => null;

The message would be more understandable if it added "The type 'Never?' is equivalent to 'Null'." when the actual declared type is not written as Null. That can work for the type alias too.

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Apr 3, 2024
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 20, 2024
@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 21, 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. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive linter-set-recommended P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants