Skip to content

Commit 428618b

Browse files
committed
- fix Vector -assoc, check key type
1 parent a9a1d0c commit 428618b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12321,9 +12321,11 @@ reduces them without incurring seq initialization"
1232112321

1232212322
IAssociative
1232312323
(-assoc [coll k v]
12324-
(let [new-array (aclone array)]
12325-
(aset new-array k v)
12326-
(Vector. meta new-array nil)))
12324+
(if (number? k)
12325+
(let [new-array (aclone array)]
12326+
(aset new-array k v)
12327+
(Vector. meta new-array nil))
12328+
(throw (js/Error. "Vector's key for assoc must be a number."))))
1232712329
(-contains-key? [coll k]
1232812330
(if (integer? k)
1232912331
(and (<= 0 k) (< k (alength array)))

0 commit comments

Comments
 (0)