Skip to content

Commit 8625f7f

Browse files
committed
* can infer distinct?
- test case * remove some more ^boolean * FIXME comments about dubious ^boolean cases
1 parent 41fc128 commit 8625f7f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ reduces them without incurring seq initialization"
23552355
"Returns true if n is a JavaScript number with no decimal part."
23562356
[n]
23572357
(and (number? n)
2358-
(not ^boolean (js/isNaN n))
2358+
(not (js/isNaN n))
23592359
(not (identical? n js/Infinity))
23602360
(== (js/parseFloat n) (js/parseInt n 10))))
23612361

@@ -2462,12 +2462,12 @@ reduces them without incurring seq initialization"
24622462
(contains? coll k))
24632463
(MapEntry. k (get coll k) nil))))
24642464

2465-
(defn ^boolean distinct?
2465+
(defn distinct?
24662466
"Returns true if no two of the arguments are ="
24672467
([x] true)
24682468
([x y] (not (= x y)))
24692469
([x y & more]
2470-
(if (not (= x y))
2470+
(if (not (= x y))
24712471
(loop [s #{x y} xs more]
24722472
(let [x (first xs)
24732473
etc (next xs)]
@@ -8351,6 +8351,7 @@ reduces them without incurring seq initialization"
83518351
(if (identical? node root)
83528352
nil
83538353
(set! root node))
8354+
;; FIXME: can we figure out something better here?
83548355
(if ^boolean (.-val added-leaf?)
83558356
(set! count (inc count)))
83568357
tcoll))
@@ -8372,6 +8373,7 @@ reduces them without incurring seq initialization"
83728373
(if (identical? node root)
83738374
nil
83748375
(set! root node))
8376+
;; FIXME: can we figure out something better here?
83758377
(if ^boolean (.-val removed-leaf?)
83768378
(set! count (dec count)))
83778379
tcoll)))
@@ -10562,6 +10564,7 @@ reduces them without incurring seq initialization"
1056210564
(pr-writer (meta obj) writer opts)
1056310565
(-write writer " "))
1056410566
(cond
10567+
;; FIXME: can we figure out something better here?
1056510568
;; handle CLJS ctors
1056610569
^boolean (.-cljs$lang$type obj)
1056710570
(.cljs$lang$ctorPrWriter obj obj writer opts)
@@ -10576,7 +10579,7 @@ reduces them without incurring seq initialization"
1057610579
(number? obj)
1057710580
(-write writer
1057810581
(cond
10579-
^boolean (js/isNaN obj) "##NaN"
10582+
(js/isNaN obj) "##NaN"
1058010583
(identical? obj js/Number.POSITIVE_INFINITY) "##Inf"
1058110584
(identical? obj js/Number.NEGATIVE_INFINITY) "##-Inf"
1058210585
:else (str_ obj)))

src/test/clojure/cljs/type_inference_tests.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@
307307
(is (= (env/with-compiler-env test-cenv
308308
(:tag (analyze test-env '(dissoc {:foo :bar} :foo))))
309309
'#{clj clj-nil}))
310+
(is (= (env/with-compiler-env test-cenv
311+
(:tag (analyze test-env '(distinct? 1))))
312+
'boolean))
313+
;; TODO: we can't infer isa?, we get 'any which is a bit surprising
314+
;(is (= (env/with-compiler-env test-cenv
315+
; (:tag (analyze test-env '(isa? ::foo :bar))))
316+
; 'boolean))
310317
;; has changed, why does this return #{clj any} ?
311318
;(is (= (env/with-compiler-env test-cenv
312319
; (:tag (analyze test-env '(assoc nil :foo :bar))))

0 commit comments

Comments
 (0)