Closed danail-branekov closed 4 months ago
Staticcheck panics when running on the Korifi codebase and golang 1.23
https://github.com/cloudfoundry/korifi/tree/golang-123
cd
go install honnef.co/go/tools/cmd/staticcheck@latest
❯ ~/go/bin/staticcheck ./... panic: Cannot range over: func(yield func(K, V) bool) goroutine 190 [running]: honnef.co/go/tools/go/ir.(*builder).rangeStmt(0xc000adda60, 0xc0015ebe00, 0xc00060eb40, 0x0, {0xa4c2d0, 0xc00060eb40}) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2225 +0x894 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000adda60, 0xc0015ebe00, {0xa4e6c0?, 0xc00060eb40?}) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2438 +0x20a honnef.co/go/tools/go/ir.(*builder).stmtList(...) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:859 honnef.co/go/tools/go/ir.(*builder).stmt(0xc000adda60, 0xc0015ebe00, {0xa4e300?, 0xc0015af4d0?}) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2396 +0x1415 honnef.co/go/tools/go/ir.(*builder).buildFunction(0xc000adda60, 0xc0015ebe00) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2508 +0x417 honnef.co/go/tools/go/ir.(*builder).buildFuncDecl(0xc000adda60, 0xc0001bca20, 0xc0015af500) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2545 +0x189 honnef.co/go/tools/go/ir.(*Package).build(0xc0001bca20) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2649 +0xb46 sync.(*Once).doSlow(0xc001840000?, 0xc00060e720?) /usr/local/go/src/sync/once.go:76 +0xb4 sync.(*Once).Do(...) /usr/local/go/src/sync/once.go:67 honnef.co/go/tools/go/ir.(*Package).Build(...) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/go/ir/builder.go:2567 honnef.co/go/tools/internal/passes/buildir.run(0xc0014008f0) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/internal/passes/buildir/buildir.go:86 +0x18b honnef.co/go/tools/lintcmd/runner.(*analyzerRunner).do(0xc0011606f0, {0xa50d98?, 0xc0009d37c0}) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:992 +0x71b honnef.co/go/tools/lintcmd/runner.genericHandle({0xa50d98, 0xc0009d37c0}, {0xa50d98?, 0xc0009d3720?}, 0xc000608cb0, 0xc000390b50, 0xc000553d80) /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:817 +0x11f created by honnef.co/go/tools/lintcmd/runner.(*subrunner).runAnalyzers in goroutine 189 /home/ccloud/go/pkg/mod/honnef.co/go/tools@v0.4.7/lintcmd/runner/runner.go:1061 +0x6a6
The commands above runs perfectly fine with golang 1.22 (e.g. our current main)
staticcheck 2023.1.7 (v0.4.7)
❯ ~/go/bin/staticcheck -debug.version staticcheck 2023.1.7 (v0.4.7) Compiled with Go version: go1.23rc2 Main module: honnef.co/go/tools@v0.4.7 (sum: h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=) Dependencies: github.com/BurntSushi/toml@v1.2.1 (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=) golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=) golang.org/x/mod@v0.12.0 (sum: h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=) golang.org/x/sys@v0.11.0 (sum: h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=) golang.org/x/tools@v0.12.1-0.20230825192346-2191a27a6dc5 (sum: h1:Vk4mysSz+GqQK2eqgWbo4zEO89wkeAjJiFIr9bpqa8k=)
go version go1.23rc2 linux/amd64
❯ go env GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/ccloud/.cache/go-build' GOENV='/home/ccloud/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/ccloud/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/ccloud/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.23rc2' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/home/ccloud/.config/go/telemetry' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='/home/ccloud/workspace/korifi/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build832850681=/tmp/go-build -gno-record-gcc-switches'
https://github.com/dominikh/go-tools/issues?q=%22Cannot+range+over%22
Please use the 2024.1rc1 pre-release, not latest, which resolves to 2023.1.7.
2024.1rc1
latest
2023.1.7
Staticcheck panics when running on the Korifi codebase and golang 1.23
Steps to reproduce:
https://github.com/cloudfoundry/korifi/tree/golang-123
andcd
into itgo install honnef.co/go/tools/cmd/staticcheck@latest
The commands above runs perfectly fine with golang 1.22 (e.g. our current main)
Additional information
staticcheck 2023.1.7 (v0.4.7)
go version go1.23rc2 linux/amd64