diff --git a/src/sci/impl/analyzer.cljc b/src/sci/impl/analyzer.cljc index 13148810..50da1725 100644 --- a/src/sci/impl/analyzer.cljc +++ b/src/sci/impl/analyzer.cljc @@ -1698,7 +1698,14 @@ (defn map-fn [children-count] (if (<= children-count 16) - array-map hash-map)) + #?(:clj #(let [^objects arr (into-array %&)] + (clojure.lang.PersistentArrayMap/createWithCheck arr)) + :cljs #(PersistentArrayMap.createWithCheck (into-array %&)) + :default array-map) + #?(:clj #(let [^objects arr (into-array %&)] + (clojure.lang.PersistentHashMap/createWithCheck arr)) + :cljs #(PersistentHashMap.createWithCheck (into-array %&)) + :default hash-map))) (defn return-map [ctx the-map analyzed-children] (let [mf (map-fn (count analyzed-children))] diff --git a/test/sci/core_test.cljc b/test/sci/core_test.cljc index 6553321d..5303d01a 100644 --- a/test/sci/core_test.cljc +++ b/test/sci/core_test.cljc @@ -110,7 +110,8 @@ :d #{*in* (inc *in*)} :e {:a *in*}})))) (testing "duplicate keys" - (is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] #{a b})")))) + (is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] #{a b})"))) + (is (thrown-with-msg? Exception #"Duplicate key" (sci/eval-string "(let [a 1 b 1] {a 1 b 2})")))) (testing "quoting" (is (= {:a '*in*} (eval* 1 (str "'{:a *in*}")))) (is (= '#{1 2 3 *in*} (eval* 4 "'#{1 2 3 *in*}")))