在以下线程讨论后打开了这个错误:
https://groups.google.com/forum/#!topic/clojure/r8WO24rHsi0
基本上,当使用 s/merge 与 s/or 一起使用时,s/conform 返回的结构无法进行 s/unform。
重现步骤(毫不客气地从线程中复制过来)
(require '[clojure.spec.alpha :as s])
(s/def ::a (s/or :even even? :odd odd?))
(s/def ::b (s/or :even even? :odd odd?))
(s/def ::m1 (s/keys :req-un [::a]))
(s/def ::m2 (s/keys :req-un [::b]))
(s/def ::mm (s/merge ::m1 ::m2))
(s/valid? ::mm {:a 1 :b 2}) ;; true
(s/conform ::mm {:a 1 :b 2})
;;=> {:a 1, :b [:even 2]}
(s/unform ::mm {:a [:odd 1] :b [:even 2]})
;;=> {:a 1, :b [:even 2]}
(s/unform ::mm (s/conform ::mm {:a 1 :b 2}))