Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Environment:

      {:deps {org.clojure/clojurescript {:mvn/version "1.10.339"}
      org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}

      Description

      If you define a spec for a variadic function with a non-zero minimum fixed arity, it will incorrectly trigger:

      $clj -Srepro -m cljs.main
      ClojureScript 1.10.339
      cljs.user=> (require '[clojure.spec.alpha :as s] '[clojure.spec.test.alpha :as st])
      
      cljs.user=> (defn foo [x & ys])
      #'cljs.user/foo
      cljs.user=> (s/fdef foo :args (s/cat :x number? :ys (s/* number?)))
      cljs.user/foo
      cljs.user=> (st/instrument)
      [cljs.user/foo]
      cljs.user=> (foo 1)
      #error {:message "Call to #'cljs.user/foo did not conform to spec:\nval: 1 fails at: [:args] predicate: (cat :x number? :ys (* number?))\n:cljs.spec.alpha/spec  #object[cljs.spec.alpha.t_cljs$spec$alpha1377]\n:cljs.spec.alpha/value  1\n:cljs.spec.alpha/args  1\n:cljs.spec.alpha/failure  :instrument\n", :data #:cljs.spec.alpha{:problems [{:path [:args], :pred (cljs.spec.alpha/cat :x cljs.core/number? :ys (cljs.spec.alpha/* cljs.core/number?)), :val 1, :via [], :in []}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha1377], :value 1, :args 1, :failure :instrument}}
      	 cljs.core/ExceptionInfo (cljs/core.cljs:11129:11)
      	 cljs$core$IFn$_invoke$arity$3 (cljs/core.cljs:11161:5)
      	 cljs$core$IFn$_invoke$arity$2 (cljs/core.cljs:11159:16)
      	 cljs$core$ex_info (cljs/core.cljs:11156:1)
      	 G__4363__delegate (cljs/spec/test/alpha.cljs:110:40)
      	 cljs.core/apply-to (cljs/core.cljs:3845:1)
      	 cljs$core$IFn$_invoke$arity$2 (cljs/core.cljs:3890:11)
      	 cljs.core/apply (cljs/core.cljs:3883:1)
      	 G__4366__delegate (cljs/spec/test/alpha.cljs:119:38)
      	 G__4366 (cljs/spec/test/alpha.cljs:114:36)
      	 G__10206__2 (cljs/core.cljs:2006:6)
      	 G__10206 (cljs/core.cljs:1995:1)
      

      Note that with master, you get a slightly different error message in the failure:

      deps.edn
      {:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "6eedd0a08c49f7b0d4dcb30977b2fb38c90577bd"}
              org.clojure/test.check {:mvn/version "0.10.0-alpha3"}}}
      
      $ clj -Srepro -m cljs.main
      cljs.user=> (require '[clojure.spec.alpha :as s] '[clojure.spec.test.alpha :as st])
      nil
      cljs.user=> (defn foo [x & ys])
      #'cljs.user/foo
      cljs.user=> (s/fdef foo :args (s/cat :x number? :ys (s/* number?)))
      cljs.user/foo
      cljs.user=> (st/instrument)
      [cljs.user/foo]
      cljs.user=> (foo 1)
      #error {:message "Call to #'cljs.user/foo did not conform to spec.", :data #:cljs.spec.alpha{:problems [{:path [], :pred (cljs.core/fn [%] (cljs.core/or (cljs.core/nil? %) (cljs.core/sequential? %))), :val 1, :via [], :in []}], :spec #object[cljs.spec.alpha.t_cljs$spec$alpha21124], :value 1, :fn cljs.user/foo, :args 1, :failure :instrument}}
      	 cljs.core/ExceptionInfo (cljs/core.cljs:11147:11)
      	 cljs$core$IFn$_invoke$arity$3 (cljs/core.cljs:11179:5)
      	 cljs$core$IFn$_invoke$arity$2 (cljs/core.cljs:11177:16)
      	 cljs$core$ex_info (cljs/core.cljs:11174:1)
      	 G__24320__delegate (cljs/spec/test/alpha.cljs:111:40)
      	 cljs.core/apply-to (cljs/core.cljs:3848:1)
      	 cljs$core$IFn$_invoke$arity$2 (cljs/core.cljs:3893:11)
      	 cljs.core/apply (cljs/core.cljs:3886:1)
      	 G__24323__delegate (cljs/spec/test/alpha.cljs:120:38)
      	 G__24323 (cljs/spec/test/alpha.cljs:115:36)
      	 G__17846__2 (cljs/core.cljs:2010:6)
      	 G__17846 (cljs/core.cljs:1999:1)
      cljs.user=>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mfikes Mike Fikes
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: