Skip to content

Commit

Permalink
fixing bug in find
Browse files Browse the repository at this point in the history
  • Loading branch information
dupuchba committed Sep 23, 2024
1 parent 9e368a7 commit ab6be55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clj/src/cljd/core.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -5112,8 +5112,10 @@
(not (identical? (-lookup coll k coll) coll)))
IFind
(-find [coll k]
(when-some [v (-lookup coll k nil)]
(new #/(MapEntry K V) k v)))
;; NOTE: `coll` is used as a local sentinel here
(let [v (-lookup coll k coll)]
(when-not (identical? coll v)
(new #/(MapEntry K V) k v))))
IMap
(-dissoc [coll k]
(let [new-root (.inode_without root 0 (hash k) k)]
Expand Down
3 changes: 3 additions & 0 deletions clj/test/cljd/test_clojure/core_test_cljd.cljd
Original file line number Diff line number Diff line change
Expand Up @@ -1059,3 +1059,6 @@
([result input]
(reduced {:cljd.core/halt :should-be-wrapped})))))
[1])))))

(deftest find-returns-nil-value
(is (= (find {1 nil, 2 "b"} 1) [1 nil])))

0 comments on commit ab6be55

Please sign in to comment.