basilisp
basilisp copied to clipboard
default vaue in map destructuring can override falsy key values
Hi,
t appears there is a bug in map destructuring where an :or
default value overrides a key in the destructured map when the key's value is falsy, such as nil
.
The expected behavior is that no destructured key should be overridden by an :or
default when the key exists, even if its value is falsy.
To reproduce,
Open up the REPL and destructure a map where a key is associated with a nil
value while providing a default value of 5
. The destructured value is incorrectly set to the default 5
instead of nil
basilisp.user=> (let [{:keys [abc]
:or {abc 5}} {:abc nil}]
abc)
5
In contast, Clojure returns nil
as expected
user=> (let [{:keys [abc]
:or {abc 5}} {:abc nil}]
abc)
nil
Thanks