Fork me on GitHub
#clojure-spec
<
2017-09-09
>
samedhi23:09:00

I have the following

;; This ::post does not work, recursion limit
;; (spec/def ::post (spec/keys :req [::post-content ::user-id ::posts]))

;; This ::post does work, never seems to recurse though...
(spec/def ::post (spec/keys :req [::post-content ::user-id]
                            :opt [::posts]))

(spec/def ::posts
  (spec/with-gen
    (spec/map-of ::post-id ::post)
    #(spec/gen (spec/map-of ::post-id ::post :min-count 0 :max-count 1))))
which defines a spec recursively; ::post refers to ::posts .However, if I remove :opt [::posts] and add ::posts to the :req field’s ::post, I get a Maximum call stack size exceeded. Is this the expected behavior?