Skip to content

Commit 6654cb2

Browse files
aspeddrocknitt
andauthored
Add throw (#7346)
* Add `throw` Deprecate `raise` and rename references * remove raise from Pervasives_mini.res * convert to external and add deprecated attr * restore tests/gentype_tests/typescript-react-example/package-lock.json * update analysis output * update CHANGELOG.md * move `throw` to Pervasives.res * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <christoph@knittel.cc> * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <christoph@knittel.cc> * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <christoph@knittel.cc> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <christoph@knittel.cc> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <christoph@knittel.cc> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <christoph@knittel.cc> * update Stdlib_Bool and Stdlib_Char * remove comment --------- Co-authored-by: Christoph Knittel <christoph@knittel.cc>
1 parent 12f2578 commit 6654cb2

31 files changed

+91
-57
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- Fix Pervasive.max using boolean comparison for floats. https://github.com/rescript-lang/rescript/pull/7333
2323
- Experimental: Support nested/inline record types - records defined inside of other records, without needing explicit separate type definitions. https://github.com/rescript-lang/rescript/pull/7241
2424
- Add unified exponentiation (`**`) operator for numeric types using ES7 `**`. https://github.com/rescript-lang/rescript-compiler/pull/7153
25+
- Rename `raise` to `throw` to align with JavaScript vocabulary. `raise` has been deprecated. https://github.com/rescript-lang/rescript/pull/7346
2526

2627
#### :boom: Breaking Change
2728

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 {

runtime/Belt_internalSetInt.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ let rec getUndefined = (n: t, x: value) =>
106106

107107
let rec getExn = (n: t, x: value) =>
108108
switch n {
109-
| None => raise(Not_found)
109+
| None => throw(Not_found)
110110
| Some(t) =>
111111
let v = t.value
112112
if x == v {

0 commit comments

Comments
 (0)