Skip to content

Commit 817b44d

Browse files
author
dnolen
committed
CLJS-1721: 3-arity get-in fails on types which do not implement ILookup
1 parent db896ff commit 817b44d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,13 +4798,11 @@ reduces them without incurring seq initialization"
47984798
(loop [sentinel lookup-sentinel
47994799
m m
48004800
ks (seq ks)]
4801-
(if ks
4802-
(if (not (satisfies? ILookup m))
4803-
not-found
4804-
(let [m (get m (first ks) sentinel)]
4805-
(if (identical? sentinel m)
4806-
not-found
4807-
(recur sentinel m (next ks)))))
4801+
(if-not (nil? ks)
4802+
(let [m (get m (first ks) sentinel)]
4803+
(if (identical? sentinel m)
4804+
not-found
4805+
(recur sentinel m (next ks))))
48084806
m))))
48094807

48104808
(defn assoc-in

src/test/cljs/cljs/core_test.cljs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,12 @@
32103210
(is (zero? (hash-string nil)))
32113211
(is (not (zero? (hash-string "null")))))
32123212

3213+
(deftest test-cljs-1721
3214+
(is (= 1 (get-in {:a (array 1 2 3 4)} [:a 0] :not-found)))
3215+
(is (= :not-found (get-in {:a (array 1 2 3 4)} [:a 4] :not-found)))
3216+
(is (= "d" (get-in {:a "data"} [:a 0] :not-found)))
3217+
(is (= :not-found (get-in {:a "data"} [:a 4] :not-found))))
3218+
32133219
(comment
32143220
;; ObjMap
32153221
;; (let [ks (map (partial str "foo") (range 500))

0 commit comments

Comments
 (0)