In specs alpha 2, if we define a clojure.alpha.spec/select
of a spec defined as a s/schema
of a nested spec that is itself a s/schema
, but of unnamespaced keys, and try to use it with either s/valid?
or s/exercise
, we get exceptions:
s/valid
throws *"No implementation of method: :conform of protocol: #'clojure.alpha.spec.protocols/Spec found for class: clojure.lang.Keyword" and s/exercise
throws "Unable to resolve spec: :foo"** (where :foo
is the unnamespaced key).
An example can illustrate the issue better:
; Context
(s/def ::foo int?)
(s/def ::inner (s/schema [{:foo ::foo}]))
(s/def ::outer (s/schema [::inner]))
; Works as expected:
(s/exercise ::outer)
(s/exercise (s/select ::inner [*]))
(s/valid? (s/select ::inner [*]) {:foo 10})
; Fails with "Unable to resolve spec: :foo"
(s/exercise (s/select ::outer [*]))
; Fails with "No implementation of method: :conform* of protocol: #'clojure.alpha.spec.protocols/Spec found for class: clojure.lang.Keyword"
(s/valid? (s/select ::outer [*]) {::inner {:foo 10}})