clojure.core.match 在嵌套地图上

clojure.core.match on nested map

在 clojure.core.match 中,此示例在嵌套映射中运行良好

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

但是当将 key 更改为 vector 时会引发错误。

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

[:b :c] 不是 clojure 映射中的有效键吗?或者它在 clojure.core.match 中不起作用?

[:b :c] 当然是一个有效的密钥。这是一个错误,已被报告,请参阅 opened issue

而且您似乎也无法将地图与数字作为键进行匹配:

(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')