File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 boxes user dynvars too (cross-module set! in
623+ ; ; per-file ESM output), but its cljs.core vars are real CLJS vars:
624+ ; ; a reference resolved to the core module alias stays plain.
623625 (emit-return (escape-jsx
624- (cond-> expr
625- (and (not= :cherry (:target env))
626- (dynamic-name? orig-sym)
627- (not (contains? (:var->ident env) orig-sym)))
628- (str " .val" ))
626+ (let [core-ref? (when-let [core-alias (:core-alias env)]
627+ (str/starts-with? (str expr) (str core-alias " ." )))]
628+ (cond-> expr
629+ (and (dynamic-name? orig-sym)
630+ (not (contains? (:var->ident env) orig-sym))
631+ (or (not= :cherry (:target env))
632+ (not core-ref?)))
633+ (str " .val" )))
629634 env)
630635 env))))))
631636
802807 init (emit expr (expr-env env*))
803808 ; ; a dynamic var (earmuffed) compiles to a mutable box {value ...} so
804809 ; ; 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))
810+ ; ; Cherry too: only its cljs.core vars are plain (see the symbol emit).
811+ init (if (dynamic-name? name)
808812 (str " ({val: " init " })" )
809813 init)]
810814 (str " var " ident " = "
You can’t perform that action at this time.
0 commit comments