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

false positive for prefer_void_to_null w/ Never? #4867

Open
pq opened this issue Feb 5, 2024 · 1 comment
Open

false positive for prefer_void_to_null w/ Never? #4867

pq opened this issue Feb 5, 2024 · 1 comment
Labels
false-positive P3 A lower priority bug or feature request set-recommended Affects a rule in the recommended Dart rule set 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 dart-lang/sdk#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.

@github-actions github-actions bot added the set-recommended Affects a rule in the recommended Dart rule set label Feb 5, 2024
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive P3 A lower priority bug or feature request set-recommended Affects a rule in the recommended Dart rule set type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants