Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SA4023: false positive involving generics #1242

Closed
dominikh opened this issue Apr 1, 2022 · 0 comments
Closed

SA4023: false positive involving generics #1242

dominikh opened this issue Apr 1, 2022 · 0 comments

Comments

@dominikh
Copy link
Owner

@dominikh dominikh commented Apr 1, 2022

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
dominikh added a commit that referenced this issue Apr 3, 2022
…turn untyped nil

Closes gh-1242

(cherry picked from commit e88e689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant