Welcome! Please see the About page for a little more info on how this works.

0 votes
ago in Clojure by
(def select-c (selector {{:keys [a]} :c :select s}))

(select-c {})
;; => {}

(select-c {:c nil})
;; => {:c nil}

(select-c {:c 1})
;; => {:c {}}

{} is not in the input.
The docs say :select gives "a subset of the input map".
I would expect one of these:

;; keep it: copy the value as is, like nil
(select-c {:c 1})
;; => {:c 1}

;; drop it: not a map, so not selected
(select-c {:c 1})
;; => {}

Is {:c {}} intended?

Reproduced on Clojure 1.13.0-alpha10.

1 Answer

+1 vote
ago by

Trying to destructure a non-map is undefined behavior. We don't have plans protect against this for  :select.

...