diff --git a/src/spec_tools/parse.cljc b/src/spec_tools/parse.cljc index 9c253fa8..dfb7d866 100644 --- a/src/spec_tools/parse.cljc +++ b/src/spec_tools/parse.cljc @@ -193,8 +193,7 @@ ::items specs})) (defmethod parse-form 'clojure.spec.alpha/merge [_ form options] - (let [type-priority #((:type %) {:map 0 - :multi-spec 1} 0)] + (let [type-priority #(if (= (:type %) :multi-spec) 1 0)] (apply impl/deep-merge (->> (rest form) (map #(parse-spec % options)) (sort-by type-priority))))) diff --git a/test/cljc/spec_tools/core_test.cljc b/test/cljc/spec_tools/core_test.cljc index 96d27f68..b1bf46df 100644 --- a/test/cljc/spec_tools/core_test.cljc +++ b/test/cljc/spec_tools/core_test.cljc @@ -840,6 +840,20 @@ (is (st/spec? (st/merge ::qix ::qux))) (is (st/spec? (st/merge qix ::qux)))))) +(s/def ::a242 int?) +(s/def ::b242 int?) +(s/def ::c242 int?) + +(deftest issue-242 + (testing "parse-form should continue to work with [:or [:map]] specs" + (let [desired-spec (st/spec (s/merge (s/or :one (s/keys :req-un [::a242]) + :two (s/keys :req-un [::b242])) + (s/keys :req-un [::c242])))] + (is (s/valid? desired-spec {:a242 1 :c242 2})) + (is (not (s/valid? desired-spec {:c242 2}))) + (is (s/valid? desired-spec {:b242 2 :c242 3})) + (is (not (s/valid? desired-spec {:a242 1})))))) + (s/def ::rec-pattern (s/coll-of (s/or :atr qualified-keyword? :ref (s/map-of qualified-keyword? (s/or :rec-pattern ::rec-pattern)))))