Skip to content

Commit b24c036

Browse files
committed
CLJS-3352: Self-host negative zero emitted as positive zero
1 parent 90497c1 commit b24c036

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/clojure/cljs/compiler.cljc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@
335335
(not (js/isFinite x))
336336
(emits (if (pos? x) "Infinity" "-Infinity"))
337337

338+
(and (zero? x) (neg? (/ x)))
339+
(emits "(-0)")
340+
338341
:else (emits "(" x ")"))))
339342

340343
#?(:clj

src/test/cljs/cljs/primitives_test.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@
953953
(is (= 1 (gobject/get #js {:a 1} "a")))
954954
(is (= 1 (.-a #js {:a 1})))))
955955

956+
(deftest test-3352
957+
(is (== ##-Inf (/ -0.0)))
958+
(is (== ##Inf (/ -0))))
959+
956960
(deftest test-char?
957961
(is (char? "0"))
958962
(is (char? (String/fromCharCode 13)))

0 commit comments

Comments
 (0)