Skip to content

Commit 039d4f2

Browse files
author
dnolen
committed
CLJS-1685: Incorrectly lazy subvec when start param is nil
1 parent 977284e commit 039d4f2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5516,9 +5516,10 @@ reduces them without incurring seq initialization"
55165516
the resulting vector shares structure with the original and no
55175517
trimming is done."
55185518
([v start]
5519-
(subvec v start (count v)))
5519+
(subvec v start (count v)))
55205520
([v start end]
5521-
(build-subvec nil v start end nil)))
5521+
(assert (and (not (nil? start)) (not (nil? end))))
5522+
(build-subvec nil v start end nil)))
55225523

55235524
(defn- tv-ensure-editable [edit node]
55245525
(if (identical? edit (.-edit node))

src/test/cljs/cljs/core_test.cljs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,13 @@
13201320
(is (true? (equiv-map (MapWithNoIKVReduce. {:a 1 :b 2 :c 3}) {:a 1 :b 2 :c 3})))
13211321
(is (false? (equiv-map (MapWithNoIKVReduce. {:a 1 :b 2 :c 3}) {:a 1 :b 2 :c 4})))))
13221322

1323+
(deftest test-cljs-1685
1324+
(testing "nil start or end param throws error"
1325+
(is (= :fail (try (subvec nil nil)
1326+
(catch js/Error e :fail))))
1327+
(is (= :fail (try (subvec nil 1 nil)
1328+
(catch js/Error e :fail))))))
1329+
13231330
(comment
13241331
;; ObjMap
13251332
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)