From a32ae269365fdfdf33fc913ef13ed9fa55f2d466 Mon Sep 17 00:00:00 2001 From: Hubert Iwaniuk Date: Fri, 20 Apr 2012 12:25:01 +0200 Subject: [PATCH 1/2] CLJ-975: test reproducing issue. Only 4th case is failing. 3rd case is using also nested destructuring with :as using same symbol, but order is different than in 4th case. --- test/clojure/test_clojure/data_structures.clj | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/clojure/test_clojure/data_structures.clj b/test/clojure/test_clojure/data_structures.clj index e3ecaa9..cb299fa 100644 --- a/test/clojure/test_clojure/data_structures.clj +++ b/test/clojure/test_clojure/data_structures.clj @@ -579,6 +579,19 @@ (get-in m [] 0) m (get-in m nil 0) m))) +(deftest test-nested-map-destructuring + (let [sample-map {:a 1 :b {:a 2}} + {ao1 :a {ai1 :a} :b} sample-map + {ao2 :a {ai2 :a :as m1} :b :as m2} sample-map + {ao3 :a {ai3 :a :as m} :b :as m} sample-map + {{ai4 :a :as m} :b ao4 :a :as m} sample-map] + (are [i o] (and (= i 2) + (= o 1)) + ai1 ao1 + ai2 ao2 + ai3 ao3 + ai4 ao4))) + ;; *** Sets *** (deftest test-hash-set -- 1.7.8.4 From eab974b5c4d278fc3945c0132189e768b824c322 Mon Sep 17 00:00:00 2001 From: Hubert Iwaniuk Date: Fri, 20 Apr 2012 14:36:47 +0200 Subject: [PATCH 2/2] CLJ-975: bugfix. :as destructuring option is not colliding anymore. --- src/clj/clojure/core.clj | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 336be78..ba705e7 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -3924,10 +3924,14 @@ ret)))) pmap (fn [bvec b v] - (let [gmap (or (:as b) (gensym "map__")) + (let [gmap (gensym "map__") defaults (:or b)] (loop [ret (-> bvec (conj gmap) (conj v) - (conj gmap) (conj `(if (seq? ~gmap) (apply hash-map ~gmap) ~gmap))) + (conj gmap) (conj `(if (seq? ~gmap) (apply hash-map ~gmap) ~gmap)) + ((fn [ret] + (if (:as b) + (conj ret (:as b) gmap) + ret)))) bes (reduce1 (fn [bes entry] (reduce1 #(assoc %1 %2 ((val entry) %2)) -- 1.7.8.4