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
openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment Zulu17.30+15-CA (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM Zulu17.30+15-CA (build 17.0.1+12-LTS, mixed mode, sharing)
problem
ns-unmap and intern are not successful at rebinding a referred var if that var shares a name with an existing var supplied via the 'user namespace or the :bindings context options key.
repro
(require '[sci.core :as sci])
(require '[clojure.test :refer [is]])
(let [remote {'cake "cake"}
opts {:namespaces {'remote remote}
:bindings {'cake "new-cake"}}]
;; First confirm that `cake` evaluates to "new-cake":
(is (="new-cake"
(sci/eval-form (sci/init opts) 'cake)))
;; I can overwrite bindings with `ns-unmap` and `intern`:
(is (="bar"
(sci/eval-form
(sci/init opts)
'(do (ns-unmap *ns* 'cake)
(intern *ns* 'cake "bar")
cake))))
;; BUG: Rebinding a referred var using `ns-unmap` and `intern` fails when;; some var of the same name was set using the `:bindings` key.
(is (="cake"
(sci/eval-form
(sci/init opts)
'(do (require '[remote :refer [cake]])
(ns-unmap *ns* 'cake)
(intern *ns* 'cake "bar")
cake))))
;; This is also a problem if the initial bindings are supplied to the;; `'user` namespace (I am pretty sure these are equivalent)
(is (="cake"
(sci/eval-form
(sci/init (-> opts
(dissoc:bindings)
(assoc-in [:namespaces 'user] (:bindings opts))))
'(do (require '[remote :refer [cake]])
(ns-unmap *ns* 'cake)
(intern *ns* 'cake "bar")
cake))))
;; If `'cake` is not present in bindings, or if `:bindings` is gone, the bug;; goes away and we can rebind the referred var:
(is (="bar"
(sci/eval-form
(sci/init (update opts :bindings dissoc 'cake))
'(do (require '[remote :refer [cake]])
(ns-unmap *ns* 'cake)
(intern *ns* 'cake "bar")
cake)))))
The text was updated successfully, but these errors were encountered:
version
0.2.7
platform
JVM:
openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment Zulu17.30+15-CA (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM Zulu17.30+15-CA (build 17.0.1+12-LTS, mixed mode, sharing)
problem
ns-unmap
andintern
are not successful at rebinding a referred var if that var shares a name with an existing var supplied via the'user
namespace or the:bindings
context options key.repro
The text was updated successfully, but these errors were encountered: