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

x/tools/gopls: add the nilness analysis #44627

Closed
ainar-g opened this issue Feb 26, 2021 · 3 comments
Closed

x/tools/gopls: add the nilness analysis #44627

ainar-g opened this issue Feb 26, 2021 · 3 comments

Comments

@ainar-g
Copy link
Contributor

@ainar-g ainar-g commented Feb 26, 2021

The nilness analysis pass can detect some absurd conditions, like checking a value that has already been proven non-nil against nil. This is especially useful during refactoring, when a new nil check appears before an existing one. I think that this analysis would be a good fit for the gopls analysis suite. If I recall correctly, it uses SSA, so it should probably be disabled by default.

If there are no objections, I am ready to send a CL soon-ish.

@gopherbot gopherbot added this to the Unreleased milestone Feb 26, 2021
@findleyr
Copy link
Contributor

@findleyr findleyr commented Feb 26, 2021

Note that nilness was removed in https://golang.org/cl/219203, specifically because of the resources that SSA consumes.

That said, it makes sense to have available yet disabled by default.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Feb 26, 2021
@stamblerre stamblerre added this to To Do in gopls: v1.0.0 Feb 28, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 8, 2021

Change https://golang.org/cl/299131 mentions this issue: internal/lsp/source: add the nilness analyzer

@ainar-g
Copy link
Contributor Author

@ainar-g ainar-g commented Mar 8, 2021

Thanks for the review!

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.6.7 Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants