Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Nested let-mutable's #7

Open
vitvly opened this issue Oct 22, 2016 · 1 comment
Open

Nested let-mutable's #7

vitvly opened this issue Oct 22, 2016 · 1 comment

Comments

@vitvly
Copy link

vitvly commented Oct 22, 2016

Hi!

Thank you for your open-source work!

I've recently ran into an issue with Proteus, namely that

(let-mutable [a 3
              b (let-mutable [c 1 ]
                  c)]
  b)

will yield

CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to proteus.Containers$L, compiling:(proteus.clj:123:1)

After macro-expanding it turns out that read-form gets applied twice to c. After some debugging i've figured out how to address the issue by modifying the code of read-form to

(defn- read-form [x]
  (if (not (:tag (meta x)))
    (-> (locals) (find x) key* meta ::read-form)
    nil))

It checks for the presence of :tag in local's metadata, which should only be there if it is being processed by the let-mutable macro at the current level of nesting.

It seems that a corresponding fix to write-form is not necessary.

If the above is correct and there are no stupid mistakes on my part, i can make a pull request.

Thanks again,
Vitaliy.

@ztellman
Copy link
Owner

It's been a while since I've looked at this code, but that seems like a sane fix to me. If you can open a pull request with some additional test cases, I'd appreciate it.

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

No branches or pull requests

2 participants