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

map-vals and map-keys don't understand #_uneval-nodes #79

Closed
doby162 opened this issue May 2, 2020 · 5 comments
Closed

map-vals and map-keys don't understand #_uneval-nodes #79

doby162 opened this issue May 2, 2020 · 5 comments
Labels

Comments

@doby162
Copy link

doby162 commented May 2, 2020

This seems related to #70, but it causes the nodes returned bu map-vals and map-keys to not correctly correspond to the values and keys in a hashmap if the hashmap contains uneval nodes.

@borkdude
Copy link
Collaborator

borkdude commented May 2, 2020

@doby162 It might be worth checking if https://github.com/lread/rewrite-cljc-playground solves this problem for you. The author @lread is working on this as a merger of rewrite-clj and rewrite-cljs. I've been using it in carve which has been exposed to quite a lot of code and so far I haven't heard anyone complain.

@doby162
Copy link
Author

doby162 commented May 2, 2020

Thank you, I'll check that out!

@lread lread added the bug label Jan 23, 2021
@lread
Copy link
Collaborator

lread commented Jan 23, 2021

Did I fix this in rewrite-clj v1? I'll check.

@lread
Copy link
Collaborator

lread commented Jan 26, 2021

@doby162 it has been a while since you reported this issue, thanks for raising it.

I'll try to guess what you were seeing, I'm testing against the main branch of rewrite-clj.

Let's start with something that works:

(-> "{:a 1 :b 2 :c 3}"
    z/of-string
    z/sexpr)
;; => {:c 3, :b 2, :a 1}

And now we'll introduce some uneval:

(-> "{:a 1 #_#_:b 2 :c 3}"
    z/of-string
    z/sexpr)
;; => {:c 3, :a 1}

That works too.

But... if we introduce uneval that would create an uneven number of forms in our map, we'll trigger an exception:

(-> "{:a 1 #_:b 2 :c 3}"
    z/of-string
    z/sexpr)
;; ; IllegalArgumentException No value supplied for key: 3  clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)

This is normal rewrite-clj behaviour. It allows this type of illegal map, but because it is not legal Clojure it cannot be sexpr-essed.

Is this anything like the error you were encountering?

If not, please provide a minimal code example that reproduces the failure you were encountering.

@lread
Copy link
Collaborator

lread commented Feb 2, 2021

No response received, assuming we are good, if not can re-open in the future.

@lread lread closed this as completed Feb 2, 2021
@lread lread added this to rewrite-clj Jul 3, 2024
@lread lread moved this to Done in rewrite-clj Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

3 participants