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

0 votes
in Spec by

(s/def ::thing (s/cat :a (s/? string?) :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))

(s/conform ::seq-of (list "foo" 1 "bar" 2 3 "qux" 4))
;=> [{:a "foo", :b [1]} [{:a "bar", :b [2 3]} {:a "qux", :b [4]}]]

;EXPECTED
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]

;; ONLY 2nd thing matters?
(s/conform ::seq-of (list "foo" 1 2 "bar" 3))
;=> [{:a "foo", :b [1 2]} {:a "bar", :b [2]}]

;; NO OPTIONAL
(s/def ::thing (s/cat :a string? :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of (list "foo" 1 "bar" 2 3 "qux" 4))
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]


This also only shows up if there are 2+ numbers in the 2nd or later ::thing
AND the problem goes away if I make :a not optional...

Could be related to http://dev.clojure.org/jira/browse/CLJ-2003 ?

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2105 (reported by alex+import)
...