-
Notifications
You must be signed in to change notification settings - Fork 2
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
scope capture causes load-file operation to choke on aliased keywords #7
Comments
Thanks for reporting this @RickMoynihan ! What would help me investigate is if we could have a look at the args the middleware is receiving. Could you run this in your REPL: ;;;; instrumenting rewrite-args to see what it receives
(in-ns 'sc.nrepl.impl)
(def seen-args (atom [])
(defn rewrite-args
[ep-id args]
(swap! seen-args conj args)
(if
(nil? ep-id)
args
(update args 0
(fn [arg]
(cond
(and
(-> arg :op (= "load-file"))
(string? (:file arg)))
(update arg :file #(add-letsc ep-id %))
(and
(-> arg :op (= "eval"))
(string? (:code arg)))
(update arg :code #(add-letsc ep-id %))
:else
arg))))) ... then reproduce the error, and post me the result of Cheers, |
Hmm... I can't easily print that form as it contains circular references. |
@RickMoynihan Maybe by doing something like (binding [*print-level* 5]
(prn @sc.nrepl.impl/seen-args)) ? |
Hmmm... whenever I try and reproduce this in a minimal context it appears to work. |
I have the same issue - while in the context of an Execution Point, I cannot evaluate any code that contains an aliased namespaced keyword. If I replace the alias with the full namespace it works again. The following throws an error: I get the same stacktrace as above. |
Here's some more info: I wrapped rewrite-args update function in an exception handler, and the arg value that throws the exception is:
What's strange is that when I manually run it I can't replicate the error, only when it is run as part of the nrepl middleware. I can reliably replicate this, so please let me know if I can send more information. |
It seems to be a problem with the clojure reader when reading aliased keywords (see here as well) I've changed the
|
@mjmeintjes thanks for investigating. Unfortunately I currently don't have much time for reviewing this; in the meantime:
|
Thanks, I'll test it a bit more and then push a fork. |
Did you ever push that fork @mjmeintjes? |
Use rewrite-clj to read forms, thanks to @mjmeintjes
Ok, I can confirm the suggested fix works, though obviously it involves picking up a dependency. Regardless this is useful for me, and may be handy for others so I pushed a fork and coined a clojars release with @mjmeintjes patch. If there's any interest in merging a PR with the fix here I can issue one. |
I'm not sure why this is occuring but it seems scope-capture-nrepl somehow prevents cider/nrepl
"load-file"
operation from working; if the namespace being loaded includes an aliased keyword.I'm not sure if this is peculiar to my setup but if I disable scope capture the operation appears to work, where as it would fail with scope capture.
A failing case would be something like this:
Additionally I've tried recreating things minimally by modifying the
rewrite-args
forms here to include the above ns in the string, but I can't seem to manufacture a failure that way; though I don't really understand the details here.scope-capture-nrepl/src/sc/nrepl/impl.clj
Lines 78 to 79 in a94c0fe
The text was updated successfully, but these errors were encountered: