-
Notifications
You must be signed in to change notification settings - Fork 53
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
False positive in error handling logic for "always-safe" case #151
Comments
I have a somewhat similar false positive... // Library code
func (t *Thing) GetFoo() (*string, bool) {
if t == nil || t.Foo == nil {
return nil, false
}
return t.Foo, true
}
// Application code
if ptr, ok := t.GetFoo(); ok {
v := *ptr // nilaway reports this deference hasn't been checked, when it has, by the GetFoo method
} |
@Integralist, you're absolutely right. However, the false positive you reported is due to a slightly different reason. It's occurring because NilAway doesn't currently understand the |
Amazing, thanks @sonalmahajan15 for clarifying 👍🏻 |
@sonalmahajan15 I think this has been resolved? |
(Linking related issue #199) |
@sonalmahajan15 any idea if this will be addressed soon? |
@sircelsius: I am working on addressing this issue at the moment. Hopefully I should have the support for "always-safe" case ready in a couple of weeks. |
NilAway is encoded with the pattern that if the error return is non-nil, then inherently assume non-error returns to be nilable, and hence need guarding. However, this reports a false positive when the non-error return is always returned as non-nil, independent of the status of the error return, and hence does not really need to be guarded.
The text was updated successfully, but these errors were encountered: