diff options
author | Rich Hickey <richhickey@gmail.com> | 2010-04-05 11:02:09 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2010-04-05 11:02:09 -0400 |
commit | e6e39d5931fbdf3dfa68cd2d059b8e26ce45c965 (patch) | |
tree | 9dadb9dd9c327fe52ad8d9a33d4d5f5c58cf0007 /src/clj | |
parent | ba6cc3bde1a1ea9801b2133748a45f1277166368 (diff) |
catch duplicate map keys for literals and hash- and array-map calls. Fixes #87
Diffstat (limited to 'src/clj')
-rw-r--r-- | src/clj/clojure/core.clj | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index b4d4a31e..b5909407 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -283,7 +283,7 @@ Returns a new hash map with supplied mappings." ([] {}) ([& keyvals] - (. clojure.lang.PersistentHashMap (create keyvals)))) + (. clojure.lang.PersistentHashMap (createWithCheck keyvals)))) (defn hash-set "Returns a new hash set with supplied keys." @@ -2971,7 +2971,7 @@ (defn array-map "Constructs an array-map." ([] (. clojure.lang.PersistentArrayMap EMPTY)) - ([& keyvals] (new clojure.lang.PersistentArrayMap (to-array keyvals)))) + ([& keyvals] (clojure.lang.PersistentArrayMap/createWithCheck (to-array keyvals)))) (defn nthnext "Returns the nth next of coll, (seq coll) when n is 0." @@ -2984,7 +2984,7 @@ ;redefine let and loop with destructuring (defn destructure [bindings] - (let [bmap (apply array-map bindings) + (let [bents (partition 2 bindings) pb (fn pb [bvec b v] (let [pvec (fn [bvec b val] @@ -3035,10 +3035,10 @@ (vector? b) (pvec bvec b v) (map? b) (pmap bvec b v) :else (throw (new Exception (str "Unsupported binding form: " b)))))) - process-entry (fn [bvec b] (pb bvec (key b) (val b)))] - (if (every? symbol? (keys bmap)) + process-entry (fn [bvec b] (pb bvec (first b) (second b)))] + (if (every? symbol? (map first bents)) bindings - (reduce process-entry [] bmap)))) + (reduce process-entry [] bents)))) (defmacro let "Evaluates the exprs in a lexical context in which the symbols in |