if target == nil {
return err == target
}
+
+ isComparable := target == nil || reflectlite.TypeOf(target).Comparable()
for {
- if err == target {
+ if isComparable && err == target {
return true
}
if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) {
{poser, errb, false},
{poser, erro, false},
{poser, errco, false},
+ {errorUncomparable{}, errorUncomparable{}, true},
+ {errorUncomparable{}, &errorUncomparable{}, false},
+ {&errorUncomparable{}, errorUncomparable{}, true},
+ {&errorUncomparable{}, &errorUncomparable{}, false},
+ {errorUncomparable{}, err1, false},
+ {&errorUncomparable{}, err1, false},
}
for _, tc := range testCases {
t.Run("", func(t *testing.T) {
}
func (p *printer) Print(args ...interface{}) { fmt.Fprint(&p.buf, args...) }
+
+type errorUncomparable struct {
+ f []string
+}
+
+func (errorUncomparable) Error() string {
+ return "uncomparable error"
+}
+
+func (errorUncomparable) Is(target error) bool {
+ _, ok := target.(errorUncomparable)
+ return ok
+}