Skip to content

Commit 85b20db

Browse files
authored
Float.isNaN: use Number.isNaN instead of global isNaN (#7874)
* Float.isNaN: use Number.isNaN instead of isNaN * CHANGELOG
1 parent 6d9eedf commit 85b20db

File tree

8 files changed

+9
-8
lines changed

8 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#### :nail_care: Polish
3333

3434
- Reactivate optimization for length of array literals. https://github.com/rescript-lang/rescript/pull/7872
35+
- `Float.isNaN`: use `Number.isNaN` instead of global `isNaN`. https://github.com/rescript-lang/rescript/pull/7874
3536

3637
#### :house: Internal
3738

packages/@rescript/runtime/Stdlib_Float.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ external equal: (float, float) => bool = "%equal"
1313

1414
external compare: (float, float) => Stdlib_Ordering.t = "%compare"
1515

16-
@val external isNaN: float => bool = "isNaN"
16+
@val @scope("Number") external isNaN: float => bool = "isNaN"
1717
@val external isFinite: float => bool = "isFinite"
1818
@val external parseFloat: 'a => float = "parseFloat"
1919
// parseInt's return type is a float because it can be NaN

packages/@rescript/runtime/Stdlib_Float.resi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ external compare: (float, float) => Stdlib_Ordering.t = "%compare"
139139

140140
/**
141141
`isNaN(v)` tests if the given `v` is `NaN`.
142-
See [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN.
142+
See [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) on MDN.
143143
144144
## Examples
145145
@@ -148,7 +148,7 @@ Float.isNaN(3.0) // false
148148
Float.isNaN(Float.Constants.nan) // true
149149
```
150150
*/
151-
@val
151+
@val @scope("Number")
152152
external isNaN: float => bool = "isNaN"
153153

154154
/**

packages/@rescript/runtime/lib/es6/Stdlib_Float.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let Constants = {};
55

66
function fromString(i) {
77
let i$1 = parseFloat(i);
8-
if (isNaN(i$1)) {
8+
if (Number.isNaN(i$1)) {
99
return;
1010
} else {
1111
return i$1;

packages/@rescript/runtime/lib/es6/Stdlib_Int.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as Stdlib_Array from "./Stdlib_Array.js";
44

55
function fromString(x, radix) {
66
let maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x);
7-
if (isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
7+
if (Number.isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
88
return;
99
} else {
1010
return maybeInt | 0;

packages/@rescript/runtime/lib/js/Stdlib_Float.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let Constants = {};
55

66
function fromString(i) {
77
let i$1 = parseFloat(i);
8-
if (isNaN(i$1)) {
8+
if (Number.isNaN(i$1)) {
99
return;
1010
} else {
1111
return i$1;

packages/@rescript/runtime/lib/js/Stdlib_Int.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let Stdlib_Array = require("./Stdlib_Array.js");
44

55
function fromString(x, radix) {
66
let maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x);
7-
if (isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
7+
if (Number.isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
88
return;
99
} else {
1010
return maybeInt | 0;

tests/tests/src/core/Core_FloatTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Test.run([
105105
33
106106
],
107107
"clamp - nan"
108-
], isNaN(Stdlib_Float.clamp(4.1, 4.3, Number.NaN)), eq, true);
108+
], Number.isNaN(Stdlib_Float.clamp(4.1, 4.3, Number.NaN)), eq, true);
109109

110110
Test.run([
111111
[

0 commit comments

Comments
 (0)