Skip to content

Commit c4bc714

Browse files
authored
be less specific around int coercion fns (#294)
cljs.tools.reader uses `int` to coerce numeric unicode chars, with better inference of JS APIs this triggered a numeric warning. But this warning is a bit bogus in that `int` is for coercion anyway. Clojure is vague about `int` behavior, we should be equally vague.
1 parent 8757eaa commit c4bc714

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,22 +2932,22 @@ reduces them without incurring seq initialization"
29322932
(Math/ceil q)))
29332933

29342934
(defn int
2935-
"Coerce to int by stripping decimal places."
2935+
"Coerce to int."
29362936
[x]
29372937
(bit-or x 0))
29382938

29392939
(defn unchecked-int
2940-
"Coerce to int by stripping decimal places."
2940+
"Coerce to int."
29412941
[x]
29422942
(fix x))
29432943

29442944
(defn long
2945-
"Coerce to long by stripping decimal places. Identical to `int'."
2945+
"Coerce to long. Identical to `int'."
29462946
[x]
29472947
(fix x))
29482948

29492949
(defn unchecked-long
2950-
"Coerce to long by stripping decimal places. Identical to `int'."
2950+
"Coerce to long. Identical to `int'."
29512951
[x]
29522952
(fix x))
29532953

src/main/clojure/cljs/core.cljc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,9 @@
12361236
([x y] (core/list 'js* "(~{} | ~{})" x y))
12371237
([x y & more] `(bit-or (bit-or ~x ~y) ~@more)))
12381238

1239-
(core/defmacro ^::ana/numeric int [x]
1240-
`(bit-or ~x 0))
1239+
(core/defmacro int
1240+
[x]
1241+
(core/list 'js* "(~{} | 0)" x))
12411242

12421243
(core/defmacro ^::ana/numeric bit-xor
12431244
([x y] (core/list 'js* "(~{} ^ ~{})" x y))

0 commit comments

Comments
 (0)