-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmp: top-level interfaces are not matched #88
Comments
In working on this, I attempted to always promote to an Line 87 in 5411ab9
would become something like: iface := reflect.TypeOf((*interface{})(nil)).Elem()
s.compareAny(reflect.ValueOf(x).Convert(iface), reflect.ValueOf(y).Convert(iface)) However, this does not work because the My next thought was to dynamically create an interface type T that had the common set of methods for both the x and y values. If the underlying types of x and y are each individually assignable to some interface R, then it is guaranteed that T is also assignable to R. However, this approach requires dynamically creating an interface, which is functionality that On that thread, @Merovius commented:
You are correct that the
This rule prevents |
Fixed by #112. |
Consider the following:
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 tocmp.Equal
reports false because the underlying types are not equal, before even giving the customComparer
passed in a chance to apply.We should probably box the top-level values into an empty interface to fix this.
\cc @neild
The text was updated successfully, but these errors were encountered: