GithubHelp home page GithubHelp logo

Comments (2)

Biserkov avatar Biserkov commented on June 6, 2024

To answer my own question: wrapping the s/or in an st/spec seems to work?

(s/def ::d (st/spec (s/merge (st/spec (s/or :one (s/keys :req-un [::a])
                                            :two (s/keys :req-un [::b])))
                             (s/keys :req-un [::c]))))

from spec-tools.

wandersoncferreira avatar wandersoncferreira commented on June 6, 2024

Hello @Biserkov , the problem is the following: there is a bug introduced with multi-spec support after version 0.10.0 at the parse-form function. Your spec is decomposed by parse-form which yields :type [:or [:map]]to the inner most portion of your spec.

When we look at the parse-form, we find (current-version):

(defmethod parse-form 'clojure.spec.alpha/merge [_ form]
  (let [type-priority #((:type %) {:map 0
                                   :multi-spec 1} 0)]
    (apply impl/deep-merge (->> (rest form)
                                (map parse-spec)
                                (sort-by type-priority)))))

The ArityException is thrown by this operation:

 #([:or [:map]] {:map 0
                 :multi-spec 1} 0)
 ;; => Wrong number of args (2) passed to: clojure.lang.PersistentVector

The same code in version 0.10.0 looks like this:

(defmethod parse-form 'clojure.spec.alpha/merge [_ form]
  (apply impl/deep-merge (map parse-spec (rest form))))

Does not contain the portion to sort by priority, thus no error. I opened a PR to change the type-priority function to be more defensive.

from spec-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.