{{:pred}}应该在解释问题如
{{s/coll-of}}和{{s/every-kv}}中解析出{{:pred}}函数,如果它们不是有效的值
(::s/problems (s/explain-data (s/coll-of (fn [x] (pos? x))) [-1]))
({:path [], :pred (fn [x] (pos? x)), :val -1, :via [], :in [0]})
应该是
(::s/problems (s/explain-data (s/coll-of (fn [x] (pos? x))) [-1]))
({:path [], :pred (clojure.core/fn [x] (clojure.core/pos? x)), :val -1, :via [], :in [0]})
其他示例
;; 同样适用于 every
(::s/problems (s/explain-data (s/every (fn [x] (pos? x))) [-1]))
({:path [], :pred (fn [x] (pos? x)), :val -1, :via [], :in [0]})
;; :distinct 选项的 pred 不被解析
(::s/problems (s/explain-data (s/coll-of pos? :distinct true) [-1 -1]))
[{:path [], :pred distinct?, :val [-1 -1], :via [], :in []}]
map-of 和 every-kv 没有这个问题。:count、:min-count、:max-count 和 :kind 选项会正确生成解析后的 :preds。
*补丁:* clj-2168.patch