Repository navigation
Closed
Labels
Description
$ staticcheck -version
staticcheck 2026.2 (0.8.0)
$ staticcheck -debug.version
staticcheck 2026.2 (0.8.0)
Compiled with Go version: go1.26.6-X:nodwarf5
Main module:
honnef.co/go/tools@v0.8.0 (sum: h1:UacpzPr7D6i5BAjTkA7sNVcx4kIbhAZcQ4zYtKiXx68=)
Dependencies:
github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c (sum: h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=)
golang.org/x/exp/typeparams@v0.0.0-20231108232855-2478ac86f678 (sum: h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=)
golang.org/x/mod@v0.35.0 (sum: h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=)
golang.org/x/sync@v0.20.0 (sum: h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=)
golang.org/x/tools@v0.44.1-0.20260420230617-19499e7caabc (sum: h1:vSv/HN1q9eoPD7lMyJYVJ/GPYnqtqu6adMxUmrxOB78=)
$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/var/home/teuf/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/var/home/teuf/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build707243157=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/var/home/teuf/dev/playground/staticcheck/go.mod'
GOMODCACHE='/var/home/teuf/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/var/home/teuf/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/golang'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/var/home/teuf/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.6-X:nodwarf5'
GOWORK=''
PKG_CONFIG='pkg-config'
$ go version
go version go1.26.6-X:nodwarf5 linux/amd64
I ran staticcheck . with this program:
$ cat main.go
package main
import "fmt"
func notImplemented() error {
return fmt.Errorf("not implemented")
}
func main() {
err := notImplemented()
if err != nil {
panic(err.Error())
}
fmt.Println("hello")
}
and v0.8.0 prints
$ staticcheck
main.go:11:5: this comparison is always true (SA4023)
main.go:10:9: the lhs of the comparison is the 1st return value of this function call
main.go:5:6: example.com/staticcheck.notImplemented never returns a nil interface value
v0.7.0 does not report an error.
The reproducer is a bit silly, but this is extracted from a larger codebase where some functions are implemented on windows but not on linux/macos, so we use a function always returning an error on platforms where the function cannot be implemented ( https://github.com/containers/gvisor-tap-vsock/blob/main/pkg/sshclient/npipe_unsupported.go )
Activity
dominikh commentedon Aug 24, 2026
This should be fixed now. Please let me know if you run into any other false positives.
analysis/facts/nilness: more accurately track inner values
cfergeau commentedon Aug 25, 2026
I can confirm that latest
masterdoes not report an error with this test case.lint: Disable SA4023 in staticcheck
analysis/facts/nilness: more accurately track inner values