Skip to content

Commit

Permalink
fix: Allow type assertions of non-error types (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfloyd committed Dec 1, 2023
1 parent ef170d2 commit f6592d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions errorlint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
continue
}

// If the asserted type is not an error, allow the expression.
if !implementsError(info.TypesInfo.Types[typeAssert.Type].Type) {
continue
}

lints = append(lints, analysis.Diagnostic{
Message: "type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors",
Pos: typeAssert.Pos(),
Expand Down

0 comments on commit f6592d4

Please sign in to comment.