nbb
nbb copied to clipboard
Keyword argument fns don't accept map arguments
Hi @borkdude. With cljs 1.11, keyword arg fns can accept maps. This seems to work in bb but not in nbb. This is not an urgent bug but it could be nice to be at 1.11 parity at some point
version
0.5.103
platform
osx and node 16.13.1
problem
Define a fn that takes keyword args and pass it a map. See the call fail
repro
Create the following file example.cljc
:
(ns example
(:require
[clojure.test :as t :refer [deftest is]]))
(defn destr [& {:keys [a b] :as opts}]
[a b opts])
(deftest keyword-arg
(is (= [1 nil {:a 1}]
(destr :a 1)))
(is (= [1 2 {:a 1 :b 2}]
(destr {:a 1 :b 2}))))
(defn run-tests []
(t/run-tests 'example))
Run the test:
$ nbb -m example/run-tests
Testing example
ERROR in (keyword-arg) (:12:7)
expected: (= [1 2 {:a 1, :b 2}] (destr {:a 1, :b 2}))
actual: #object[Error Error: No value supplied for key: {:a 1, :b 2}]
Ran 1 tests containing 2 assertions.
0 failures, 1 errors.
Running this with bb does pass: bb -cp . -m example/run-tests
expected behavior
Expected this to pass
@logseq-cldwalker Thanks. If you want to look into this a bit before I get to it, related logic in SCI is here: https://github.com/babashka/sci/blob/bb3031eaabd0b1b30fdb9a2d5969a48dba959cc6/src/sci/impl/namespaces.cljc#L798
The full commit that made it work for SCI on Clojure 1.11: https://github.com/babashka/sci/commit/b6ab05d5e4b0d6df594a6e03a5849caf82caecb3
Fixed in 1.2.164
Thanks! Works great