Go version

go version go1.24.5 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/bkreitch/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/bkreitch/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/hx/91lpwn6j1yq000cp_j1np6k00000gq/T/go-build1319912065=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/bkreitch/github/bkreitch/golang-tools/go.mod'
GOMODCACHE='/Users/bkreitch/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/bkreitch/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.5/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/bkreitch/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.5'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

crossfile.go:

package crossfile

func ShadowGlobal() {
    {
        global := 1 // line 5
        _ = global
    }
    _ = global
}

other.go:

package crossfile

var global int // line 3

$ shadow .

What did you see happen?

crossfile.go:5:3: declaration of "global" shadows declaration at line 3

What did you expect to see?

crossfile.go:5:3: declaration of "global" shadows declaration at line 3 in other.go

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gopherbot

Change https://go.dev/cl/692396 mentions this issue: go/analysis/passes/shadow: include filename in cross-file shadow error messages

Comment From: mrkfrmn

CC @adonovan from owners.