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

unchecked_use_of_nullable_value for a checked nullable callback #44417

Closed
nex3 opened this issue Dec 7, 2020 · 2 comments
Closed

unchecked_use_of_nullable_value for a checked nullable callback #44417

nex3 opened this issue Dec 7, 2020 · 2 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-dart-sass NNBD Issues related to NNBD Release P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@nex3
Copy link
Member

nex3 commented Dec 7, 2020

When analyzing the following file with NNBD enabled:

int Function()? foo;

int callFoo() => foo != null ? foo() : 0;

I get the following error:

  error • An expression whose value can be 'null' must be null-checked before it can be dereferenced. • test.dart:3:32 • unchecked_use_of_nullable_value

This error seems bogus, since we are specifically are checking foo != null. Note that doing the check in an if statement also exhibits this error.

Tested with 2.12.0-110.0.dev.

@nex3 nex3 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) customer-dart-sass NNBD Issues related to NNBD Release labels Dec 7, 2020
@devoncarew
Copy link
Member

Above, foo is a field; unfortunately, those don't type promote. There's a discussion of that here: #35525.

cc @leafpetersen @stereotype441 wrt improving the diagnostics we provide in these cases.

@scheglov scheglov added the P3 A lower priority bug or feature request label Dec 8, 2020
@srawlins
Copy link
Member

Closing; working as specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-dart-sass NNBD Issues related to NNBD Release 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

4 participants