Skip to content

Commit 1942e70

Browse files
author
dnolen
committed
same as Clojure 69dd29d2c8
1 parent b4f9d75 commit 1942e70

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/main/cljs/cljs/spec.cljc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
5858
Returns a spec."
5959
[form & {:keys [gen]}]
60-
`(cljs.spec/spec-impl '~(res &env form) ~form ~gen nil))
60+
(when form
61+
`(cljs.spec/spec-impl '~(res &env form) ~form ~gen nil)))
6162

6263
(defmacro multi-spec
6364
"Takes the name of a spec/predicate-returning multimethod and a
@@ -251,7 +252,9 @@
251252
that returns a test.check generator."
252253
[& {:keys [args ret fn gen]}]
253254
(let [env &env]
254-
`(cljs.spec/fspec-impl ~args '~(res env args) ~ret '~(res env ret) ~fn '~(res env fn) ~gen)))
255+
`(cljs.spec/fspec-impl (spec ~args) '~(res env args)
256+
(spec ~ret) '~(res env ret)
257+
(spec ~fn) '~(res env fn) ~gen)))
255258

256259
(defmacro tuple
257260
"takes one or more preds and returns a spec for a tuple, a vector

src/main/cljs/cljs/spec.cljs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,20 +1060,13 @@
10601060
(defn ^:skip-wiki fspec-impl
10611061
"Do not call this directly, use 'fspec'"
10621062
[argspec aform retspec rform fnspec fform gfn]
1063-
(assert (c/and argspec retspec))
10641063
(let [specs {:args argspec :ret retspec :fn fnspec}]
10651064
(reify
10661065
IFn
10671066
(-invoke [this x] (valid? this x))
10681067
ILookup
1069-
(-lookup [this k]
1070-
(-lookup this k nil))
1071-
(-lookup [_ k not-found]
1072-
(case k
1073-
:args argspec
1074-
:ret retspec
1075-
:fn fnspec
1076-
not-found))
1068+
(-lookup [this k] (get specs k))
1069+
(-lookup [_ k not-found] (get specs k not-found))
10771070
Spec
10781071
(conform* [_ f] (if (fn? f)
10791072
(if (identical? f (validate-fn f specs *fspec-iterations*)) f ::invalid)

0 commit comments

Comments
 (0)