-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
What version of Go are you using (go version
)?
$ go version 1.14.6
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/wolf/.cache/go-build" GOENV="/home/wolf/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="go.showmax.cc,go.platfoo.cc" GONOSUMDB="go.showmax.cc,go.platfoo.cc" GOOS="linux" GOPATH="/home/wolf/go" GOPRIVATE="go.showmax.cc,go.platfoo.cc" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build056422182=/tmp/go-build -gno-record-gcc-switches"
What did you do?
-
Install shadow vet:
$ go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
-
Create following files:
+$ tree .
.
├── b.go
├── c.go
└── go.mod0 directories, 3 files
+$ cat b.go
package foofunc newX() int {
x := 1
return x
}var x = newX()
+$ cat c.go
package foofunc f() {
x = 1
}
+$ cat go.mod
module foogo 1.14
-
Run the shadow vet:
$ go vet -vettool=/home/wolf/go/bin/shadow ./...
What did you expect to see?
# foo
./b.go:4:2: declaration of "x" shadows declaration at line 8
What did you see instead?
Nothing.
Some research notes
It looks like shadow vet depends on the filenames, because all one needs to do
to get the expected output is to rename c.go
to a.go
, so when sorted by
alphabet is is before b.go
. My understanding is that the package is the
scope, so alphabetic ordering of the files should not matter.
Metadata
Metadata
Assignees
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.