Skip to content

Commit 835efe4

Browse files
committed
Add throw
Deprecate `raise` and rename references
1 parent 890ace4 commit 835efe4

35 files changed

+111
-48
lines changed

lib/es6/Stdlib.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
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+
610
function assertEqual(a, b) {
711
if (!Primitive_object.notequal(a, b)) {
812
return;
@@ -11,7 +15,7 @@ function assertEqual(a, b) {
1115
RE_EXN_ID: "Assert_failure",
1216
_1: [
1317
"Stdlib.res",
14-
117,
18+
118,
1519
4
1620
],
1721
Error: new Error()
@@ -154,6 +158,7 @@ export {
154158
$$BigInt64Array,
155159
$$BigUint64Array,
156160
panic,
161+
$$throw,
157162
assertEqual,
158163
}
159164
/* No side effect */

lib/js/Stdlib.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
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+
610
function assertEqual(a, b) {
711
if (!Primitive_object.notequal(a, b)) {
812
return;
@@ -11,7 +15,7 @@ function assertEqual(a, b) {
1115
RE_EXN_ID: "Assert_failure",
1216
_1: [
1317
"Stdlib.res",
14-
117,
18+
118,
1519
4
1620
],
1721
Error: new Error()
@@ -153,5 +157,6 @@ exports.$$Uint8ClampedArray = $$Uint8ClampedArray;
153157
exports.$$BigInt64Array = $$BigInt64Array;
154158
exports.$$BigUint64Array = $$BigUint64Array;
155159
exports.panic = panic;
160+
exports.$$throw = $$throw;
156161
exports.assertEqual = assertEqual;
157162
/* No side effect */

runtime/Belt_List.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let head = x =>
8888

8989
let headExn = x =>
9090
switch x {
91-
| list{} => raise(Not_found)
91+
| list{} => throw(Not_found)
9292
| list{x, ..._} => x
9393
}
9494

@@ -100,7 +100,7 @@ let tail = x =>
100100

101101
let tailExn = x =>
102102
switch x {
103-
| list{} => raise(Not_found)
103+
| list{} => throw(Not_found)
104104
| list{_, ...t} => t
105105
}
106106

@@ -126,7 +126,7 @@ let rec nthAuxAssert = (x, n) =>
126126
} else {
127127
nthAuxAssert(t, n - 1)
128128
}
129-
| _ => raise(Not_found)
129+
| _ => throw(Not_found)
130130
}
131131

132132
let get = (x, n) =>
@@ -138,7 +138,7 @@ let get = (x, n) =>
138138

139139
let getExn = (x, n) =>
140140
if n < 0 {
141-
raise(Not_found)
141+
throw(Not_found)
142142
} else {
143143
nthAuxAssert(x, n)
144144
}

runtime/Belt_MutableQueue.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let peekUndefined = q =>
7272

7373
let peekExn = q =>
7474
switch q.first {
75-
| None => raise(Not_found)
75+
| None => throw(Not_found)
7676
| Some(v) => v.content
7777
}
7878

@@ -95,7 +95,7 @@ let pop = q =>
9595
let popExn = q =>
9696
/* TO fix */
9797
switch q.first {
98-
| None => raise(Not_found)
98+
| None => throw(Not_found)
9999
| Some(x) =>
100100
let next = x.next
101101
if next == None {

runtime/Belt_Option.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let forEach = (opt, f) =>
3737
let getExn = x =>
3838
switch x {
3939
| Some(x) => x
40-
| None => raise(Not_found)
40+
| None => throw(Not_found)
4141
}
4242

4343
external getUnsafe: option<'a> => 'a = "%identity"

runtime/Belt_Result.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type t<'a, 'b> = result<'a, 'b> =
2929
let getExn = x =>
3030
switch x {
3131
| Ok(x) => x
32-
| Error(_) => raise(Not_found)
32+
| Error(_) => throw(Not_found)
3333
}
3434

3535
let mapWithDefault = (opt, default, f) =>

runtime/Belt_internalAVLset.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ let rec getUndefined = (n: t<_>, x, ~cmp) =>
590590

591591
let rec getExn = (n: t<_>, x, ~cmp) =>
592592
switch n {
593-
| None => raise(Not_found)
593+
| None => throw(Not_found)
594594
| Some(t) /* Node(l, v, r, _) */ =>
595595
let v = t.value
596596
let c = Belt_Id.getCmpInternal(cmp)(x, v)

runtime/Belt_internalAVLtree.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ let rec getUndefined = (n, x, ~cmp) =>
713713

714714
let rec getExn = (n, x, ~cmp) =>
715715
switch n {
716-
| None => raise(Not_found)
716+
| None => throw(Not_found)
717717
| Some(n) /* Node(l, v, d, r, _) */ =>
718718
let v = n.key
719719
let c = Belt_Id.getCmpInternal(cmp)(x, v)

runtime/Belt_internalMapInt.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let rec getUndefined = (n, x: key) =>
6565

6666
let rec getExn = (n, x: key) =>
6767
switch n {
68-
| None => raise(Not_found)
68+
| None => throw(Not_found)
6969
| Some(n) =>
7070
let v = n.N.key
7171
if x == v {

runtime/Belt_internalMapString.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ let rec getUndefined = (n, x: key) =>
6565

6666
let rec getExn = (n, x: key) =>
6767
switch n {
68-
| None => raise(Not_found)
68+
| None => throw(Not_found)
6969
| Some(n) =>
7070
let v = n.N.key
7171
if x == v {

0 commit comments

Comments
 (0)