Closed artyom closed 3 months ago
I'm failing to reproduce this. Are you sure that you're running the same staticcheck
executable both times?
Yes, the one installed with go install honnef.co/go/tools/cmd/staticcheck@latest
:
test1 ¶ go version -m $(which staticcheck)
/Users/artyom/go/bin/staticcheck: go1.23.0 X:rangefunc
path honnef.co/go/tools/cmd/staticcheck
mod honnef.co/go/tools v0.5.0 h1:29uoiIormS3Z6R+t56STz/oI4v+mB51TSmEOdJPgRnE=
dep github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
dep golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
dep golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
dep golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
dep golang.org/x/tools v0.21.1-0.20240531212143-b6235391adb3 h1:SHq4Rl+B7WvyM4XODon1LXtP7gcG49+7Jubt1gWWswY=
build -buildmode=exe
build -compiler=gc
build -trimpath=true
build DefaultGODEBUG=asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
build CGO_ENABLED=1
build GOARCH=arm64
build GOEXPERIMENT=rangefunc
build GOOS=darwin
build GOARM64=v8.0
test1 ¶ /Users/artyom/go/bin/staticcheck
-: module requires at least go1.23.0, but Staticcheck was built with go1.23 (compile)
1 test1 ¶ cat go.mod main.go
module foo
go 1.23.0
package main
func main() {}
I unset GOEXPERIMENT=rangefunc
like so:
test1 ¶ go env -u GOEXPERIMENT
test1 ¶ go env GOEXPERIMENT
Reinstalled:
test1 ¶ go install honnef.co/go/tools/cmd/staticcheck@latest
test1 ¶ go version -m $(which staticcheck) | grep GOEXPERIMENT
1 test1 ¶
And now it succeeds:
test1 ¶ staticcheck ; echo $?
0
So it looks like the bug only happens with GOEXPERIMENT=rangefunc
(not sure yet either env-dependent or how the binary was buit).
The bug only happens when running staticcheck built with GOEXPERIMENT=rangefunc
(regardless of the env it then used in)
Thank you, I can reproduce it now.
Barring any other issues, I'll cut a new release later today that includes this fix.
To reproduce: