Skip to content

Commit

Permalink
CLJS-435: Stack overflow error when adding large numerical keys to maps
Browse files Browse the repository at this point in the history
IHash implementation for numbers now apply modulo MAX INT on the floor
of the number.
  • Loading branch information
David Nolen authored and David Nolen committed Dec 22, 2012
1 parent 19d265d commit 61455e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cljs/cljs/core.cljs
Expand Up @@ -452,7 +452,7 @@
(-equiv [x o] (identical? x o))

IHash
(-hash [o] o))
(-hash [o] (js-mod (.floor js/Math o) 2147483647)))

(extend-type boolean
IHash
Expand Down
5 changes: 5 additions & 0 deletions test/cljs/cljs/core_test.cljs
Expand Up @@ -1778,5 +1778,10 @@
(assert (instance? js/Error (ex-info "asdf" {:foo 1})))
(assert (not (instance? cljs.core.ExceptionInfo (js/Error.))))

;; CLJS-435

(assert (= (assoc {} 154618822656 1 261993005056 1)
{154618822656 1 261993005056 1}))

:ok
)

0 comments on commit 61455e6

Please sign in to comment.