clojure.core.match on nested map

166 views Asked by At

in clojure.core.match , this example works well in nested map

(match [{:a {:b :c}}]
  [{:a {:b nested-arg}}] nested-arg)

but when change the key to a vector it will raise error.

(m/match x
  {:a {[:b :c]  1}}
  :found
  )

Isn't that [:b :c] is a valid key in clojure map ? Or it just won't work in clojure.core.match ?

1

There are 1 answers

0
Martin Půda On BEST ANSWER

[:b :c] is of course a valid key. This is a bug and it was already reported, see opened issue.

And it seems you can't also match map with numbers as keys:

(match/match [{:a 4}]
             [{:a _}] :found)
         
=> :found

(match/match [{2 4}]
             [{2 _}] :found)
         
Unexpected error (ClassCastException) macroexpanding match/match at ....
class java.lang.Long cannot be cast to class clojure.lang.Named (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.Named is in unnamed module of loader 'app')