[CLJ-1242] = on sorted collections with different key types incorrectly throws Created: 31/Jul/13 Updated: 21/Jan/16
|Affects Version/s:||Release 1.5, Release 1.6|
|Patch:||Code and Test|
Comparing a sorted-set with numbers to a set with keywords is not symmetric:
The latter case should return false instead of throwing.
Cause: APersistentMap.equiv() and APersistentSet.equiv() do not expect this exception be thrown from the containsKey()/contains() check. It would probably be best for PersistentTreeMap and PersistentTreeMap to implement equiv() and handle that possibility appropriately. Should also consider similar changes in equals() if necessary.
|Comment by OHTA Shogo [ 31/Jul/13 8:02 PM ]|
PersistentVector also has the same problem.
user=> (compare  [:a])
The cause of this problem is that Util.compare() casts the second argument
|Comment by OHTA Shogo [ 31/Jul/13 8:26 PM ]|
Umm, my brain was not working right.
|Comment by François Rey [ 02/May/15 4:44 PM ]|
|Comment by Stuart Halloway [ 30/Jul/15 11:09 AM ]|
The behavior of get is consistent with Java collections, so I think changing that expectation should be considered a feature request and not a bug.
The fix for equals should be informed by the approach taken in the JDK, where the implementation of equals (not get) has exception catchers.
|Comment by Alex Miller [ 21/Jan/16 10:33 AM ]|
I re-focused this ticket on just the equality aspect. The other request regarding `get` with a value of a different type is consistent with Java behavior and should be considered "as designed" - a separate enhancement ticket could be considered for that one.