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

Calling meta on records should exclude preserved own metadata? #819

Closed
athos opened this issue Oct 21, 2022 · 8 comments
Closed

Calling meta on records should exclude preserved own metadata? #819

athos opened this issue Oct 21, 2022 · 8 comments

Comments

@athos
Copy link

athos commented Oct 21, 2022

version

The current head of the master branch (207e994)

platform

Clojure CLI version 1.11.1.1165
macOS 12.6

problem & repro

When calling the meta function on a record object, you'll get metadata with the record's preserved own metadata merged:

(require '[sci.core :as sci])
(sci/eval-string "(defrecord R []) (def r (->R)) (meta (with-meta (->R) {:val 42}))")
;=> {:val 42,
;    :type user.R,
;    :sci.impl/record true,
;    :sci.impl/constructor nil,
;    :sci.impl/var nil,
;    :sci.impl.record/map-constructor nil}

Is this the intended behavior or one of the limitations in the current record implementation?

expected behavior

Expected (meta (with-meta x m)) = m to hold for any valid x and m.

@borkdude
Copy link
Collaborator

Previously this was because record was just a regular map and metadata indicated that it was considered a record in SCI, but this implementation has changed and we may be able to get rid of this.

@athos
Copy link
Author

athos commented Oct 21, 2022

Yeah, I was somewhat guessing the current situation from reading this TODO.

@borkdude
Copy link
Collaborator

How critical is this issue for you?

@athos
Copy link
Author

athos commented Oct 21, 2022

Not so critical.
I’m now working on some of my libraries to make them support Babashka and along the way I found some tests (e.g. around here) were failing on Babashka. But some tweaks on the test code will fix the failures, so it’s not a big deal about this case.

@borkdude
Copy link
Collaborator

The way I usually write tests like that (especially in clj-kondo test cases) is to assert that the result has at least the expected keys, but can contain more, so that when adding new keys, existing tests don't break. But I will leave this open and see when it can be fixed eventually.

@borkdude
Copy link
Collaborator

Should be fixed now. Fix also pushed to babashka.

@athos
Copy link
Author

athos commented Oct 23, 2022

Great! Thanks!!
I'm amazed every time I see how productive you are 😳

@borkdude
Copy link
Collaborator

borkdude commented Oct 23, 2022 via email

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

No branches or pull requests

2 participants