Skip to content

Commit e3326fe

Browse files
committed
remove fst and snd as essential API
1 parent f8d232f commit e3326fe

File tree

7 files changed

+534
-552
lines changed

7 files changed

+534
-552
lines changed

jscomp/main/builtin_cmi_datasets.ml

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

jscomp/main/builtin_cmj_datasets.ml

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

jscomp/runtime/bs_stdlib_mini.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ external not : bool -> bool = "%boolnot"
4141

4242
external raise : exn -> 'a = "%raise"
4343
external ignore : 'a -> unit = "%ignore"
44-
external fst : 'a * 'b -> 'a = "%field0"
45-
external snd : 'a * 'b -> 'b = "%field1"
4644
external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply"
4745
external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"
4846

jscomp/runtime/caml_option.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
let undefinedHeader = [| |]
25+
let undefinedHeader = [| |]
2626

2727
let some ( x : Obj.t) : Obj.t =
2828
if Obj.magic x = None then
2929
(let block = Obj.repr (undefinedHeader, 0) in
3030
Obj.set_tag block 256;
3131
block)
3232
else
33-
if x != Obj.repr Js.null && fst (Obj.magic x ) == Obj.repr undefinedHeader then
33+
if x != Obj.repr Js.null && match (Obj.magic x ) with (x,_) -> x == Obj.repr undefinedHeader then
3434
(
35-
let nid = snd (Obj.magic x) + 1 in
35+
let nid = match (Obj.magic x) with (_,x) -> x + 1 in
3636
let block = Obj.repr (undefinedHeader, nid) in
3737
Obj.set_tag block 256;
3838
block
@@ -60,11 +60,11 @@ let null_to_opt (type t ) ( x : t Js.null) : t option =
6060
(** The input is already of [Some] form, [x] is not None,
6161
make sure [x[0]] will not throw *)
6262
let valFromOption (x : Obj.t) : Obj.t =
63-
if x != Obj.repr Js.null && fst (Obj.magic x) == Obj.repr undefinedHeader
63+
if x != Obj.repr Js.null && match (Obj.magic x) with (x,_) -> x == Obj.repr undefinedHeader
6464
then
65-
let depth : int = snd (Obj.magic x) in
65+
(match (Obj.magic x) with (_, (depth : int)) ->
6666
if depth = 0 then Obj.magic None
67-
else Obj.magic (undefinedHeader, depth - 1)
67+
else Obj.magic (undefinedHeader, depth - 1))
6868
else Obj.magic x
6969

7070

lib/4.06.1/unstable/js_compiler.ml

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

lib/4.06.1/unstable/js_refmt_compiler.ml

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

lib/4.06.1/whole_compiler.ml

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

0 commit comments

Comments
 (0)