We're updating the issue view to help you get more done. 

Fail fast for s/with-gen on undefined spec

Description

Observe what happens in Clojure if you attempt to use s/with-gen on an undefined spec:

1 2 3 4 5 6 Clojure 1.10.0 user=> (require '[clojure.spec.alpha :as s]) nil user=> (s/def ::foo (s/with-gen ::bar #(s/gen #{:a}))) Syntax error (IllegalArgumentException) compiling at (REPL:1:14). No implementation of method: :specize* of protocol: #'clojure.spec.alpha/Specize found for class: nil

In ClojureScript, on the other hand, things don't fail fast, and when they fail later the error can be somewhat cryptic to developers:

1 2 3 4 5 6 7 8 9 10 11 12 13 $ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.439"}}}' -m cljs.main ClojureScript 1.10.439 cljs.user=> (require '[clojure.spec.alpha :as s]) nil cljs.user=> (s/def ::foo (s/with-gen ::bar #(s/gen #{:a}))) :cljs.user/foo cljs.user=> (s/valid? ::foo 10) TypeError: null is not an object (evaluating 'self__.pred.call') cljs$spec$alpha$Spec$conform_STAR_$arity$2 (cljs/spec/alpha.cljs:526:35) cljs.spec.alpha/conform* (cljs/spec/alpha.cljs:40:14) cljs$core$IFn$_invoke$arity$2 (cljs/spec/alpha.cljs:375:22) cljs$spec$alpha$valid_QMARK_ (cljs/spec/alpha.cljs:371:1) cljs.user=>

Environment

None

Status

Assignee

Unassigned

Reporter

Mike Fikes

Labels

Approval

None

Patch

None

Priority

Major