Comment made by: kenran
The first example works fine for me as well, but I'm having a problem mostly similar to the second one. The following code runs into a StackOverflow pretty quickly unless I set :gen-max or :max-count to a low value (e.g. 2):
`
(require '[clojure.spec.alpha :as s])
(require '[clojure.spec.gen.alpha :as gen])
(s/def ::bar string?)
(s/def ::baz (s/coll-of (s/or :s string? :b ::foo)))
(s/def ::foo
(s/spec
map?
:gen
#(s/gen
(s/keys :req [::bar ::baz]))))
(gen/generate (s/gen ::foo))
`
The s/spec (or s/with-gen, which I also tried) seem to be the problem here, because the following works well and should produce equivalent data:
`
(s/def ::bar2 string?)
(s/def ::baz2 (s/coll-of (s/or :s2 string? :b2 ::foo2)))
(s/def ::foo2 (s/keys :req [::bar2 ::baz2]))
(gen/generate (s/gen ::foo2))
`
I'm using java 10.0.2 64 bit, but a colleague can reproduce it with the latest java 8.
Am I using it incorrectly or is there a problem hidden somewhere?