Skip to content

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

Open
@gergely-pepper

Description

@gergely-pepper

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)BugReportIssues describing a possible bug in the Go implementation.NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions