Skip to content

Commit b45dff9

Browse files
swannodettefogusrichhickeypuredanger
authored
port Clojure 1.13 alpha destructuring changes (#326)
Co-authored-by: Fogus <mefogus@gmail.com> Co-authored-by: Rich Hickey <richhickey@gmail.com> Co-authored-by: Alex Miller <alex.miller@cognitect.com>
1 parent 2b4d741 commit b45dff9

4 files changed

Lines changed: 459 additions & 118 deletions

File tree

src/main/cljs/cljs/core/specs/alpha.cljc

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,38 @@
3030

3131
;; map destructuring
3232

33-
(s/def ::keys (s/coll-of ident? :kind vector?))
34-
(s/def ::syms (s/coll-of symbol? :kind vector?))
35-
(s/def ::strs (s/coll-of simple-symbol? :kind vector?))
36-
(s/def ::or (s/map-of simple-symbol? any?))
33+
(s/def ::non-binding-elements (s/cat :ampersand #{'&} ::non-binding-element (s/+ any?)))
34+
(s/def ::keys-form (s/and vector? (s/cat :bindings (s/* ident?) :nonbinding (s/? ::non-binding-elements))))
35+
(s/def ::syms-form (s/and vector? (s/cat :bindings (s/* symbol?) :nonbinding (s/? ::non-binding-elements))))
36+
(s/def ::simple-syms-form (s/and vector? (s/cat :bindings (s/* simple-symbol?) :nonbinding (s/? ::non-binding-elements))))
37+
38+
(s/def ::keys ::keys-form)
39+
(s/def ::syms ::syms-form)
40+
(s/def ::strs ::simple-syms-form)
41+
(s/def ::keys! ::keys-form)
42+
(s/def ::syms! ::syms-form)
43+
(s/def ::strs! ::simple-syms-form)
44+
(s/def ::or map?)
3745
(s/def ::as ::local-name)
46+
(s/def ::defaults ::local-name)
47+
(s/def ::select ::local-name)
48+
(s/def ::all ::local-name)
3849

3950
(s/def ::map-special-binding
40-
(s/keys :opt-un [::as ::or ::keys ::syms ::strs]))
51+
(s/keys :opt-un [::as ::or ::keys ::syms ::strs ::keys! ::syms! ::strs! ::select ::defaults ::all]))
4152

4253
(s/def ::map-binding (s/tuple ::binding-form any?))
4354

4455
(s/def ::ns-keys
4556
(s/tuple
46-
(s/and qualified-keyword? #(-> % name #{"keys" "syms"}))
47-
(s/coll-of simple-symbol? :kind vector?)))
57+
(s/and qualified-keyword? #(-> % name #{"keys" "syms" "keys!" "syms!"}))
58+
::simple-syms-form))
4859

4960
(s/def ::map-bindings
5061
(s/every (s/or :map-binding ::map-binding
5162
:qualified-keys-or-syms ::ns-keys
52-
:special-binding (s/tuple #{:as :or :keys :syms :strs} any?)) :kind map?))
63+
:special-binding (s/tuple #{:as :or :keys :syms :strs :keys! :syms! :strs! :select :defaults :all} any?))
64+
:kind map?))
5365

5466
(s/def ::map-binding-form (s/merge ::map-bindings ::map-special-binding))
5567

0 commit comments

Comments
 (0)