Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Commit cdc037d

Browse files
tobiasrichhickey
authored andcommitted
Restore {:as x} destructuring for empty lists [CLJ-1140]
Signed-off-by: Rich Hickey <[email protected]>
1 parent cd01820 commit cdc037d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/clj/clojure/core.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3991,7 +3991,7 @@
39913991
gmapseq (with-meta gmap {:tag 'clojure.lang.ISeq})
39923992
defaults (:or b)]
39933993
(loop [ret (-> bvec (conj gmap) (conj v)
3994-
(conj gmap) (conj `(if (seq? ~gmap) (clojure.lang.PersistentHashMap/create ~gmapseq) ~gmap))
3994+
(conj gmap) (conj `(if (seq? ~gmap) (clojure.lang.PersistentHashMap/create (seq ~gmapseq)) ~gmap))
39953995
((fn [ret]
39963996
(if (:as b)
39973997
(conj ret (:as b) gmap)

test/clojure/test_clojure/special.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@
2727
bar (fn [& options] (apply foo :x :b options))]
2828
(is (= (bar) :b))
2929
(is (= (bar :x :a) :a))))
30+
31+
(deftest empty-list-with-:as-destructuring
32+
(let [{:as x} '()]
33+
(is (= {} x))))

0 commit comments

Comments
 (0)