Skip to content

Commit 9b4fcfc

Browse files
thomasmulvaneyswannodette
authored andcommitted
CLJS-2012: Find on PHM with nil entry always returns nil entry
1 parent bb56fb4 commit 9b4fcfc

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7412,8 +7412,9 @@ reduces them without incurring seq initialization"
74127412

74137413
IFind
74147414
(-find [coll k]
7415-
(if has-nil?
7416-
[nil nil-val]
7415+
(if (nil? k)
7416+
(when has-nil?
7417+
[nil nil-val])
74177418
(.inode-find root 0 (hash k) k nil)))
74187419

74197420
IMap

src/test/cljs/cljs/collections_test.cljs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,15 @@
640640
(is (= v v'))
641641
(is (= metadata (meta k'))))
642642
(let [map (hash-map nil :foo)]
643-
(is (= (find map nil) [nil :foo]))))
643+
(is (= (find map nil) [nil :foo])))
644+
(let [metadata {:a 1}
645+
k [1 2 3]
646+
v 1
647+
map (hash-map (with-meta k metadata) v nil 2)
648+
[k' v'] (find map k)]
649+
(is (= k k'))
650+
(is (= v v'))
651+
(is (= metadata (meta k')))))
644652
(testing "PersistentTreeMap"
645653
(let [metadata {:a 1}
646654
k [1 2 3]

0 commit comments

Comments
 (0)