Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different defrecords with same fields are equal #735

Closed
frenchy64 opened this issue May 18, 2022 · 4 comments · Fixed by #736
Closed

Different defrecords with same fields are equal #735

frenchy64 opened this issue May 18, 2022 · 4 comments · Fixed by #736

Comments

@frenchy64
Copy link

version

Via Babashka v0.8.2 REPL

platform

Via Babashka v0.8.2 REPL
Intel Mac

problem

Different defrecords with same fields are equal. Causes this schema unit test to fail, since the schema implementation defines:

(clojure.core/defrecord RequiredKey [k])
(clojure.core/defrecord OptionalKey [k])

repro

Babashka v0.8.2 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (defrecord A [a])
#'user/A
user=> (defrecord B [a])
#'user/B
user=> (= (A. 1) (B. 1))
true

expected behavior

Clojure 1.11.1
user=> (defrecord A [a])
user.A
user=> (defrecord B [a])
user.B
user=> (= (A. 1) (B. 1))
false
frenchy64 added a commit to frenchy64/schema that referenced this issue May 18, 2022
@borkdude
Copy link
Collaborator

borkdude commented May 18, 2022

Related: #727

@borkdude
Copy link
Collaborator

Working on a fix by adding a field __sci_type which is different for each record, but this breaks existing libraries that babashka runs in CI:

{:test 1785, :pass 10291, :fail 7, :error 2}

We probably need to move on to a custom record implementation to make this work properly...

@borkdude
Copy link
Collaborator

Got all tests passing now in branch with a custom record implementation, at least in the :clj side of things! In babashka branch record-equiv.

@frenchy64
Copy link
Author

We probably need to move on to a custom record implementation to make this work properly...

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants