-
Notifications
You must be signed in to change notification settings - Fork 18k
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: -shadow false positive #19490
Comments
Thanks for the report. The |
New tasks include: golang/go#19675 cmd/vet: report uses of -0 in float32/64 context golang/go#19683 cmd/compile: eliminate usages of global lineno golang/go#19670 x/tools/go/ssa: make opaqueType less annoying to use golang/go#19636 encoding/base64: decoding is slow golang/go#23471 x/perf/cmd/benchstat: tips or quickstart for newcomers golang/go#19577 test: errorcheck support for intraline errors golang/go#19490 cmd/vet: reduce the amount of false positives for -shadow mode golang/go#19042 cmd/internal/obj: optimize wrapper method prologue for branch prediction golang/go#19013 cmd/compile: add tool for understanding/debugging SSA rules
Is it possible to somehow allow user to grant such false positives (such as the shellcheck disable directives)? |
Any plans to fix this yet ? It really seems unnecessary to me checking for |
Honestly I don't see why this is a false positive. The inner |
It isn't a "false positive", and inner it's just that it is very common to have code like from example above that isn't harmful in any way, and still one has to find out linter failing on it, and come up with another name for have you seen any harmful shadowing with respect to |
I'm fine with coming up with some rule for when we should not report shadowing, but what should that rule be? I don't think it should be "don't report shadowing if the variable is named |
I agree with @ianlancetaylor , it is indeed a shadowing case. We can add a In some other cases, like:
Reporting shadowing |
@hitzhangjie This example do not build https://go.dev/play/p/KVsmDUICNui . It fails with |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?A sample code:
Run the command
go tool vet -shadow *.go
to get :I think there is no question of such code, in the main function in the defer if caused by using the local err statement.
The text was updated successfully, but these errors were encountered: