Skip to content

Commit 29eb8e0

Browse files
author
dnolen
committed
CLJS-1617: Evaluation order of arguments to 'list' is right-to-left
don't optimize list construction unless we have constants
1 parent 9a2be8b commit 29eb8e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,9 +2377,13 @@
23772377
assoc :tag 'array)))
23782378

23792379
(core/defmacro list
2380-
([] '(.-EMPTY cljs.core/List))
2380+
([]
2381+
'(.-EMPTY cljs.core/List))
23812382
([x & xs]
2382-
`(-conj (list ~@xs) ~x)))
2383+
(if (= :constant (:op (cljs.analyzer/analyze &env x)))
2384+
`(-conj (list ~@xs) ~x)
2385+
`(let [x# ~x]
2386+
(-conj (list ~@xs) x#)))))
23832387

23842388
(core/defmacro vector
23852389
([] '(.-EMPTY cljs.core/PersistentVector))

0 commit comments

Comments
 (0)