-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: shadow false positive when using exported function #11843
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
If you run |
Yes. |
Thanks. /cc @robpike |
The shadow code is marked experimental. It has too many false positives to be enabled by default, so this is not entirely unexpected, but don't expect a fix soon. The right way to detect shadowing without flow analysis is elusive. |
@robpike flow analysis doesn't seem relevant here. @mberhault and I dug into this a bit and discovered that go/types (underlying vet) regards the return of |
go tool vet --shadow
returns a false positive when the variable being shadowed is declared from the return of an exported user function from another package. That's a mouthful, so here's some code:./other/other.go:
./shadow_test.go:
The comments in the code describe the problem. Use
other.Foo()
and you get a false positive; use any of the others (local function, local variables, exported method from the stdlib) and the warning goes away. Weird!All the code is also available here: https://github.com/tamird/shadow
cc @mberhault
The text was updated successfully, but these errors were encountered: