Skip to content

Commit 7916a67

Browse files
anmonteiroswannodette
authored andcommitted
CLJS-2368: Self-host: Never compile macro namespaces with :optimize-constants true
Macro namespaces may be evaluated in a compiler environment that is different from the one which has emitted the constants table, which leads to cryptic errors because the constants are not available in the evaluating environment.
1 parent 6e5cb90 commit 7916a67

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/cljs/cljs/js.cljs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@
224224
[bound-vars cache opts cb]
225225
(process-deps bound-vars
226226
(distinct (vals (:require-macros cache)))
227-
(assoc opts :macros-ns true)
227+
(-> opts
228+
(assoc :macros-ns true)
229+
(dissoc :emit-constants :optimize-constants))
228230
cb))
229231

230232
(defn- process-libs-deps
@@ -487,7 +489,8 @@
487489
(assoc :macros-ns true)
488490
(dissoc :context)
489491
(dissoc :def-emits-var)
490-
(dissoc :ns))]
492+
(dissoc :ns)
493+
(dissoc :emit-constants :optimize-constants))]
491494
(require bound-vars nsym k opts'
492495
(fn [res]
493496
(if-not (:error res)
@@ -1072,7 +1075,8 @@
10721075
(:def-emits-var opts))
10731076
(compile-loop ns'))))))
10741077
(do
1075-
(.append sb (with-out-str (comp/emit ast)))
1078+
(env/with-compiler-env (assoc @(:*compiler* bound-vars) :options opts)
1079+
(.append sb (with-out-str (comp/emit ast))))
10761080
(recur ns'))))))
10771081
(do
10781082
(when (:source-map opts)

0 commit comments

Comments
 (0)