You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If isNilOrFoo = isNilOrFoo || *s1 == "foo" is changed to isNilOrFoo = *s1 == "foo" no diagnostic is reported.
In fact isNilOrFoo is known to be false in isNilOrFoo || *s1 == "foo", which is probably the cause of the diagnostic. But it is very confusing that a diagnostic is reported on s1 == nil.
I don't know how this could be improved, but wanted to provide this as a test case as it caused confusion.
The text was updated successfully, but these errors were encountered:
gopherbot
added
the
Tools
This label describes issues relating to any tools in the x/tools repository.
label
Apr 17, 2025
because the SSA representation for both is essentially identical. This causes it to report an error for what it thinks is the second occurrence of the s1 == nil condition in the second program, which would be a correct diagnostic---except that the s1 == nil.
The fix is to record additional bookkeeping in the SSA representation (such as enabling the GlobalDebug flag, but that's too expensive). Needs some careful thought. Apologies for the confusion.
I'm going to close this issue as a dup, but mention it from the canonical issue.
Go version
go version go1.24.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I checked out commit f76b112f11ae44045f70b22a3d0dc0627f72ae10 of https://github.com/golang/tools.
Added the following to the end of https://github.com/golang/tools/blob/master/go/analysis/passes/nilness/testdata/src/a/a.go:
Went to the the path
go/analysis/passes/nilness
and rungo test
.What did you see happen?
I saw a diagnostic reported.
What did you expect to see?
No diagnostic should be reported.
If
isNilOrFoo = isNilOrFoo || *s1 == "foo"
is changed toisNilOrFoo = *s1 == "foo"
no diagnostic is reported.In fact
isNilOrFoo
is known to be false inisNilOrFoo || *s1 == "foo"
, which is probably the cause of the diagnostic. But it is very confusing that a diagnostic is reported ons1 == nil
.I don't know how this could be improved, but wanted to provide this as a test case as it caused confusion.
The text was updated successfully, but these errors were encountered: