Repository navigation
Closed
Labels
Description
main.go:11:32: this comparison is always true (SA4023)
main.go:11:12: the lhs of the comparison is the 1st return value of this function call
$GOROOT/src/cmp/cmp.go:69:1: cmp.Or never returns a nil interface value
Code
package main
import (
"cmp"
"fmt"
)
func ok() error { return nil }
func main() {
if err := cmp.Or(ok(), ok()); err != nil {
fmt.Println("Error")
}
fmt.Println("No error")
}This result with No error but staticcheck warns that the err is always true
staticcheck 2026.2rc1 (0.8.0-rc.1)
Compiled with Go version: go1.26.7
Main module:
honnef.co/go/tools@v0.8.0-rc.1 (sum: h1:wqMm2kjcEXMOr+6yau+pdKqJKe6l2N1aKPkpini+Kzk=)
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=)
Activity
dominikh commentedon Aug 20, 2026
Fixed on master, will be part of the next patch release (either today or tomorrow).
go/types/typesutil: return true from IsPointerLike for unconstrained …
go/types/typesutil: return true from IsPointerLike for unconstrained …