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

0 votes
in Spec by
{{:pred}} should be resolved in explain problems like:

{{s/coll-of}} and {{s/every-kv}} should have resolved {{:pred}} functions if it's values aren't valid:


(::s/problems (s/explain-data (s/coll-of (fn [x] (pos? x))) [-1]))
({:path [], :pred (fn [x] (pos? x)), :val -1, :via [], :in [0]})


should be


(::s/problems (s/explain-data (s/coll-of (fn [x] (pos? x))) [-1]))
({:path [], :pred (clojure.core/fn [x] (clojure.core/pos? x)), :val -1, :via [], :in [0]})


Other examples:


;; same with every
(::s/problems (s/explain-data (s/every (fn [x] (pos? x))) [-1]))
({:path [], :pred (fn [x] (pos? x)), :val -1, :via [], :in [0]})

;; :distinct option pred is not resolved:
(::s/problems (s/explain-data (s/coll-of pos? :distinct true) [-1 -1]))
[{:path [], :pred distinct?, :val [-1 -1], :via [], :in []}]


map-of and every-kv do not have this issue. The :count, :min-count, :max-count, and :kind options do correctly produce resolved :preds.

*Patch:* clj-2168.patch

4 Answers

0 votes
by

Comment made by: sohta

The same problem happens with {{s/every}}.

0 votes
by
_Comment made by: sohta_

Oh, sorry. I meant {{s/every-kv}}, not {{s/every}}.

BTW, after looking into things around this, I found some other spec macros were putting inconsistent forms of {{:pred}} in their explain data.

For example,

{{(s/explain-data (s/tuple integer?) [])}} => {{(clojure.core/= (clojure.core/count %) 1)}}
{{(s/explain-data (s/& integer? even?) [])}} => #function[clojure.core/integer?] (not a symbol)

I'll file that as another ticket later.
0 votes
by

Comment made by: akiel

Issue https://github.com/alexanderkiel/phrase/issues/22 relates to this.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2168 (reported by ikitommi)
...