-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/go/analysis/passes/nilness: false negative with pointers and type assertions #47938
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
Comments
The original example one could plausible infer that
Handling just the control flow looks feasible for easy cases. It could use roughly the same trick as here:
Brainstorming: |
Yes, my example was both over- and undersimplified. In the original code the type set isn't as clear. Your example illustrates the problem better, thanks! |
But then the Or, I suppose: something analogous to the |
@bcmills The
This is all doable but handling this requires some amount of inter-procedural dataflow analysis. Not really clear this complexity is worth it for |
Change https://go.dev/cl/560075 mentions this issue: |
Currently, as of
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff
andgo1.17
,nilness
doesn't mark the following code as invalid despitett
being provably nil:If
ok
is false thentt
is nil, since that is the default value for pointers.Playground: https://play.golang.org/p/0ni1nXpLBFK.
The text was updated successfully, but these errors were encountered: