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

+1 vote
in Spec by
Namespaced :keys destructuring (see CLJ-1919) supports any kind of ident in a `::foo/keys` or `::foo/syms`, but the core spec says only `simple-symbol?` is allowed.

Example:


user=> (let [{::keys [:foo]} {::foo 1}] foo)
Syntax error macroexpanding clojure.core/let at (REPL:1:1).
...bunch of spec problems


Expected:


user=> (let [{::keys [:foo]} {::foo 1}] foo)
1


*Proposed:* Widen spec for this case from `simple-symbol?` to `ident?` (which the code supports).
*Patch:* clj-2473.patch

3 Answers

0 votes
by
_Comment made by: thheller_

{{ident?}} accepts namespaced keywords (and symbols) which probably should not be allowed given that the current implementation will ignore the namespace and use the namespace used by "keys" instead. To avoid confusion the spec should, in my opinion, be restricted to {{simple-keyword?}} or {{simple-symbol?}} in the namespaced "keys" case and only accept {{ident?}} for non-namespaced {{:keys}}.


(let [{:foo/keys [:other/bar]} {}])
(let [{:foo/keys [other/bar]} {}])
0 votes
by

Comment made by: alexmiller

I considered that and decided to match the code. There is also consistency with :keys.

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