Uploaded image for project: 'Clojure'
  1. CLJ-867

Records of different types with the same data have the same hashcodes, even though they are not considered to be equal

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: Release 1.3
    • Fix versions: Release 1.5
    • Labels:
      None
    • Approval:
      Ok
    • Patch:
      Code

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              djpowell David Powell
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: