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

equality bug on records created with nested calls to map->record

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: Release 1.6
    • Fix versions: Release 1.7
    • Labels:
    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      Depending on the type of the map passed to a record map constructor, records will not correctly compare for equality:

      user> (defrecord a []) 
      user.a
      user> (def r1 (map->a {:a 1}))
      nil
      user> (def r2 (map->a r1))
      nil
      user> (= r1 r2)  ;; expected => true
      false
      user> (.__extmap r1)
      {:a 1}
      user> (.__extmap r2)  ;; expected => {:a 1}
      #user.a{:a 1}
      

      Cause: The type of the map passed into the map constructor leaks into the __extmap, affecting equality comparison of the record. This bug was described in this post: https://groups.google.com/forum/#!topic/clojure/iN-SPBaTFUw

      Approach: Clean the extmap before putting it into the record constructor.

      Patch: CLJ-1388-record-equality-and-map-record-factory.patch

      Screened by: Alex Miller

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bronsa Nicola Mometto
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: