You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In cider.nrepl.middleware.out/print-stream
the proxy OutputStream for the PrintWriter later bound to System/setOut ends up doing this
(resolve '*out*)
(same goes for *err*)
The point is that this is an unqualified reference to *out*, instead of clojure.core/*out*. This can cause issues if System/out is being called from *ns*'s that do not automatically have clojure.core/*out* mapped to the ns-interns.
In particular, I saw this come up in a CLJS macroexpansion situation, where System/out was called and the *ns* was bound to cljs.main during the CLJS compiler's analysis stage.
I believe a solution to this issue may be to fully-qualify these symbols so that the macro doesn't implicitly rely on what *ns* is bound to when these PrintStream.write methods are called.
Expected behavior
wrap-out to work transparently when System/out called in application.
Actual behavior
wrap-out can sometimes cause NullPointerException if the caller calls System/out with a *ns* bound that cannot resolve the bare, unqualified symbol *out* or *err*.
This comes up in CLJS if there is a macro that calls something like (.println System/out s) during macroexansion with the *ns* bound to the cljs.main ns.
In
cider.nrepl.middleware.out/print-stream
the
proxy
OutputStream for thePrintWriter
later bound toSystem/setOut
ends up doing this(resolve '*out*)
(same goes for
*err*
)The point is that this is an unqualified reference to
*out*
, instead ofclojure.core/*out*
. This can cause issues ifSystem/out
is being called from*ns*
's that do not automatically haveclojure.core/*out*
mapped to thens-interns
.In particular, I saw this come up in a CLJS macroexpansion situation, where
System/out
was called and the*ns*
was bound tocljs.main
during the CLJS compiler's analysis stage.I believe a solution to this issue may be to fully-qualify these symbols so that the macro doesn't implicitly rely on what
*ns*
is bound to when thesePrintStream.write
methods are called.Expected behavior
wrap-out
to work transparently whenSystem/out
called in application.Actual behavior
wrap-out
can sometimes causeNullPointerException
if the caller callsSystem/out
with a*ns*
bound that cannot resolve the bare, unqualified symbol*out*
or*err*
.This comes up in CLJS if there is a macro that calls something like
(.println System/out s)
during macroexansion with the*ns*
bound to thecljs.main
ns.Steps to reproduce the problem
I believe all you need to show it is
A real-world example is vvvvalvalval/scope-capture#24 (comment)
Environment & Version information
cider-nrepl version
0.17.0
but this is still in
master
and is in older versions as well.Java version
1.8, 1.9 etc
The text was updated successfully, but these errors were encountered: