Skip to content

Commit c282587

Browse files
committed
remove intenral usage of %assert
1 parent f5e9b82 commit c282587

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+275
-350
lines changed

jscomp/main/builtin_cmj_datasets.ml

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

jscomp/others/belt_List.ml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ let head x =
9292

9393
let headExn x =
9494
match x with
95-
| [] -> [%assert "headExn"]
95+
| [] -> raise Not_found
9696
| x::_ -> x
9797

9898
let tail x =
@@ -102,7 +102,7 @@ let tail x =
102102

103103
let tailExn x =
104104
match x with
105-
| [] -> [%assert "tailExn"]
105+
| [] -> raise Not_found
106106
| _::t -> t
107107

108108
let add xs x = x :: xs
@@ -116,14 +116,14 @@ let rec nthAux x n =
116116
let rec nthAuxAssert x n =
117117
match x with
118118
| h::t -> if n = 0 then h else nthAuxAssert t (n - 1)
119-
| _ -> [%assert "getExn"]
119+
| _ -> raise Not_found
120120

121121
let get x n =
122122
if n < 0 then None
123123
else nthAux x n
124124

125125
let getExn x n =
126-
if n < 0 then [%assert "getExn"]
126+
if n < 0 then raise Not_found
127127
else nthAuxAssert x n
128128

129129
let rec partitionAux p cell precX precY =
@@ -447,22 +447,7 @@ let shuffle xs =
447447
2. raise JS exception, how to pattern match
448448
*)
449449

450-
(* let fromJson j f = *)
451-
(* match J.decodeArray j with *)
452-
(* | Some arr -> *)
453-
(* let len = Belt_Array.length arr in *)
454-
(* if len = 0 then [] *)
455-
(* else *)
456-
(* let head = (mutableCell (f (A.getUnsafe arr 0) [@bs]) []) in *)
457-
(* let cell = ref head in *)
458-
(* for i = 1 to len - 1 do *)
459-
(* let next = mutableCell (f (A.getUnsafe arr i) [@bs]) [] in *)
460-
(* unsafeMutateTail.unsafeMutateTail !cell next ; *)
461-
(* cell .contents<- next *)
462-
(* done ; *)
463-
(* head *)
464-
(* | None -> *)
465-
(* [%assert "Not array when decoding list"] *)
450+
466451

467452
let rec reverseConcat l1 l2 =
468453
match l1 with

jscomp/others/belt_MutableQueue.ml

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

7272
let peekExn q =
7373
match q.first with
74-
| None -> [%assert "Belt.Queue.Empty"]
74+
| None -> raise Not_found
7575
| Some v -> v.content
7676

7777
let pop q =
@@ -92,7 +92,7 @@ let pop q =
9292

9393
let popExn q = (* TO fix *)
9494
match q.first with
95-
| None -> [%assert "Empty"]
95+
| None -> raise Not_found
9696
| Some x ->
9797
let next = x.next in
9898
if next = None then

jscomp/others/belt_Option.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let forEach opt f = forEachU opt (fun[@bs] x -> f x)
3030

3131
let getExn = function
3232
| Some x -> x
33-
| None -> [%assert "getExn"]
33+
| None -> raise Not_found
3434

3535
external getUnsafe : 'a option -> 'a = "%identity"
3636

jscomp/others/belt_Result.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ('a,'b) t = Ok of 'a | Error of 'b
2626

2727
let getExn = function
2828
| Ok x -> x
29-
| Error _ -> [%assert "getExn"]
29+
| Error _ -> raise Not_found
3030

3131
let mapWithDefaultU opt default f = match opt with
3232
| Ok x -> (f x [@bs])

jscomp/others/belt_internalAVLset.ml

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

530530
let rec getExn (n : _ t) x ~cmp =
531531
match n with
532-
None -> [%assert "getExn0"]
532+
None -> raise Not_found
533533
| Some t (* Node(l, v, r, _) *) ->
534534
let v = t.value in
535535
let c = (Belt_Id.getCmpInternal cmp) x v [@bs] in

jscomp/others/belt_internalAVLtree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ let rec getUndefined n x ~cmp =
604604
let rec getExn n x ~cmp =
605605
match n with
606606
None ->
607-
[%assert "getExn0"]
607+
raise Not_found
608608
| Some n (* Node(l, v, d, r, _)*) ->
609609
let v = n.key in
610610
let c = (Belt_Id.getCmpInternal cmp) x v [@bs] in

jscomp/others/belt_internalMapInt.ml

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

4747
let rec getExn n (x : key) =
4848
match n with
49-
| None -> [%assert "getExn"]
49+
| None -> raise Not_found
5050
| Some n ->
5151
let v = n.N.key in
5252
if x = v then n.N.value

jscomp/others/belt_internalMapString.ml

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

4747
let rec getExn n (x : key) =
4848
match n with
49-
| None -> [%assert "getExn"]
49+
| None -> raise Not_found
5050
| Some n ->
5151
let v = n.N.key in
5252
if x = v then n.N.value

jscomp/others/belt_internalSetInt.ml

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

8383
let rec getExn (n :t) (x : value) =
8484
match n with
85-
| None -> [%assert "getExn"]
85+
| None -> raise Not_found
8686
| Some t ->
8787
let v = t.value in
8888
if x = v then v

0 commit comments

Comments
 (0)