-
Notifications
You must be signed in to change notification settings - Fork 12
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
Userland macros receives RCF env as &env instead of standard clojure &env value #74
Comments
Minimal repro: (defmacro my-test-macro [a]
(prn &env)
`[~a])
;; No RCF
(let [a 1]
(my-test-macro a))
;; => {a #object[clojure.lang.Compiler$LocalBinding 0x58d44b9f "clojure.lang.Compiler$LocalBinding@58d44b9f"]}
;; => [1]
;; From inside RCF
(tests
(let [a 1]
(my-test-macro a)) := [1])
;; => {a {:op :binding, :name a, :init {:op :const, :env {:locals {}, :namespaces {}, :ns hyperfiddle.rcf-test}, :form 1}, :form a, :local :let, :children [:init]}}
;; => ✅ |
It is not clear to me if one can construct a valid instances of LocalBinding. I tried to produce an instance of LocalBinding, but got an |
|
I'm using &env to get all current locals, their primitive type, and their attached metadata. In my macro, I do the following:
To get all local symbols from I also do this:
On each LocalBinding returned from I believe this is the type for what &env returns: https://www.javadoc.io/doc/org.clojure/clojure/1.11.1/clojure/lang/Compiler.LocalBinding.html |
So I saw that riddley macro-expander I think seems to create LocalBindings as it macro-expands: https://github.com/ztellman/riddley/blob/master/src/riddley/compiler.clj#L55 and https://github.com/ztellman/riddley/blob/master/src/riddley/Util.java#L8 which you could also do in Clojure I guess. It does seem you have to somewhat update the Compiler about it, or the creation of the LocalBinding will throw an IllegalAccessError or something of that sort. Might be a lead? |
Reported by @didibus
A minimal repro is welcome
The text was updated successfully, but these errors were encountered: