Skip to content

Commit 1247e83

Browse files
authored
Fix some primitives usage (#7114)
1 parent 47870d0 commit 1247e83

File tree

7 files changed

+30
-6
lines changed

7 files changed

+30
-6
lines changed

lib/es6/Error.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11

22

3+
import * as Primitive_option from "./Primitive_option.js";
4+
5+
function fromException(exn) {
6+
if (exn.TAG === "Ok") {
7+
return;
8+
} else {
9+
return Primitive_option.some(exn._0);
10+
}
11+
}
312

413
let $$EvalError = {};
514

@@ -18,6 +27,7 @@ function panic(msg) {
1827
}
1928

2029
export {
30+
fromException,
2131
$$EvalError,
2232
$$RangeError,
2333
$$ReferenceError,

lib/js/Error.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
'use strict';
22

3+
let Primitive_option = require("./Primitive_option.js");
4+
5+
function fromException(exn) {
6+
if (exn.TAG === "Ok") {
7+
return;
8+
} else {
9+
return Primitive_option.some(exn._0);
10+
}
11+
}
312

413
let $$EvalError = {};
514

@@ -17,6 +26,7 @@ function panic(msg) {
1726
throw new Error("Panic! " + msg);
1827
}
1928

29+
exports.fromException = fromException;
2030
exports.$$EvalError = $$EvalError;
2131
exports.$$RangeError = $$RangeError;
2232
exports.$$ReferenceError = $$ReferenceError;

runtime/Error.res

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
type t = Js.Exn.t
22

3-
external fromException: exn => option<t> = "?as_js_exn"
3+
let fromException: exn => option<t> = exn =>
4+
switch Obj.magic(exn) {
5+
| Error(t) => Some(t)
6+
| _ => None
7+
}
48
external toException: t => exn = "%identity"
59

610
@get external stack: t => option<string> = "stack"

runtime/Error.resi

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
77
/** Represents a JavaScript exception. */
88
type t = Js.Exn.t
99

10-
external fromException: exn => option<t> = "?as_js_exn"
10+
let fromException: exn => option<t>
1111

1212
/**
1313
Turns an `Error.t` into an `exn`.

runtime/Float.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let fromString = i =>
4545
external toInt: float => int = "%intoffloat"
4646
external fromInt: int => float = "%identity"
4747

48-
@unboxed @noalloc external mod: (float, float) => float = "?fmod_float"
48+
external mod: (float, float) => float = "%modfloat"
4949

5050
let clamp = (~min=?, ~max=?, value): float => {
5151
let value = switch max {

runtime/Float.resi

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ external fromInt: int => float = "%identity"
440440
Float.mod(7.0, 4.0) == 3.0
441441
```
442442
*/
443-
external mod: (float, float) => float = "?fmod_float"
443+
external mod: (float, float) => float = "%modfloat"
444444

445445
/**
446446
`clamp(~min=?, ~max=?, value)` returns `value`, optionally bounded by `min` and `max`.

runtime/Pervasives.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ external floor: float => float = "floor"
166166
external abs_float: float => float = "abs"
167167

168168
@deprecated("Use Core instead. This will be removed in v13")
169-
external mod_float: float => float = "%modfloat"
169+
external mod_float: (float, float) => float = "%modfloat"
170170

171171
@deprecated("Use Core instead. This will be removed in v13")
172172
external float: int => float = "%floatofint"
@@ -549,7 +549,7 @@ async function main() {
549549
}
550550
```
551551
*/
552-
external import: 'a => promise<'a> = "#import"
552+
external import: 'a => promise<'a> = "%import"
553553

554554
type null<+'a> = Js.null<'a>
555555

0 commit comments

Comments
 (0)