We're updating the issue view to help you get more done. 

with-redefs on core functions works slightly differently than for Clojure

Description

The following session demonstrates behavior in a ClojureScript REPL. The exact same code in a Clojure REPL causes both with-redefs to behave similarly to the first one.

Possibility: this difference in behavior is because core ClojureScript functions called from user code are by default direct-linked in the user's functions, whereas in Clojure they are indirected through Vars (by default, with direct linking disabled while compiling user code).

```
;; Command to start ClojureScript REPL:

;; clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.520\"}}}" -m cljs.main --repl-env node

(defn wrapme [wrapped-fn a another-fn]
(fn [& args]
(println "called wrapped fn")
(let [ret (apply wrapped-fn args)]
(apply another-fn a ret args)
ret)))

(defn f1 [x y & args]
(println "f1 x=" x "y=" y "args=" (vec args)))

(def my-vector vector)

(defn other-f4 [p q r]
(println "f4 here")
(my-vector p q r))

;; this causes other-f4 to call wrapme'd version of my-vector
;; printing these msgs:
;; f4 here
;; called wrapped fn
;; f1 x= foo ...
(with-redefs [my-vector (wrapme my-vector "foo" f1)]
(other-f4 13 17 19))

(defn f4 [p q r]
(println "f4 here")
(vector p q r))

;; This only prints:
;; f4 here
;; so it must not be calling the wrapped version of the function, nor f1
(with-redefs [vector (wrapme vector "foo" f1)]
(f4 13 17 19))
```

Environment

None

Status

Assignee

Unassigned

Reporter

Andy Fingerhut

Labels

None

Approval

None

Patch

None

Priority

Minor