-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Description
Consider the following:
equalErrors := cmp.Comparer(func(_, _ error) bool { return true })
cmp.Equal(io.EOF, &os.PathError{}, equalErrors) // false
type E struct{ E error }
cmp.Equal(E{io.EOF}, E{&os.PathError{}}, equalErrors) // true
Note that the first comparison always reports false, while the later reports true. The reason is because reflect.ValueOf
on an interface loses information about the fact that the value passed in is an interface. Thus, the first call to cmp.Equal
reports false because the underlying types are not equal, before even giving the custom Comparer
passed in a chance to apply.
We should probably box the top-level values into an empty interface to fix this.
\cc @neild
Metadata
Metadata
Assignees
Labels
No labels