Skip to content

Commit

Permalink
fix: Is methods should be exempt for type assertions and switches too (
Browse files Browse the repository at this point in the history
  • Loading branch information
triarius authored and polyfloyd committed Aug 20, 2023
1 parent a84d1dc commit 285a074
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions errorlint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
continue
}

if isNodeInErrorIsFunc(info, typeAssert) {
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 Expand Up @@ -330,6 +334,10 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
continue
}

if isNodeInErrorIsFunc(info, typeSwitch) {
continue
}

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

0 comments on commit 285a074

Please sign in to comment.