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
For error-returning functions, NilAway will check if the error is properly checked, otherwise the pointer result will be treated as nilable. However, NilAway currently only supports checking the errors via an if statement, but not a type switch. Consider the following example:
funcaa() (*int, error) {
returnnew(int), nil
}
funcbb() {
ptr, err:=aa()
iferr==nil {
print(*ptr) // OK, no NilAway errors.
}
switcherr.(type) {
casenil:
print(*ptr) // Also OK, but NilAway does report an error.// analysistest.go:459: go.uber.org/errorreturn/inference/errorreturn-with-inference.go:191:10: unexpected diagnostic: Value returned as result 0 from the function `aa` lacking guarding (definitely nilable) and is dereferenced at "inference/errorreturn-with-inference.go:191:10" (must be nonnil)
}
}
The case nil in the type switch has the same effect as a normal if statement check if err == nil, but NilAway doesn't seem to understand this fact.
The text was updated successfully, but these errors were encountered:
For error-returning functions, NilAway will check if the error is properly checked, otherwise the pointer result will be treated as nilable. However, NilAway currently only supports checking the errors via an if statement, but not a type switch. Consider the following example:
The
case nil
in the type switch has the same effect as a normal if statement checkif err == nil
, but NilAway doesn't seem to understand this fact.The text was updated successfully, but these errors were encountered: