spec/valid? and spec/explain inconsistent for coll-of :kind

Description

valid? and explain-str give inconsistent results when using coll-of :kind with a registered spec.

(s/def ::vector? vector?)
=> :user/vector?
(s/def ::vector-of-maps (s/coll-of map? :kind ::vector?))
=> :user/vector-of-maps
(s/valid? ::vector-of-maps [{}])
=> false
(s/explain-str ::vector-of-maps [{}])
=> "Success!\n"

Environment

Windows XP, MacOS 10.13, JDK 1.8.0_171, Clojure 1.9.0, clojure.spec.alpha

Activity

Show:
Alex Miller
July 9, 2018, 2:24 PM

It is not valid to use a spec for :kind.

import
July 9, 2018, 2:34 PM

Comment made by: dalethatcher

Ok, the doc string doesn't match then:

coll-of refers you to "every" which has:

:kind - a pred/spec that the collection type must satisfy, e.g. vector?
(default nil) Note that if :kind is specified and :into is
not, this pred must generate in order for every to generate."

Also I noticed that the documentation for coll-of specifies:

Returns a spec for a collection of items satisfying pred.

But in this case a spec can be used.

Alex Miller
July 9, 2018, 3:03 PM

The doc was fixed in the newest release of spec.alpha (0.2.168) - see CLJ-2111.

import
July 9, 2018, 3:57 PM

Comment made by: dalethatcher

Understood, sorry to have wasted your time. I'll check the latest source next time, before raising a Jira.

Alex Miller
July 9, 2018, 4:00 PM

No worries at all! That’s what triage is all about.

Declined

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Affects versions

Priority

Major