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

0 votes
in ClojureScript by
If you rename a core Var, you will get a warning if you redefine it. It is as if the {{:rename}} doesn't imply {{:exclude}}.

Repro with QuickStart JAR:


$ java -jar cljs.jar -m cljs.repl.node
ClojureScript Node.js REPL server listening on 52319
To quit, type: :cljs/quit
cljs.user=> (ns foo.core (:refer-clojure :rename {map clj-map}))
nil
foo.core=> (map inc [1 2])
(2 3)
foo.core=> (def map {:a :b})
WARNING: map already refers to: cljs.core/map being replaced by: foo.core/map at line 1 <cljs repl>
#'foo.core/map
foo.core=> map
{:a :b}
foo.core=> (clj-map inc [1 2])
(2 3)


Compare to Clojure:


user=> (ns foo.core (:refer-clojure :rename {map clj-map}))
nil
foo.core=> (map inc [1 2])

CompilerException java.lang.RuntimeException: Unable to resolve symbol: map in this context, compiling:(/private/var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/form-init8370940485091648461.clj:1:1)
foo.core=> (def map {:a :b})
#'foo.core/map
foo.core=> map
{:a :b}
foo.core=> (clj-map inc [1 2])
(2 3)


Note that you cannot workaround this by simply adding an explicit {{:exclude}} for {{map}} above. While this works with the current ClojureScript compiler, it breaks in Clojure, making the alias symbol {{clj-map}} unresolvable.

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2292 (reported by mfikes)
...