Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by
Opened the bug after discussion in this thread: https://groups.google.com/forum/#!topic/clojure/r8WO24rHsi0

Essentially, when using s/merge with s/or, s/conform returns a structure that cannot be s/unform'ed.

Steps to reproduce (shamelessly copied from the thread):


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

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2388 (reported by alex+import)
...