isErrorReturnNil returns true if the error return is guaranteed to be nil, false otherwise
(rootNode *RootAssertionNode, errRet ast.Expr)
| 225 | |
| 226 | // isErrorReturnNil returns true if the error return is guaranteed to be nil, false otherwise |
| 227 | func isErrorReturnNil(rootNode *RootAssertionNode, errRet ast.Expr) bool { |
| 228 | if ident, ok := errRet.(*ast.Ident); ok && rootNode.isNil(ident) { |
| 229 | // error return is the literal nil |
| 230 | return true |
| 231 | } |
| 232 | |
| 233 | // check for false cases where error return value may be nil |
| 234 | if asthelper.IsEmptyExpr(errRet) { |
| 235 | // error result is a blank named return ("_ error"), so it's always nil |
| 236 | return true |
| 237 | } |
| 238 | |
| 239 | if exprCallsKnownNilableErrFunc(errRet) { |
| 240 | // error value is the return of a known nilable function |
| 241 | return true |
| 242 | } |
| 243 | return false |
| 244 | } |
| 245 | |
| 246 | // isErrorReturnNonnil returns true if the error return is guaranteed to be nonnil, false otherwise |
| 247 | func isErrorReturnNonnil(rootNode *RootAssertionNode, errRet ast.Expr) bool { |
no test coverage detected