metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.51k stars 212 forks source link

Generator generation diverges #359

Closed nilern closed 3 months ago

nilern commented 3 years ago

While I was trying to describe Malli forms with Malli I noticed that recursive generator generation can diverge:

(mg/generator
  [:schema {:registry {::schema [:or
                                 [:= :int] [:= :string]
                                 [:cat [:= :and] [:* [:schema [:ref ::schema]]]]
                                 [:cat [:= :or] [:* [:schema [:ref ::schema]]]]
                                 [:tuple [:= :vector] [:ref ::schema]]]}}
   ::schema])
; Execution error (OutOfMemoryError) at malli.generator/-create (generator.cljc:219).
; GC overhead limit exceeded

Perhaps malli.generator should use clojure.test.check.generators/recursive-gen instead of the current ad hoc recursion depth limiting? I don't really get the current limits, so can't really say whether they can be made to work for all schemas.

ikitommi commented 3 years ago

There is such a thing? Please.

frenchy64 commented 4 months ago

Generation now uses recursive-gen via https://github.com/metosin/malli/issues/452

ikitommi commented 3 months ago

yes, this works now.