Skip to content

Commit 59ae42e

Browse files
committed
CLJS-3095: apply vector with array acts as vec
In this case, clone the array.
1 parent c4a5120 commit 59ae42e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5721,7 +5721,7 @@ reduces them without incurring seq initialization"
57215721
"Creates a new vector containing the args."
57225722
[& args]
57235723
(if (and (instance? IndexedSeq args) (zero? (.-i args)))
5724-
(.fromArray PersistentVector (.-arr args) true)
5724+
(.fromArray PersistentVector (.-arr args) (not (array? (.-arr args))))
57255725
(vec args)))
57265726

57275727
(declare subvec)

src/test/cljs/cljs/core_test.cljs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,3 +1789,9 @@
17891789
(is (= [] (subvec [1 2 3 4] 1.7 1.3)))
17901790
(is (thrown-with-msg? js/Error #"Index out of bounds" (subvec [1 2 3 4] 0 5)))
17911791
(is (= [1 2 3 4] (subvec [1 2 3 4] 0 4.9))))
1792+
1793+
(deftest test-cljs-3095
1794+
(let [a #js [:original]
1795+
v (apply vector a)]
1796+
(aset a 0 :modified)
1797+
(is (= :original (v 0)))))

0 commit comments

Comments
 (0)