Skip to content

Commit 09b85c5

Browse files
committed
Uniform dynvar boxes for cherry too, core vars proxied by accessor boxes
1 parent 858d0d5 commit 09b85c5

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/squint/compiler_common.cljc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,11 @@
619619
(let [m (munged-name expr)]
620620
m)))))]
621621
;; a reference to a dynamic var (earmuffed, not a local) reads the
622-
;; box's .val. Cherry has real CLJS dynamic vars, no box.
622+
;; box's .val. Cherry too: its npm lib exports accessor boxes that
623+
;; proxy the real cljs.core vars.
623624
(emit-return (escape-jsx
624625
(cond-> expr
625-
(and (not= :cherry (:target env))
626-
(dynamic-name? orig-sym)
626+
(and (dynamic-name? orig-sym)
627627
(not (contains? (:var->ident env) orig-sym)))
628628
(str ".val"))
629629
env)
@@ -802,9 +802,8 @@
802802
init (emit expr (expr-env env*))
803803
;; a dynamic var (earmuffed) compiles to a mutable box {value ...} so
804804
;; set!/binding can mutate it across ESM modules; references read .value.
805-
;; Cherry has real CLJS dynamic vars, no box.
806-
init (if (and (not= :cherry (:target env))
807-
(dynamic-name? name))
805+
;; Cherry boxes user dynvars the same way.
806+
init (if (dynamic-name? name)
808807
(str "({val: " init "})")
809808
init)]
810809
(str "var " ident " = "

0 commit comments

Comments
 (0)