Skip to content

x/tools/go/analysis/passes/shadow: go vet shadow strict doesn't check global constant shadowing #72943

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

Open
gergely-pepper opened this issue Mar 19, 2025 · 3 comments
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) BugReport Issues describing a possible bug in the Go implementation. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@gergely-pepper
Copy link

Go version

go version go1.24.0 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE='auto'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/gergely-pepperstone/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/gergely-pepperstone/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/vc/jvx1n9n12bq0_fhbqlb2sv_00000gp/T/go-build1999280843=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD=''
GOMODCACHE='/Users/gergely-pepperstone/og/pkg/mod'
GONOPROXY='github.com/pepperstone'
GONOSUMDB='github.com/pepperstone'
GOOS='darwin'
GOPATH='/Users/gergely-pepperstone/og'
GOPRIVATE='github.com/pepperstone'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/gergely-pepperstone/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

package main

import "fmt"

const testStr = "some"

func main() {
	if testStr != "" {
		fmt.Println("Not empty")
	}
	testStr := "Test string"
	fmt.Println(testStr)
}

go vet -vettool="$(which shadow)" -strict .

What did you see happen?

no output

What did you expect to see?

./vet.go:11:2: declaration of "testStr" shadows declaration at line 5

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Mar 19, 2025
@gopherbot gopherbot added this to the Unreleased milestone Mar 19, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 19, 2025
@cherrymui cherrymui added the Analysis Issues related to static analysis (vet, x/tools/go/analysis) label Mar 20, 2025
@cherrymui
Copy link
Member

cc @adonovan

@cherrymui cherrymui added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 20, 2025
@adonovan
Copy link
Member

Since its inception, the shadow analyzer has always had problems that prevent us from enabling it. Until we know how to fix them, we are unlikely to invest more effort into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) BugReport Issues describing a possible bug in the Go implementation. NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants