diff --git a/CHANGES.md b/CHANGES.md index 179e25f..4faf3ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ ## 0.13.1-SNAPSHOT * Remove any? in com.rpl.specter.impl to avoid conflict with Clojure 1.9 +* Bug fix: Fix regression from 0.13.0 where [ALL FIRST] on a PersistentArrayMap that created duplicate keys would create an invalid PersistentArrayMap ## 0.13.0 diff --git a/src/clj/com/rpl/specter/navs.cljc b/src/clj/com/rpl/specter/navs.cljc index a613ed5..a5ce306 100644 --- a/src/clj/com/rpl/specter/navs.cljc +++ b/src/clj/com/rpl/specter/navs.cljc @@ -108,7 +108,7 @@ (aset array i newk) (aset array (inc i) newv) (recur (+ i 2))))) - (clojure.lang.PersistentArrayMap. array)))) + (clojure.lang.PersistentArrayMap/createAsIfByAssoc array)))) #?(:cljs cljs.core/PersistentArrayMap) diff --git a/test/com/rpl/specter/core_test.cljc b/test/com/rpl/specter/core_test.cljc index 1486a9a..2e23cc5 100644 --- a/test/com/rpl/specter/core_test.cljc +++ b/test/com/rpl/specter/core_test.cljc @@ -1297,3 +1297,8 @@ (is (= s/NONE (afn :c :a))) (is (= data (afn :b :a))) (is (= data (afn :b :b))))) + +(deftest duplicate-map-keys-test + (let [res (setval [s/ALL s/FIRST] "a" {:a 1 :b 2})] + (is (= {"a" 2} res)) + (is (= 1 (count res)))))