clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
twashing 2021-04-29T20:37:52.114300Z

Running cljs.spec.test.alpha/instrument then cljs.spec.test.alpha/check on fns w/ a namespaced keyword is producing the error: RangeError: Maximum call stack size exceeded. This seems like a bug in Clojurescript. https://clojure.atlassian.net/browse/CLJS-3023 https://clojure.atlassian.net/browse/CLJS-2995 But maybe I’m doing something wrong? I’ve tried on these lib pairs.

org.clojure/clojure       {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.10.844"}

org.clojure/clojure       {:mvn/version "1.9.0"}
org.clojure/clojurescript {:mvn/version "1.10.339"}
a.cljs
(s/fdef github-deployment->deployment
  :args (s/cat :message (s/keys :req [::github.deployment/payload])))

(defn github-deployment->deployment [{payload ::github.deployment/payload :as message}]
  )

(cljs.spec.test.alpha/instrument)
b.cljs
(cljs.spec.test.alpha/check
  `backend.topology.processor.transform.deployment/github-deployment->deployment
  {:clojure.spec.test.check/opts {:num-tests 1}})

[{:spec #object[cljs.spec.alpha.t_cljs$spec$alpha20390], :clojure.test.check/ret {:result #object[RangeError RangeError: Maximum call stack size exceeded]}, :sym backend.topology.processor.transform.deployment/github-deployment->deployment, :failure #object[RangeError RangeError: Maximum call stack size exceeded]}]

lassemaatta 2021-05-01T09:08:19.114700Z

I doubt I can help you solve this, but I assume you've verified that the generator for ::github.deployment/payload works and produces values without encountering that call stack issue?

1✔️
twashing 2021-05-03T20:33:30.115100Z

No, that’s a great suggestion. I did check that, and I was generating the spec in question. I did find the problem though. A given namespace has to handle messages, all keyed by a :payload entry. When I put a namespace on it… and place it in a file with other specs, it turned out that there was a separate :payload somewhere in the spec tree.