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
NilAway reports a false positive when a value (m) calls a method (m.foo()) with a pointer receiver, not being able to understand the implicit conversion that takes place: (&m).foo().
type myInt int
func (m *myInt) foo() *myInt {
if m == nil {
return nil
}
return m
}
func test(m myInt) {
v := m.foo()
_ = *v // FP here
}
However, if we convert this into a regular parameter, then NilAway can reason about the flow correctly and does not report any false positive.
type myInt int
func foo(m *myInt) *myInt {
if m == nil {
return nil
}
return m
}
func test(m myInt) {
v := foo(&m)
_ = *v // no error -- correct behavior
}
The text was updated successfully, but these errors were encountered:
NilAway reports a false positive when a value (
m
) calls a method (m.foo()
) with a pointer receiver, not being able to understand the implicit conversion that takes place:(&m).foo()
.However, if we convert this into a regular parameter, then NilAway can reason about the flow correctly and does not report any false positive.
The text was updated successfully, but these errors were encountered: