Skip to content

Commit 54a06c9

Browse files
committed
convert to external and add deprecated attr
1 parent 0061043 commit 54a06c9

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

lib/es6/Stdlib.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
import * as Stdlib_Error from "./Stdlib_Error.js";
44
import * as Primitive_object from "./Primitive_object.js";
55

6-
function $$throw(prim) {
7-
throw prim;
8-
}
9-
106
function assertEqual(a, b) {
117
if (!Primitive_object.notequal(a, b)) {
128
return;
@@ -15,7 +11,7 @@ function assertEqual(a, b) {
1511
RE_EXN_ID: "Assert_failure",
1612
_1: [
1713
"Stdlib.res",
18-
118,
14+
134,
1915
4
2016
],
2117
Error: new Error()
@@ -158,7 +154,6 @@ export {
158154
$$BigInt64Array,
159155
$$BigUint64Array,
160156
panic,
161-
$$throw,
162157
assertEqual,
163158
}
164159
/* No side effect */

lib/js/Stdlib.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
let Stdlib_Error = require("./Stdlib_Error.js");
44
let Primitive_object = require("./Primitive_object.js");
55

6-
function $$throw(prim) {
7-
throw prim;
8-
}
9-
106
function assertEqual(a, b) {
117
if (!Primitive_object.notequal(a, b)) {
128
return;
@@ -15,7 +11,7 @@ function assertEqual(a, b) {
1511
RE_EXN_ID: "Assert_failure",
1612
_1: [
1713
"Stdlib.res",
18-
118,
14+
134,
1915
4
2016
],
2117
Error: new Error()
@@ -157,6 +153,5 @@ exports.$$Uint8ClampedArray = $$Uint8ClampedArray;
157153
exports.$$BigInt64Array = $$BigInt64Array;
158154
exports.$$BigUint64Array = $$BigUint64Array;
159155
exports.panic = panic;
160-
exports.$$throw = $$throw;
161156
exports.assertEqual = assertEqual;
162157
/* No side effect */

runtime/Pervasives.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ external /* Internal */
1212
__unsafe_cast: 'a => 'b = "%identity"
1313

1414
/* Exceptions */
15-
15+
@deprecated(
16+
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw`"
17+
)
1618
external raise: exn => 'a = "%raise"
1719

1820
@deprecated("Use custom exception instead")

runtime/Stdlib.res

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,23 @@ async function main() {
100100
external import: 'a => promise<'a> = "%import"
101101

102102
let panic = Error.panic
103-
let throw = Error.throw
103+
104+
/**
105+
Throw and exception which will stop execution.
106+
107+
## Examples
108+
109+
```rescript
110+
let error = Error.make("Everything is upside down.")
111+
112+
if 5 > 10 {
113+
error->throw
114+
} else {
115+
Console.log("Phew, sanity still rules.")
116+
}
117+
```
118+
*/
119+
external throw: Error.t => 'a = "%raise"
104120

105121
/**
106122
`assertEqual(a, b)` check if `a` is equal `b`. If not raise a panic exception

runtime/Stdlib_Error.resi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ if 5 > 10 {
155155
}
156156
```
157157
*/
158-
@deprecated("Use `Error.throw` instead.")
158+
@deprecated(
159+
"`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw`"
160+
)
159161
external raise: t => 'a = "%raise"
160162

161163
/**

0 commit comments

Comments
 (0)