Skip to content

Commit 285a074

Browse files
triariuspolyfloyd
authored andcommitted
fix: Is methods should be exempt for type assertions and switches too (#50)
1 parent a84d1dc commit 285a074

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

errorlint/lint.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
303303
continue
304304
}
305305

306+
if isNodeInErrorIsFunc(info, typeAssert) {
307+
continue
308+
}
309+
306310
lints = append(lints, analysis.Diagnostic{
307311
Message: "type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors",
308312
Pos: typeAssert.Pos(),
@@ -330,6 +334,10 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
330334
continue
331335
}
332336

337+
if isNodeInErrorIsFunc(info, typeSwitch) {
338+
continue
339+
}
340+
333341
lints = append(lints, analysis.Diagnostic{
334342
Message: "type switch on error will fail on wrapped errors. Use errors.As to check for specific errors",
335343
Pos: typeAssert.Pos(),

0 commit comments

Comments
 (0)