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

zip/root isn't idempotent #311

Closed
NoahTheDuke opened this issue Sep 4, 2024 · 4 comments
Closed

zip/root isn't idempotent #311

NoahTheDuke opened this issue Sep 4, 2024 · 4 comments

Comments

@NoahTheDuke
Copy link

Version
1.1.48

Platform
Operating System: MacOS
Clojure version: 1.11.4
JDK vendor and version: openjdk 17.0.11 2024-04-16

Symptom
Can't call zip/root on a zipper multiple times.

Reproduction

(require '[rewrite-clj.zip :as zip])

(zip/root (zip/root (zip/of-string "a")))

Actual behavior
Throws a ClassCastException with message: "class rewrite_clj.node.forms.FormsNode cannot be cast to class clojure.lang.IFn (rewrite_clj.node.forms.FormsNode is in unnamed module of loader clojure.lang.DynamicClassLoader @653a5a; clojure.lang.IFn is in unnamed module of loader 'app')"

Expected behavior
I would expect that zip/root is idempotent and can be called repeatedly on a zipper.

Diagnosis
I haven't looked at the code yet, so I'm not sure.

Action
Wait and see.

@NoahTheDuke
Copy link
Author

Having written all that out, I see that the docstring says that zip/root returns a node, not a zipper? How do you traverse to the root of the zipper?

@lread
Copy link
Collaborator

lread commented Sep 4, 2024

I'm not crazy about the naming of the zip/root fn.
But it comes from clojure.zip (which uses terminology from Huet's Zipper paper), so we'll keep using it.
As you've noticed it does not return a zipper, it returns the root node with all changes applied.

There is an open issue about traversing to the top node #149.
If you are still stuck, leave another comment.

@lread
Copy link
Collaborator

lread commented Sep 5, 2024

@NoahTheDuke, is this issue good to close now?
Or do you think we should discuss more?

@lread
Copy link
Collaborator

lread commented Sep 6, 2024

Chatted with @NoahTheDuke, he's good to close this one.

@lread lread closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2024
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