Skip to content

SA4023: false positive involving generics #1242

@dominikh

Description

@dominikh
package main

func foo[T any](x T) {
	if any(x) == nil {
		println("is nil")
	}
}

func main() {
	foo[error](nil)
}
$ go run baz.go
is nil
$ run-dev-staticcheck baz.go
baz.go:4:5: this comparison is never true (SA4023)
	baz.go:3:17: the lhs of the comparison gets its value from here and has a concrete type

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions