Skip to content

Commit daf0811

Browse files
committed
fix gen override by name, use in fspec ret gen
1 parent d274b2b commit daf0811

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/clj/clojure/spec.clj

+6-5
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@
221221
(defn- gensub
222222
[spec overrides path rmap form]
223223
;;(prn {:spec spec :over overrides :path path :form form})
224-
(let [spec (c/or (get overrides spec) spec)
225-
spec (specize spec)]
226-
(if-let [g (c/or (get overrides path) (gen* spec overrides path rmap))]
224+
(let [spec (specize spec)]
225+
(if-let [g (c/or (get overrides (c/or (spec-name spec) spec))
226+
(get overrides path)
227+
(gen* spec overrides path rmap))]
227228
(gen/such-that #(valid? spec %) g 100)
228229
(let [abbr (abbrev form)]
229230
(throw (ex-info (str "Unable to construct gen at: " path " for: " abbr)
@@ -1634,12 +1635,12 @@ in ns-or-nses, a symbol or a collection of symbols."
16341635
(let [cargs (conform argspec args)]
16351636
(explain-1 fform fnspec (conj path :fn) via in {:args cargs :ret cret})))))))))
16361637
{path {:pred 'ifn? :val f :via via :in in}}))
1637-
(gen* [_ _ _ _] (if gfn
1638+
(gen* [_ overrides _ _] (if gfn
16381639
(gfn)
16391640
(gen/return
16401641
(fn [& args]
16411642
(assert (valid? argspec args) (with-out-str (explain argspec args)))
1642-
(gen/generate (gen retspec))))))
1643+
(gen/generate (gen retspec overrides))))))
16431644
(with-gen* [_ gfn] (fspec-impl argspec aform retspec rform fnspec fform gfn))
16441645
(describe* [_] `(fspec :args ~aform :ret ~rform :fn ~fform)))))
16451646

0 commit comments

Comments
 (0)