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

[analyzer] Unhandled exception: Null check operator used on a null value #50660

Closed
incendial opened this issue Dec 8, 2022 · 5 comments
Closed
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@incendial
Copy link
Contributor

incendial commented Dec 8, 2022

Hi, our users reported a strange null check exception dart-code-checker/dart-code-metrics#1098 and after looking at source code I'm not sure that this is the expected behaviour https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/lib/src/dart/element/member.dart#L624. I've also asked for the code example that produced the exception.

Also, the Element class declares the source property as nullable.
Screenshot 2022-12-08 at 19 20 07

@bwilkerson @scheglov could you please take a look?

@incendial incendial changed the title [anayzer] Unhandled exception: Null check operator used on a null value [analyzer] Unhandled exception: Null check operator used on a null value Dec 8, 2022
@lrhn lrhn 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) labels Dec 8, 2022
@scheglov
Copy link
Contributor

scheglov commented Dec 8, 2022

Thank you, I can reproduce it.

@incendial
Copy link
Contributor Author

The example from our user dart-code-checker/dart-code-metrics#1098 (comment)

@scheglov
Copy link
Contributor

scheglov commented Dec 8, 2022

Yes, this example is what allowed me to reproduce it!

@scheglov
Copy link
Contributor

scheglov commented Dec 8, 2022

https://dart-review.googlesource.com/c/sdk/+/274603

So, this is how to reproduce it.

void foo<T>({required int a}) {}

void f() {
  foo(a: 0);
}

Fortunately, this is not the issue that I thought it is initially, with completely synthetic FunctionType and its parameters.

@scheglov scheglov added the P2 A bug or feature request we're likely to work on label Dec 8, 2022
@scheglov scheglov self-assigned this Dec 8, 2022
copybara-service bot pushed a commit that referenced this issue Dec 9, 2022
Bug: #50660
Change-Id: Ie6af7c60178b2010f4cd5254e563185eb7e27042
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274603
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov scheglov closed this as completed Dec 9, 2022
@incendial
Copy link
Contributor Author

Thank you for the fast fix and the code example, the case is very interesting 🙂 !

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. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants