-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/vet: vet should warn on possible mis-shaddows caused by short variable declarations. #22582
Comments
This example cannot be vetted. |
@cznic |
Legitimate code. |
Yes, it is. But legitimate code can't be vetted? |
What should vet say about it? 'Warning: legitimate code detected'? |
That seems hyperbolic. |
"possible mis-shaddow of a" is better. |
Not at all. I read many anti-Go articles, this trap is a must-have in them. |
This is already implemented and guarded by the
This check cannot be enabled by default because it is noisy and produces false positives – not all shadowing is buggy, and a lot of shadowing is intentional. |
Great! Glad to know it is supported. |
Many new gophers give up using Go when they ever fall into the famous trap in Go.
Go vet should make a warning for such cases to get better user experience.
The text was updated successfully, but these errors were encountered: