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

0 votes
in ClojureScript by

Overwriting symbols that are defined in cljs.core works fine and prints an expected warning. One case where this fails is when a symbol that was replaces was originally a macro and it's invoked without namespace qualification. An example:

`}
;;;;;;; file a ;;;;;;
(ns file.a)
(defn + [& vals]
(prn "Called!")
(apply cljs.core/+ vals))
;;;;;;; file b ;;;;;;
(ns file.b
(:require [file.a :refer [+]]))
(+ 1 2 ) ;; Doesn't print "Called!"
(file.a/+ 1 2) ;; Prints "Called!"
(var +) => file.a/+
(+ 1 2) ;; Prints "Called!" ``
}

The same symbol + alone by itself in file b calls cljs.core/+ despite it being referred and all var resolution resolves to file.a/+. This seems not to be the case when overwriting functions from cljs.core, for example overwriting the function map works fine.

`
;;;;;;; file a ;;;;;;
(ns file.a)
(defn map [f coll]
(prn "map called!")
(cljs.core/map f coll))
;;;;;;; file b ;;;;;;
(ns file.b
(:require [file.a :refer [map]]))

(map inc [1 2 3]) => "map called!" (2 3 4)
`
}

1 Answer

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