Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

0 votes
in REPL by

When testing I noticed that my tests for certain warnings when evaluating code in the prepl pass once and then fail. The warnings are only issued once per session:

$ clojure -X clojure.core.server/start-server :name prepl :port 7777 :accept clojure.core.server/io-prepl :server-daemon false &
$ nc localhost 7777
(defn identity [x] x)
{:tag :ret, :val "#'user/identity", :ns "user", :ms 1, :form "(defn identity [x] x)"}
(binding [*out* *err*] (flush))
{:tag :err, :val "WARNING: identity already refers to: #'clojure.core/identity in namespace: user, being replaced by: #'user/identity\n"}
{:tag :ret, :val "nil", :ns "user", :ms 1, :form "(binding [*out* *err*] (flush))"}
(defn identity [x] x)
{:tag :ret, :val "#'user/identity", :ns "user", :ms 1, :form "(defn identity [x] x)"}
(binding [*out* *err*] (flush))
{:tag :ret, :val "nil", :ns "user", :ms 1, :form "(binding [*out* *err*] (flush))"}

Is this expected behavior?

1 Answer

0 votes
by

This shadowing warning mirrors the Clojure behavior no?

by
If you're saying it's expected behavior, I'll take it.

I asked because whenever I load a NS that has shadow functions into the nREPL of Cursive, it complains each time.

So that might be a special behavior in that editor. I should have mentioned that.
by
The method that reports that warning is `Namespace.warnOrFailOnReplace` and depending on how that method is called (via `intern` or `refer` or if nREPL uses it directly) and from where and which vars its checking it will report or not. Sadly, I don't know enough about nREPL to know how it might be calling that method.
...