Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
Observe what happens in Clojure if you attempt to use {{s/with-gen}} on an undefined spec:


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:


$ 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=>

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-3029 (reported by mfikes)
...