We're updating the issue view to help you get more done. 

[core.specs] ::keys spec conflicts with destructuring spec

Description

As a consequence of the destructuring specs being implemented in terms of `s/keys`, defining a spec for `::keys` or `::strs` is problematic at the moment, because it will conflict with trying to use `::keys` for destructuring:

1 2 3 4 5 6 7 8 9 10 11 user=> (require '[clojure.spec :as s]) nil user=> (s/def ::keys nil?) :user/keys user=> (let [{::keys [a]} {::a 1}] a) ExceptionInfo Call to clojure.core/let did not conform to spec: In: [0 0] val: #:user{:keys [a]} fails spec: :clojure.core.specs/local-name at: [:args :bindings :binding :sym] predicate: simple-symbol? In: [0 0 0] val: ([:user/keys [a]]) fails spec: :clojure.core.specs/seq-binding-form at: [:args :bindings :binding :seq] predicate: (cat :elems (* :clojure.core.specs/binding-form) :rest (? (cat :amp #{(quote &)} :form :clojure.core.specs/binding-form)) :as (? (cat :as #{:as} :sym :clojure.core.specs/local-name))), Extra input In: [0 0 :user/keys] val: [a] fails spec: :user/keys at: [:args :bindings :binding :map :user/keys] predicate: nil? :clojure.spec/args ([#:user{:keys [a]} #:user{:a 1}] a) clojure.core/ex-info (core.clj:4725)

This feels like an implementation detail leak.

Environment

None

Status

Assignee

Alex Miller

Reporter

Nicola Mometto

Approval

Triaged

Patch

Code

Priority

Major