Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CLJS-768: Fix assoc!-ing non-numeric keys into TransientVector.

  • Loading branch information...
commit 8419d8aeb6d2e975029fc693f96137775d2442c6 1 parent 90cf724
@favila favila authored swannodette committed
Showing with 10 additions and 2 deletions.
  1. +4 −1 src/cljs/cljs/core.cljs
  2. +6 −1 test/cljs/cljs/core_test.cljs
View
5 src/cljs/cljs/core.cljs
@@ -3773,7 +3773,10 @@ reduces them without incurring seq initialization"
(throw (js/Error. "persistent! called twice"))))
ITransientAssociative
- (-assoc! [tcoll key val] (-assoc-n! tcoll key val))
+ (-assoc! [tcoll key val]
+ (if (number? key)
+ (-assoc-n! tcoll key val)
+ (throw (js/Error. "TransientVector's key for assoc! must be a number."))))
ITransientVector
(-assoc-n! [tcoll n val]
View
7 test/cljs/cljs/core_test.cljs
@@ -2076,7 +2076,6 @@
(assert (= (-> (transient {}) (assoc! :a 1 :b 2) persistent!) {:a 1 :b 2}))
(assert (= (-> (transient {:a 1 :b 2 :c 3}) (dissoc! :a :b) persistent!) {:c 3}))
-
;; CLJS-767
(doseq [n [nil "-1" "" "0" "1" false true (js-obj)]]
@@ -2087,5 +2086,11 @@
(assert (= :fail (try (assoc (range 1 3) n 4)
(catch js/Error e :fail)))))
+ ;; CLJS-768
+
+ (doseq [n [nil "-1" "" "0" "1" false true (js-obj)]]
+ (assert (= :fail (try (assoc! (transient [1 2]) n 4)
+ (catch js/Error e :fail)))))
+
:ok
)
Please sign in to comment.
Something went wrong with that request. Please try again.