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

Defining a record with defrecord twice breaks record equality

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects versions: Release 1.7, Release 1.6, Release 1.5
    • Fix versions: None
    • Labels:

      Description

      If I spin up a fresh repl and type the following four lines, I consistently get this unexpected behavior. I discovered it because it was breaking a unit test.

      user> (defrecord Foo [bar])
      user.Foo
      user> (= (->Foo 42) #user.Foo{:bar 42}) ;;expect this to evaluate to true
      true
      user> (defrecord Foo [bar])
      user.Foo
      user> (= (->Foo 42) #user.Foo{:bar 42}) ;;expect this to evaluate to true also -- but it doesn't!
      false
      user> 
      

      This may be related to http://dev.clojure.org/jira/browse/CLJ-1457.

      You may also find the following interesting (posted by a fellow irc chatter, reproducible on my machine):

      user=> (defrecord Foo [a])
      user.Foo
      user=> #user.Foo[1]
      #user.Foo{:a 1}
      user=> (defrecord Foo [b])
      user.Foo
      user=> (Foo. 1)
      #user.Foo{:a 1}
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: