Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.3
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:None
-
Patch:Code
-
Approval:Ok
Description
Records which contain the same field values are not considered to be equal, but the record type is not currently included in the hash. This means that if an heterogenous map contains records of different types, where the fields aren't necessarily distinct, there is a high likelyhood of hash collisions.
I propose that the record type should be included in the hash code algorithm for records. There should be no expectation that unequal records of different types should have the same hash-code.
user=> (hash (->A 1))
1013911913
user=> (hash (->B 1))
1013911913
user=> (= (>A 1) (>B 1))
false
This issue also affects ClojureScript. But see CLJS-97, as ClojureScript also has an issue with record equality.
Potential patch to xor the hash of the record symbol name with the current hash obtained from the data