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: