cmd/vet: shadow false positive when using exported function #11843
Milestone
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 |
This was referenced Aug 3, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: