diff --git a/Changes.md b/Changes.md index 8c724204ff..310d9fd0e8 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,9 @@ Unreleased ([#1040](https://github.com/melange-re/melange/pull/1040)) - runtime: add some bindings to `Js.Bigint` ([#1044](https://github.com/melange-re/melange/pull/1044)) +- core: emit `throw new Error(..)` rather than throwing a JS object with the + Melange exception payload + ([#1036](https://github.com/melange-re/melange/pull/1036)) 3.0.0 2024-01-28 --------------- diff --git a/jscomp/core/j.mli b/jscomp/core/j.mli index 7acfb5680a..9274429f7b 100644 --- a/jscomp/core/j.mli +++ b/jscomp/core/j.mli @@ -142,7 +142,7 @@ and expression_desc = (* A string is UTF-8 encoded, the string may contain escape sequences. The first argument is used to mark it is non-pure, please - don't optimize it, since it does have side effec, + don't optimize it, since it does have side effects, examples like "use asm;" and our compiler may generate "error;..." which is better to leave it alone The last argument is passed from as `j` from `{j||j}` diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 58153629eb..db263d0602 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -130,8 +130,11 @@ let throw_indent = String.length L.throw / Js_pp.indent_length let semi cxt = string cxt L.semi let comma cxt = string cxt L.comma +let new_error name cause = + E.new_ (E.js_global Js_dump_lit.error) [ name; cause ] + let exn_block_as_obj ~(stack : bool) (el : J.expression list) (ext : J.tag_info) - : J.expression_desc = + : J.expression = let field_name = match ext with | Blk_extension -> ( @@ -140,11 +143,32 @@ let exn_block_as_obj ~(stack : bool) (el : J.expression list) (ext : J.tag_info) fun i -> match i with 0 -> L.exception_id | i -> ss.(i - 1)) | _ -> assert false in - Object - (if stack then - List.mapi ~f:(fun i e -> (Js_op.Lit (field_name i), e)) el - @ [ (Js_op.Lit "Error", E.new_ (E.js_global "Error") []) ] - else List.mapi ~f:(fun i e -> (Js_op.Lit (field_name i), e)) el) + let cause = + { + J.expression_desc = + Object (List.mapi ~f:(fun i e -> (Js_op.Lit (field_name i), e)) el); + comment = None; + loc = None; + } + in + if stack then + new_error (List.hd el) + { + J.expression_desc = Object [ (Lit Js_dump_lit.cause, cause) ]; + comment = None; + loc = None; + } + else cause + +let exn_ref_as_obj e : J.expression = + let cause = { J.expression_desc = e; comment = None; loc = None } in + new_error + (E.record_access cause Js_dump_lit.exception_id 0l) + { + J.expression_desc = Object [ (Lit Js_dump_lit.cause, cause) ]; + comment = None; + loc = None; + } let rec iter_lst cxt ls element inter = match ls with @@ -785,7 +809,7 @@ and expression_desc cxt ~(level : int) x : cxt = ]) | _ -> assert false) | Caml_block (el, _, _, ((Blk_extension | Blk_record_ext _) as ext)) -> - expression_desc cxt ~level (exn_block_as_obj ~stack:false el ext) + expression cxt ~level (exn_block_as_obj ~stack:false el ext) | Caml_block (el, _, tag, Blk_record_inlined p) -> let objs = let tails = @@ -809,9 +833,7 @@ and expression_desc cxt ~(level : int) x : cxt = let tails = List.mapi ~f:(fun i e -> - ( Js_op.Lit - (Js_exp_make.variant_pos ~constr:p.name (Int32.of_int i)), - e )) + (Js_op.Lit (E.variant_pos ~constr:p.name (Int32.of_int i)), e)) el @ if !Js_config.debug && not_is_cons then @@ -1218,8 +1240,13 @@ and statement_desc top cxt (s : J.statement_desc) : cxt = let e = match e.expression_desc with | Caml_block (el, _, _, ((Blk_extension | Blk_record_ext _) as ext)) -> - { e with expression_desc = exn_block_as_obj ~stack:true el ext } - | _ -> e + { + e with + expression_desc = + (exn_block_as_obj ~stack:true el ext).expression_desc; + } + | exp -> + { e with expression_desc = (exn_ref_as_obj exp).expression_desc } in string cxt L.throw; space cxt; diff --git a/jscomp/core/js_dump_lit.ml b/jscomp/core/js_dump_lit.ml index e9685ada57..85ea269e3e 100644 --- a/jscomp/core/js_dump_lit.ml +++ b/jscomp/core/js_dump_lit.ml @@ -80,6 +80,8 @@ let minus_minus = "--" (** debug symbols *) let case = "case" +let cause = "cause" +let error = "Error" let exception_id = "MEL_EXN_ID" let polyvar_hash = "NAME" let polyvar_value = "VAL" diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index cd8ca59c39..358051b26b 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -350,7 +350,7 @@ let poly_var_value_access (e : t) = match l with _ :: v :: _ -> v | _ -> assert false) | _ -> make_expression (Static_index (e, Js_dump_lit.polyvar_value, Some 1l)) -let extension_access (e : t) name (pos : int32) : t = +let extension_access (e : t) ?name (pos : int32) : t = match e.expression_desc with | Array (l, _) (* Float i -- should not appear here *) | Caml_block (l, _, _, _) diff --git a/jscomp/core/js_exp_make.mli b/jscomp/core/js_exp_make.mli index 31611b725c..9d903bf6ef 100644 --- a/jscomp/core/js_exp_make.mli +++ b/jscomp/core/js_exp_make.mli @@ -155,7 +155,7 @@ val inline_record_access : t -> string -> Int32.t -> t val variant_pos : constr:string -> int32 -> string val variant_access : t -> int32 -> t val cons_access : t -> int32 -> t -val extension_access : t -> string option -> Int32.t -> t +val extension_access : t -> ?name:string -> Int32.t -> t val record_assign : t -> int32 -> string -> t -> t val poly_var_tag_access : t -> t val poly_var_value_access : t -> t diff --git a/jscomp/core/js_of_lam_block.ml b/jscomp/core/js_of_lam_block.ml index b04730a4a5..e03dcc8c60 100644 --- a/jscomp/core/js_of_lam_block.ml +++ b/jscomp/core/js_of_lam_block.ml @@ -48,8 +48,8 @@ let field (field_info : Lam_compat.field_dbg_info) e (i : int32) = e i | Fld_poly_var_content -> E.poly_var_value_access e | Fld_poly_var_tag -> E.poly_var_tag_access e - | Fld_record_extension { name } -> E.extension_access e (Some name) i - | Fld_extension -> E.extension_access e None i + | Fld_record_extension { name } -> E.extension_access e ~name i + | Fld_extension -> E.extension_access e i | Fld_variant -> E.variant_access e i | Fld_cons -> E.cons_access e i | Fld_record_inline { name } -> E.inline_record_access e name i diff --git a/jscomp/core/lam_convert.cppo.ml b/jscomp/core/lam_convert.cppo.ml index d8aed3d2df..6d84d43ce2 100644 --- a/jscomp/core/lam_convert.cppo.ml +++ b/jscomp/core/lam_convert.cppo.ml @@ -24,14 +24,17 @@ open Import -let caml_id_field_info : Lambda.field_dbg_info = - Fld_record { name = Js_dump_lit.exception_id; mutable_flag = Immutable } - -let lam_caml_id : Lam_primitive.t = Pfield (0, caml_id_field_info) let prim = Lam.prim -let lam_extension_id loc (head : Lam.t) = - prim ~primitive:lam_caml_id ~args:[ head ] loc +let lam_extension_id = + let lam_caml_id : Lam_primitive.t = + let caml_id_field_info : Lambda.field_dbg_info = + Fld_record { name = Js_dump_lit.exception_id; mutable_flag = Immutable } + in + Pfield (0, caml_id_field_info) + in + fun loc (head : Lam.t) -> + prim ~primitive:lam_caml_id ~args:[ head ] loc let lazy_block_info : Lam.Tag_info.t = let lazy_done = "LAZY_DONE" and lazy_val = "VAL" in diff --git a/jscomp/runtime/caml_format.ml b/jscomp/runtime/caml_format.ml index 6d902535b9..f709e25eb9 100644 --- a/jscomp/runtime/caml_format.ml +++ b/jscomp/runtime/caml_format.ml @@ -616,7 +616,7 @@ let float_of_string : string -> exn -> float = return Infinity; if (/^-inf(inity)?$/i.test(s)) return -Infinity; - throw exn; + throw new Error(exn.MEL_EXN_ID, { cause: exn }); } |}] diff --git a/jscomp/runtime/caml_js_exceptions.ml b/jscomp/runtime/caml_js_exceptions.ml index e46ea78452..3693e336b1 100644 --- a/jscomp/runtime/caml_js_exceptions.ml +++ b/jscomp/runtime/caml_js_exceptions.ml @@ -1,6 +1,7 @@ open Melange_mini_stdlib type t = Any : 'a -> t [@@unboxed] +type js_error = { cause : exn } exception Error of t @@ -9,7 +10,10 @@ exception Error of t [Error] is defined here *) let internalToOCamlException (e : Obj.t) = - if Caml_exceptions.caml_is_extension e then (Obj.magic e : exn) + if + (not (Js_internal.testAny e)) + && Caml_exceptions.caml_is_extension (Obj.magic e : js_error).cause + then (Obj.magic e : js_error).cause else Error (Any e) let caml_as_js_exn exn = match exn with Error t -> Some t | _ -> None diff --git a/jscomp/runtime/caml_lexer.ml b/jscomp/runtime/caml_lexer.ml index 949223b834..06000d6428 100644 --- a/jscomp/runtime/caml_lexer.ml +++ b/jscomp/runtime/caml_lexer.ml @@ -159,7 +159,7 @@ let caml_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = if (state < 0) { lexbuf.lex_curr_pos = lexbuf.lex_last_pos; if (lexbuf.lex_last_action == -1) - throw exn + throw new Error(exn.MEL_EXN_ID, { cause: exn }) else return lexbuf.lex_last_action; } @@ -305,7 +305,7 @@ let caml_new_lex_engine_aux : lex_tables -> int -> lexbuf -> exn -> int = if (state < 0) { lexbuf.lex_curr_pos = lexbuf.lex_last_pos; if (lexbuf.lex_last_action == -1) - throw exn; + throw new Error(exn.MEL_EXN_ID, { cause: exn }) else return lexbuf.lex_last_action; } diff --git a/jscomp/test/dist/jscomp/test/406_primitive_test.js b/jscomp/test/dist/jscomp/test/406_primitive_test.js index 6a78c9e7c5..33075caabe 100644 --- a/jscomp/test/dist/jscomp/test/406_primitive_test.js +++ b/jscomp/test/dist/jscomp/test/406_primitive_test.js @@ -32,11 +32,12 @@ function f(param) { try { for(var i = 0; i <= 200; ++i){ if (i === 10) { - throw { - MEL_EXN_ID: A, - _1: 0, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A, + _1: 0 + } + }); } } @@ -47,7 +48,9 @@ function f(param) { if (exn.MEL_EXN_ID === A) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/adt_optimize_test.js b/jscomp/test/dist/jscomp/test/adt_optimize_test.js index 1bd3635451..50c11f1c70 100644 --- a/jscomp/test/dist/jscomp/test/adt_optimize_test.js +++ b/jscomp/test/dist/jscomp/test/adt_optimize_test.js @@ -159,15 +159,16 @@ function f11(x) { if (x.TAG === /* D */0) { return 1; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/adt_optimize_test.ml", - 191, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/adt_optimize_test.ml", + 191, + 9 + ] + } + }); } exports.f = f; diff --git a/jscomp/test/dist/jscomp/test/app_root_finder.js b/jscomp/test/dist/jscomp/test/app_root_finder.js index e2a8a25b9e..9f2d475f47 100644 --- a/jscomp/test/dist/jscomp/test/app_root_finder.js +++ b/jscomp/test/dist/jscomp/test/app_root_finder.js @@ -15,10 +15,11 @@ function find_package_json(_dir) { } var new_dir = Path.dirname(dir); if (new_dir === dir) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } _dir = new_dir; continue ; diff --git a/jscomp/test/dist/jscomp/test/argv_test.js b/jscomp/test/dist/jscomp/test/argv_test.js index 5760d8453c..b7a4223d47 100644 --- a/jscomp/test/dist/jscomp/test/argv_test.js +++ b/jscomp/test/dist/jscomp/test/argv_test.js @@ -50,27 +50,29 @@ Stdlib__Arg.parse_argv(undefined, [ ], arg_spec, anno_fun, usage_msg); if (compile.contents !== true) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/argv_test.ml", - 20, - 0 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/argv_test.ml", + 20, + 0 + ] + } + }); } if (test.contents !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/argv_test.ml", - 21, - 0 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/argv_test.ml", + 21, + 0 + ] + } + }); } exports.anno_fun = anno_fun; diff --git a/jscomp/test/dist/jscomp/test/arith_parser.js b/jscomp/test/dist/jscomp/test/arith_parser.js index 3b78ada359..7ac52de29f 100644 --- a/jscomp/test/dist/jscomp/test/arith_parser.js +++ b/jscomp/test/dist/jscomp/test/arith_parser.js @@ -45,11 +45,12 @@ var yynames_block = "NUMERAL\0IDENT\0"; var yyact = [ (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "parser", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "parser" + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -115,11 +116,12 @@ var yyact = [ return Stdlib__Parsing.peek_val(__caml_parser_env, 1); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }) ]; diff --git a/jscomp/test/dist/jscomp/test/arity_infer.js b/jscomp/test/dist/jscomp/test/arity_infer.js index 42a29a1d51..b516d29a54 100644 --- a/jscomp/test/dist/jscomp/test/arity_infer.js +++ b/jscomp/test/dist/jscomp/test/arity_infer.js @@ -11,19 +11,21 @@ function f0(x) { return x + 1 | 0; }); } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return tmp(3); } function f1(x) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); return Curry._1(undefined, x); } @@ -51,10 +53,11 @@ function f3(x) { }); break; default: - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return tmp(3); } diff --git a/jscomp/test/dist/jscomp/test/array_safe_get.js b/jscomp/test/dist/jscomp/test/array_safe_get.js index e54806b761..1be243b74d 100644 --- a/jscomp/test/dist/jscomp/test/array_safe_get.js +++ b/jscomp/test/dist/jscomp/test/array_safe_get.js @@ -21,7 +21,9 @@ catch (raw_exn){ console.log(exn._1); y = 0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/array_test.js b/jscomp/test/dist/jscomp/test/array_test.js index 8f39b41094..e23d859f10 100644 --- a/jscomp/test/dist/jscomp/test/array_test.js +++ b/jscomp/test/dist/jscomp/test/array_test.js @@ -21,10 +21,11 @@ function starts_with(xs, prefix, p) { try { for(var i = 0; i < len2; ++i){ if (!Curry._2(p, Caml_array.get(xs, i), Caml_array.get(prefix, i))) { - throw { - MEL_EXN_ID: H, - Error: new Error() - }; + throw new Error(H, { + cause: { + MEL_EXN_ID: H + } + }); } } @@ -35,7 +36,9 @@ function starts_with(xs, prefix, p) { if (exn.MEL_EXN_ID === H) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/ast_abstract_test.js b/jscomp/test/dist/jscomp/test/ast_abstract_test.js index 4276a61e24..9677aee644 100644 --- a/jscomp/test/dist/jscomp/test/ast_abstract_test.js +++ b/jscomp/test/dist/jscomp/test/ast_abstract_test.js @@ -111,15 +111,16 @@ function bToJs(param) { function bFromJs(param) { if (!(param <= 3 && 0 <= param)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 0, - -1 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 0, + -1 + ] + } + }); } return param - 0 | 0; } @@ -142,15 +143,16 @@ function cToJs(param) { function cFromJs(param) { if (!(param <= 6 && 3 <= param)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 0, - -1 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 0, + -1 + ] + } + }); } return param - 3 | 0; } @@ -173,15 +175,16 @@ function hToJs(param) { function hFromJs(param) { if (!(param <= 1 && 0 <= param)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 0, - -1 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 0, + -1 + ] + } + }); } return param - 0 | 0; } diff --git a/jscomp/test/dist/jscomp/test/ast_mapper_defensive_test.js b/jscomp/test/dist/jscomp/test/ast_mapper_defensive_test.js index 74c0364d57..2358b75ea3 100644 --- a/jscomp/test/dist/jscomp/test/ast_mapper_defensive_test.js +++ b/jscomp/test/dist/jscomp/test/ast_mapper_defensive_test.js @@ -34,15 +34,16 @@ function aToJs(param) { function aFromJs(param) { if (!(param <= 2 && 0 <= param)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "_none_", - 0, - -1 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "_none_", + 0, + -1 + ] + } + }); } return param - 0 | 0; } diff --git a/jscomp/test/dist/jscomp/test/bb.js b/jscomp/test/dist/jscomp/test/bb.js index b03e5bc94f..2b35bc51e6 100644 --- a/jscomp/test/dist/jscomp/test/bb.js +++ b/jscomp/test/dist/jscomp/test/bb.js @@ -21,15 +21,16 @@ function ff(x) { case "c" : return "c"; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bb.ml", - 17, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bb.ml", + 17, + 9 + ] + } + }); } } @@ -46,15 +47,16 @@ function test(x) { match = "c"; break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bb.ml", - 26, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bb.ml", + 26, + 13 + ] + } + }); } if (match === "b") { return "b"; diff --git a/jscomp/test/dist/jscomp/test/bdd.js b/jscomp/test/dist/jscomp/test/bdd.js index c83c9f4f8b..dd4c277a7a 100644 --- a/jscomp/test/dist/jscomp/test/bdd.js +++ b/jscomp/test/dist/jscomp/test/bdd.js @@ -66,15 +66,16 @@ function resize(newSize) { } var n = bucket.hd; if (typeof n === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bdd.ml", - 54, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bdd.ml", + 54, + 27 + ] + } + }); } var ind = hashVal(getId(n._0), getId(n._3), n._1) & newSz_1; Caml_array.set(newArr, ind, { @@ -130,15 +131,16 @@ function mkNode(low, v, high) { if (b) { var n = b.hd; if (typeof n === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bdd.ml", - 99, - 31 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bdd.ml", + 99, + 31 + ] + } + }); } if (v === n._1 && idl === getId(n._0) && idh === getId(n._3)) { return n; @@ -374,15 +376,16 @@ function main(param) { if (succeeded) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bdd.ml", - 233, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bdd.ml", + 233, + 2 + ] + } + }); } main(undefined); diff --git a/jscomp/test/dist/jscomp/test/bench.js b/jscomp/test/dist/jscomp/test/bench.js index 330a1f1741..3867376f5a 100644 --- a/jscomp/test/dist/jscomp/test/bench.js +++ b/jscomp/test/dist/jscomp/test/bench.js @@ -24,11 +24,12 @@ function init(l, f) { return []; } if (l < 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.init", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.init" + } + }); } var res = Caml_array.make(l, f$1(0)); for(var i = 1; i < l; ++i){ diff --git a/jscomp/test/dist/jscomp/test/big_polyvar_test.js b/jscomp/test/dist/jscomp/test/big_polyvar_test.js index e46ea9e679..ec4d83e079 100644 --- a/jscomp/test/dist/jscomp/test/big_polyvar_test.js +++ b/jscomp/test/dist/jscomp/test/big_polyvar_test.js @@ -25,3615 +25,3916 @@ function eq(x, y) { } if (!eq(tFromJs("variant0"), "variant0")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 610, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 610, + 2 + ] + } + }); } if (!eq(tFromJs("variant1"), "variant1")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 611, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 611, + 2 + ] + } + }); } if (!eq(tFromJs("variant2"), "variant2")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 612, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 612, + 2 + ] + } + }); } if (!eq(tFromJs("variant3"), "variant3")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 613, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 613, + 2 + ] + } + }); } if (!eq(tFromJs("variant4"), "variant4")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 614, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 614, + 2 + ] + } + }); } if (!eq(tFromJs("variant5"), "variant5")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 615, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 615, + 2 + ] + } + }); } if (!eq(tFromJs("variant6"), "variant6")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 616, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 616, + 2 + ] + } + }); } if (!eq(tFromJs("variant7"), "variant7")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 617, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 617, + 2 + ] + } + }); } if (!eq(tFromJs("variant8"), "variant8")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 618, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 618, + 2 + ] + } + }); } if (!eq(tFromJs("variant9"), "variant9")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 619, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 619, + 2 + ] + } + }); } if (!eq(tFromJs("variant10"), "variant10")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 620, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 620, + 2 + ] + } + }); } if (!eq(tFromJs("variant11"), "variant11")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 621, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 621, + 2 + ] + } + }); } if (!eq(tFromJs("variant12"), "variant12")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 622, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 622, + 2 + ] + } + }); } if (!eq(tFromJs("variant13"), "variant13")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 623, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 623, + 2 + ] + } + }); } if (!eq(tFromJs("variant14"), "variant14")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 624, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 624, + 2 + ] + } + }); } if (!eq(tFromJs("variant15"), "variant15")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 625, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 625, + 2 + ] + } + }); } if (!eq(tFromJs("variant16"), "variant16")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 626, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 626, + 2 + ] + } + }); } if (!eq(tFromJs("variant17"), "variant17")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 627, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 627, + 2 + ] + } + }); } if (!eq(tFromJs("variant18"), "variant18")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 628, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 628, + 2 + ] + } + }); } if (!eq(tFromJs("variant19"), "variant19")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 629, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 629, + 2 + ] + } + }); } if (!eq(tFromJs("variant20"), "variant20")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 630, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 630, + 2 + ] + } + }); } if (!eq(tFromJs("variant21"), "variant21")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 631, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 631, + 2 + ] + } + }); } if (!eq(tFromJs("variant22"), "variant22")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 632, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 632, + 2 + ] + } + }); } if (!eq(tFromJs("variant23"), "variant23")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 633, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 633, + 2 + ] + } + }); } if (!eq(tFromJs("variant24"), "variant24")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 634, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 634, + 2 + ] + } + }); } if (!eq(tFromJs("variant25"), "variant25")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 635, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 635, + 2 + ] + } + }); } if (!eq(tFromJs("variant26"), "variant26")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 636, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 636, + 2 + ] + } + }); } if (!eq(tFromJs("variant27"), "variant27")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 637, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 637, + 2 + ] + } + }); } if (!eq(tFromJs("variant28"), "variant28")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 638, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 638, + 2 + ] + } + }); } if (!eq(tFromJs("variant29"), "variant29")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 639, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 639, + 2 + ] + } + }); } if (!eq(tFromJs("variant30"), "variant30")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 640, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 640, + 2 + ] + } + }); } if (!eq(tFromJs("variant31"), "variant31")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 641, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 641, + 2 + ] + } + }); } if (!eq(tFromJs("variant32"), "variant32")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 642, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 642, + 2 + ] + } + }); } if (!eq(tFromJs("variant33"), "variant33")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 643, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 643, + 2 + ] + } + }); } if (!eq(tFromJs("variant34"), "variant34")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 644, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 644, + 2 + ] + } + }); } if (!eq(tFromJs("variant35"), "variant35")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 645, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 645, + 2 + ] + } + }); } if (!eq(tFromJs("variant36"), "variant36")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 646, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 646, + 2 + ] + } + }); } if (!eq(tFromJs("variant37"), "variant37")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 647, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 647, + 2 + ] + } + }); } if (!eq(tFromJs("variant38"), "variant38")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 648, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 648, + 2 + ] + } + }); } if (!eq(tFromJs("variant39"), "variant39")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 649, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 649, + 2 + ] + } + }); } if (!eq(tFromJs("variant40"), "variant40")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 650, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 650, + 2 + ] + } + }); } if (!eq(tFromJs("variant41"), "variant41")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 651, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 651, + 2 + ] + } + }); } if (!eq(tFromJs("variant42"), "variant42")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 652, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 652, + 2 + ] + } + }); } if (!eq(tFromJs("variant43"), "variant43")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 653, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 653, + 2 + ] + } + }); } if (!eq(tFromJs("variant44"), "variant44")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 654, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 654, + 2 + ] + } + }); } if (!eq(tFromJs("variant45"), "variant45")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 655, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 655, + 2 + ] + } + }); } if (!eq(tFromJs("variant46"), "variant46")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 656, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 656, + 2 + ] + } + }); } if (!eq(tFromJs("variant47"), "variant47")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 657, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 657, + 2 + ] + } + }); } if (!eq(tFromJs("variant48"), "variant48")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 658, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 658, + 2 + ] + } + }); } if (!eq(tFromJs("variant49"), "variant49")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 659, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 659, + 2 + ] + } + }); } if (!eq(tFromJs("variant50"), "variant50")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 660, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 660, + 2 + ] + } + }); } if (!eq(tFromJs("variant51"), "variant51")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 661, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 661, + 2 + ] + } + }); } if (!eq(tFromJs("variant52"), "variant52")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 662, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 662, + 2 + ] + } + }); } if (!eq(tFromJs("variant53"), "variant53")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 663, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 663, + 2 + ] + } + }); } if (!eq(tFromJs("variant54"), "variant54")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 664, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 664, + 2 + ] + } + }); } if (!eq(tFromJs("variant55"), "variant55")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 665, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 665, + 2 + ] + } + }); } if (!eq(tFromJs("variant56"), "variant56")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 666, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 666, + 2 + ] + } + }); } if (!eq(tFromJs("variant57"), "variant57")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 667, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 667, + 2 + ] + } + }); } if (!eq(tFromJs("variant58"), "variant58")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 668, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 668, + 2 + ] + } + }); } if (!eq(tFromJs("variant59"), "variant59")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 669, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 669, + 2 + ] + } + }); } if (!eq(tFromJs("variant60"), "variant60")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 670, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 670, + 2 + ] + } + }); } if (!eq(tFromJs("variant61"), "variant61")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 671, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 671, + 2 + ] + } + }); } if (!eq(tFromJs("variant62"), "variant62")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 672, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 672, + 2 + ] + } + }); } if (!eq(tFromJs("variant63"), "variant63")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 673, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 673, + 2 + ] + } + }); } if (!eq(tFromJs("variant64"), "variant64")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 674, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 674, + 2 + ] + } + }); } if (!eq(tFromJs("variant65"), "variant65")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 675, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 675, + 2 + ] + } + }); } if (!eq(tFromJs("variant66"), "variant66")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 676, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 676, + 2 + ] + } + }); } if (!eq(tFromJs("variant67"), "variant67")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 677, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 677, + 2 + ] + } + }); } if (!eq(tFromJs("variant68"), "variant68")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 678, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 678, + 2 + ] + } + }); } if (!eq(tFromJs("variant69"), "variant69")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 679, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 679, + 2 + ] + } + }); } if (!eq(tFromJs("variant70"), "variant70")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 680, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 680, + 2 + ] + } + }); } if (!eq(tFromJs("variant71"), "variant71")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 681, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 681, + 2 + ] + } + }); } if (!eq(tFromJs("variant72"), "variant72")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 682, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 682, + 2 + ] + } + }); } if (!eq(tFromJs("variant73"), "variant73")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 683, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 683, + 2 + ] + } + }); } if (!eq(tFromJs("variant74"), "variant74")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 684, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 684, + 2 + ] + } + }); } if (!eq(tFromJs("variant75"), "variant75")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 685, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 685, + 2 + ] + } + }); } if (!eq(tFromJs("variant76"), "variant76")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 686, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 686, + 2 + ] + } + }); } if (!eq(tFromJs("variant77"), "variant77")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 687, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 687, + 2 + ] + } + }); } if (!eq(tFromJs("variant78"), "variant78")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 688, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 688, + 2 + ] + } + }); } if (!eq(tFromJs("variant79"), "variant79")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 689, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 689, + 2 + ] + } + }); } if (!eq(tFromJs("variant80"), "variant80")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 690, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 690, + 2 + ] + } + }); } if (!eq(tFromJs("variant81"), "variant81")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 691, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 691, + 2 + ] + } + }); } if (!eq(tFromJs("variant82"), "variant82")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 692, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 692, + 2 + ] + } + }); } if (!eq(tFromJs("variant83"), "variant83")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 693, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 693, + 2 + ] + } + }); } if (!eq(tFromJs("variant84"), "variant84")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 694, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 694, + 2 + ] + } + }); } if (!eq(tFromJs("variant85"), "variant85")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 695, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 695, + 2 + ] + } + }); } if (!eq(tFromJs("variant86"), "variant86")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 696, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 696, + 2 + ] + } + }); } if (!eq(tFromJs("variant87"), "variant87")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 697, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 697, + 2 + ] + } + }); } if (!eq(tFromJs("variant88"), "variant88")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 698, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 698, + 2 + ] + } + }); } if (!eq(tFromJs("variant89"), "variant89")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 699, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 699, + 2 + ] + } + }); } if (!eq(tFromJs("variant90"), "variant90")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 700, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 700, + 2 + ] + } + }); } if (!eq(tFromJs("variant91"), "variant91")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 701, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 701, + 2 + ] + } + }); } if (!eq(tFromJs("variant92"), "variant92")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 702, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 702, + 2 + ] + } + }); } if (!eq(tFromJs("variant93"), "variant93")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 703, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 703, + 2 + ] + } + }); } if (!eq(tFromJs("variant94"), "variant94")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 704, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 704, + 2 + ] + } + }); } if (!eq(tFromJs("variant95"), "variant95")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 705, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 705, + 2 + ] + } + }); } if (!eq(tFromJs("variant96"), "variant96")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 706, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 706, + 2 + ] + } + }); } if (!eq(tFromJs("variant97"), "variant97")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 707, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 707, + 2 + ] + } + }); } if (!eq(tFromJs("variant98"), "variant98")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 708, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 708, + 2 + ] + } + }); } if (!eq(tFromJs("variant99"), "variant99")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 709, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 709, + 2 + ] + } + }); } if (!eq(tFromJs("variant100"), "variant100")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 710, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 710, + 2 + ] + } + }); } if (!eq(tFromJs("variant101"), "variant101")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 711, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 711, + 2 + ] + } + }); } if (!eq(tFromJs("variant102"), "variant102")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 712, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 712, + 2 + ] + } + }); } if (!eq(tFromJs("variant103"), "variant103")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 713, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 713, + 2 + ] + } + }); } if (!eq(tFromJs("variant104"), "variant104")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 714, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 714, + 2 + ] + } + }); } if (!eq(tFromJs("variant105"), "variant105")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 715, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 715, + 2 + ] + } + }); } if (!eq(tFromJs("variant106"), "variant106")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 716, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 716, + 2 + ] + } + }); } if (!eq(tFromJs("variant107"), "variant107")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 717, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 717, + 2 + ] + } + }); } if (!eq(tFromJs("variant108"), "variant108")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 718, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 718, + 2 + ] + } + }); } if (!eq(tFromJs("variant109"), "variant109")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 719, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 719, + 2 + ] + } + }); } if (!eq(tFromJs("variant110"), "variant110")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 720, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 720, + 2 + ] + } + }); } if (!eq(tFromJs("variant111"), "variant111")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 721, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 721, + 2 + ] + } + }); } if (!eq(tFromJs("variant112"), "variant112")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 722, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 722, + 2 + ] + } + }); } if (!eq(tFromJs("variant113"), "variant113")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 723, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 723, + 2 + ] + } + }); } if (!eq(tFromJs("variant114"), "variant114")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 724, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 724, + 2 + ] + } + }); } if (!eq(tFromJs("variant115"), "variant115")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 725, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 725, + 2 + ] + } + }); } if (!eq(tFromJs("variant116"), "variant116")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 726, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 726, + 2 + ] + } + }); } if (!eq(tFromJs("variant117"), "variant117")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 727, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 727, + 2 + ] + } + }); } if (!eq(tFromJs("variant118"), "variant118")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 728, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 728, + 2 + ] + } + }); } if (!eq(tFromJs("variant119"), "variant119")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 729, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 729, + 2 + ] + } + }); } if (!eq(tFromJs("variant120"), "variant120")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 730, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 730, + 2 + ] + } + }); } if (!eq(tFromJs("variant121"), "variant121")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 731, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 731, + 2 + ] + } + }); } if (!eq(tFromJs("variant122"), "variant122")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 732, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 732, + 2 + ] + } + }); } if (!eq(tFromJs("variant123"), "variant123")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 733, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 733, + 2 + ] + } + }); } if (!eq(tFromJs("variant124"), "variant124")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 734, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 734, + 2 + ] + } + }); } if (!eq(tFromJs("variant125"), "variant125")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 735, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 735, + 2 + ] + } + }); } if (!eq(tFromJs("variant126"), "variant126")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 736, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 736, + 2 + ] + } + }); } if (!eq(tFromJs("variant127"), "variant127")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 737, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 737, + 2 + ] + } + }); } if (!eq(tFromJs("variant128"), "variant128")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 738, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 738, + 2 + ] + } + }); } if (!eq(tFromJs("variant129"), "variant129")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 739, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 739, + 2 + ] + } + }); } if (!eq(tFromJs("variant130"), "variant130")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 740, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 740, + 2 + ] + } + }); } if (!eq(tFromJs("variant131"), "variant131")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 741, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 741, + 2 + ] + } + }); } if (!eq(tFromJs("variant132"), "variant132")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 742, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 742, + 2 + ] + } + }); } if (!eq(tFromJs("variant133"), "variant133")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 743, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 743, + 2 + ] + } + }); } if (!eq(tFromJs("variant134"), "variant134")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 744, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 744, + 2 + ] + } + }); } if (!eq(tFromJs("variant135"), "variant135")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 745, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 745, + 2 + ] + } + }); } if (!eq(tFromJs("variant136"), "variant136")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 746, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 746, + 2 + ] + } + }); } if (!eq(tFromJs("variant137"), "variant137")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 747, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 747, + 2 + ] + } + }); } if (!eq(tFromJs("variant138"), "variant138")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 748, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 748, + 2 + ] + } + }); } if (!eq(tFromJs("variant139"), "variant139")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 749, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 749, + 2 + ] + } + }); } if (!eq(tFromJs("variant140"), "variant140")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 750, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 750, + 2 + ] + } + }); } if (!eq(tFromJs("variant141"), "variant141")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 751, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 751, + 2 + ] + } + }); } if (!eq(tFromJs("variant142"), "variant142")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 752, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 752, + 2 + ] + } + }); } if (!eq(tFromJs("variant143"), "variant143")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 753, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 753, + 2 + ] + } + }); } if (!eq(tFromJs("variant144"), "variant144")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 754, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 754, + 2 + ] + } + }); } if (!eq(tFromJs("variant145"), "variant145")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 755, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 755, + 2 + ] + } + }); } if (!eq(tFromJs("variant146"), "variant146")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 756, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 756, + 2 + ] + } + }); } if (!eq(tFromJs("variant147"), "variant147")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 757, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 757, + 2 + ] + } + }); } if (!eq(tFromJs("variant148"), "variant148")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 758, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 758, + 2 + ] + } + }); } if (!eq(tFromJs("variant149"), "variant149")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 759, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 759, + 2 + ] + } + }); } if (!eq(tFromJs("variant150"), "variant150")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 760, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 760, + 2 + ] + } + }); } if (!eq(tFromJs("variant151"), "variant151")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 761, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 761, + 2 + ] + } + }); } if (!eq(tFromJs("variant152"), "variant152")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 762, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 762, + 2 + ] + } + }); } if (!eq(tFromJs("variant153"), "variant153")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 763, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 763, + 2 + ] + } + }); } if (!eq(tFromJs("variant154"), "variant154")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 764, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 764, + 2 + ] + } + }); } if (!eq(tFromJs("variant155"), "variant155")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 765, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 765, + 2 + ] + } + }); } if (!eq(tFromJs("variant156"), "variant156")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 766, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 766, + 2 + ] + } + }); } if (!eq(tFromJs("variant157"), "variant157")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 767, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 767, + 2 + ] + } + }); } if (!eq(tFromJs("variant158"), "variant158")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 768, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 768, + 2 + ] + } + }); } if (!eq(tFromJs("variant159"), "variant159")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 769, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 769, + 2 + ] + } + }); } if (!eq(tFromJs("variant160"), "variant160")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 770, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 770, + 2 + ] + } + }); } if (!eq(tFromJs("variant161"), "variant161")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 771, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 771, + 2 + ] + } + }); } if (!eq(tFromJs("variant162"), "variant162")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 772, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 772, + 2 + ] + } + }); } if (!eq(tFromJs("variant163"), "variant163")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 773, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 773, + 2 + ] + } + }); } if (!eq(tFromJs("variant164"), "variant164")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 774, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 774, + 2 + ] + } + }); } if (!eq(tFromJs("variant165"), "variant165")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 775, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 775, + 2 + ] + } + }); } if (!eq(tFromJs("variant166"), "variant166")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 776, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 776, + 2 + ] + } + }); } if (!eq(tFromJs("variant167"), "variant167")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 777, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 777, + 2 + ] + } + }); } if (!eq(tFromJs("variant168"), "variant168")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 778, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 778, + 2 + ] + } + }); } if (!eq(tFromJs("variant169"), "variant169")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 779, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 779, + 2 + ] + } + }); } if (!eq(tFromJs("variant170"), "variant170")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 780, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 780, + 2 + ] + } + }); } if (!eq(tFromJs("variant171"), "variant171")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 781, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 781, + 2 + ] + } + }); } if (!eq(tFromJs("variant172"), "variant172")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 782, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 782, + 2 + ] + } + }); } if (!eq(tFromJs("variant173"), "variant173")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 783, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 783, + 2 + ] + } + }); } if (!eq(tFromJs("variant174"), "variant174")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 784, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 784, + 2 + ] + } + }); } if (!eq(tFromJs("variant175"), "variant175")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 785, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 785, + 2 + ] + } + }); } if (!eq(tFromJs("variant176"), "variant176")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 786, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 786, + 2 + ] + } + }); } if (!eq(tFromJs("variant177"), "variant177")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 787, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 787, + 2 + ] + } + }); } if (!eq(tFromJs("variant178"), "variant178")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 788, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 788, + 2 + ] + } + }); } if (!eq(tFromJs("variant179"), "variant179")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 789, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 789, + 2 + ] + } + }); } if (!eq(tFromJs("variant180"), "variant180")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 790, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 790, + 2 + ] + } + }); } if (!eq(tFromJs("variant181"), "variant181")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 791, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 791, + 2 + ] + } + }); } if (!eq(tFromJs("variant182"), "variant182")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 792, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 792, + 2 + ] + } + }); } if (!eq(tFromJs("variant183"), "variant183")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 793, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 793, + 2 + ] + } + }); } if (!eq(tFromJs("variant184"), "variant184")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 794, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 794, + 2 + ] + } + }); } if (!eq(tFromJs("variant185"), "variant185")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 795, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 795, + 2 + ] + } + }); } if (!eq(tFromJs("variant186"), "variant186")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 796, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 796, + 2 + ] + } + }); } if (!eq(tFromJs("variant187"), "variant187")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 797, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 797, + 2 + ] + } + }); } if (!eq(tFromJs("variant188"), "variant188")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 798, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 798, + 2 + ] + } + }); } if (!eq(tFromJs("variant189"), "variant189")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 799, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 799, + 2 + ] + } + }); } if (!eq(tFromJs("variant190"), "variant190")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 800, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 800, + 2 + ] + } + }); } if (!eq(tFromJs("variant191"), "variant191")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 801, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 801, + 2 + ] + } + }); } if (!eq(tFromJs("variant192"), "variant192")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 802, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 802, + 2 + ] + } + }); } if (!eq(tFromJs("variant193"), "variant193")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 803, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 803, + 2 + ] + } + }); } if (!eq(tFromJs("variant194"), "variant194")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 804, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 804, + 2 + ] + } + }); } if (!eq(tFromJs("variant195"), "variant195")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 805, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 805, + 2 + ] + } + }); } if (!eq(tFromJs("variant196"), "variant196")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 806, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 806, + 2 + ] + } + }); } if (!eq(tFromJs("variant197"), "variant197")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 807, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 807, + 2 + ] + } + }); } if (!eq(tFromJs("variant198"), "variant198")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 808, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 808, + 2 + ] + } + }); } if (!eq(tFromJs("variant199"), "variant199")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 809, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 809, + 2 + ] + } + }); } if (!eq(tFromJs("variant200"), "variant200")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 810, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 810, + 2 + ] + } + }); } if (!eq(tFromJs("variant201"), "variant201")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 811, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 811, + 2 + ] + } + }); } if (!eq(tFromJs("variant202"), "variant202")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 812, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 812, + 2 + ] + } + }); } if (!eq(tFromJs("variant203"), "variant203")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 813, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 813, + 2 + ] + } + }); } if (!eq(tFromJs("variant204"), "variant204")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 814, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 814, + 2 + ] + } + }); } if (!eq(tFromJs("variant205"), "variant205")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 815, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 815, + 2 + ] + } + }); } if (!eq(tFromJs("variant206"), "variant206")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 816, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 816, + 2 + ] + } + }); } if (!eq(tFromJs("variant207"), "variant207")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 817, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 817, + 2 + ] + } + }); } if (!eq(tFromJs("variant208"), "variant208")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 818, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 818, + 2 + ] + } + }); } if (!eq(tFromJs("variant209"), "variant209")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 819, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 819, + 2 + ] + } + }); } if (!eq(tFromJs("variant210"), "variant210")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 820, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 820, + 2 + ] + } + }); } if (!eq(tFromJs("variant211"), "variant211")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 821, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 821, + 2 + ] + } + }); } if (!eq(tFromJs("variant212"), "variant212")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 822, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 822, + 2 + ] + } + }); } if (!eq(tFromJs("variant213"), "variant213")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 823, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 823, + 2 + ] + } + }); } if (!eq(tFromJs("variant214"), "variant214")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 824, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 824, + 2 + ] + } + }); } if (!eq(tFromJs("variant215"), "variant215")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 825, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 825, + 2 + ] + } + }); } if (!eq(tFromJs("variant216"), "variant216")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 826, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 826, + 2 + ] + } + }); } if (!eq(tFromJs("variant217"), "variant217")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 827, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 827, + 2 + ] + } + }); } if (!eq(tFromJs("variant218"), "variant218")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 828, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 828, + 2 + ] + } + }); } if (!eq(tFromJs("variant219"), "variant219")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 829, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 829, + 2 + ] + } + }); } if (!eq(tFromJs("variant220"), "variant220")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 830, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 830, + 2 + ] + } + }); } if (!eq(tFromJs("variant221"), "variant221")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 831, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 831, + 2 + ] + } + }); } if (!eq(tFromJs("variant222"), "variant222")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 832, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 832, + 2 + ] + } + }); } if (!eq(tFromJs("variant223"), "variant223")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 833, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 833, + 2 + ] + } + }); } if (!eq(tFromJs("variant224"), "variant224")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 834, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 834, + 2 + ] + } + }); } if (!eq(tFromJs("variant225"), "variant225")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 835, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 835, + 2 + ] + } + }); } if (!eq(tFromJs("variant226"), "variant226")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 836, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 836, + 2 + ] + } + }); } if (!eq(tFromJs("variant227"), "variant227")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 837, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 837, + 2 + ] + } + }); } if (!eq(tFromJs("variant228"), "variant228")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 838, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 838, + 2 + ] + } + }); } if (!eq(tFromJs("variant229"), "variant229")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 839, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 839, + 2 + ] + } + }); } if (!eq(tFromJs("variant230"), "variant230")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 840, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 840, + 2 + ] + } + }); } if (!eq(tFromJs("variant231"), "variant231")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 841, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 841, + 2 + ] + } + }); } if (!eq(tFromJs("variant232"), "variant232")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 842, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 842, + 2 + ] + } + }); } if (!eq(tFromJs("variant233"), "variant233")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 843, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 843, + 2 + ] + } + }); } if (!eq(tFromJs("variant234"), "variant234")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 844, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 844, + 2 + ] + } + }); } if (!eq(tFromJs("variant235"), "variant235")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 845, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 845, + 2 + ] + } + }); } if (!eq(tFromJs("variant236"), "variant236")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 846, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 846, + 2 + ] + } + }); } if (!eq(tFromJs("variant237"), "variant237")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 847, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 847, + 2 + ] + } + }); } if (!eq(tFromJs("variant238"), "variant238")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 848, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 848, + 2 + ] + } + }); } if (!eq(tFromJs("variant239"), "variant239")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 849, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 849, + 2 + ] + } + }); } if (!eq(tFromJs("variant240"), "variant240")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 850, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 850, + 2 + ] + } + }); } if (!eq(tFromJs("variant241"), "variant241")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 851, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 851, + 2 + ] + } + }); } if (!eq(tFromJs("variant242"), "variant242")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 852, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 852, + 2 + ] + } + }); } if (!eq(tFromJs("variant243"), "variant243")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 853, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 853, + 2 + ] + } + }); } if (!eq(tFromJs("variant244"), "variant244")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 854, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 854, + 2 + ] + } + }); } if (!eq(tFromJs("variant245"), "variant245")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 855, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 855, + 2 + ] + } + }); } if (!eq(tFromJs("variant246"), "variant246")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 856, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 856, + 2 + ] + } + }); } if (!eq(tFromJs("variant247"), "variant247")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 857, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 857, + 2 + ] + } + }); } if (!eq(tFromJs("variant248"), "variant248")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 858, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 858, + 2 + ] + } + }); } if (!eq(tFromJs("variant249"), "variant249")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 859, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 859, + 2 + ] + } + }); } if (!eq(tFromJs("variant250"), "variant250")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 860, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 860, + 2 + ] + } + }); } if (!eq(tFromJs("variant251"), "variant251")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 861, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 861, + 2 + ] + } + }); } if (!eq(tFromJs("variant252"), "variant252")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 862, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 862, + 2 + ] + } + }); } if (!eq(tFromJs("variant253"), "variant253")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 863, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 863, + 2 + ] + } + }); } if (!eq(tFromJs("variant254"), "variant254")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 864, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 864, + 2 + ] + } + }); } if (!eq(tFromJs("variant255"), "variant255")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 865, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 865, + 2 + ] + } + }); } if (!eq(tFromJs("variant256"), "variant256")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 866, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 866, + 2 + ] + } + }); } if (!eq(tFromJs("variant257"), "variant257")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 867, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 867, + 2 + ] + } + }); } if (!eq(tFromJs("variant258"), "variant258")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 868, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 868, + 2 + ] + } + }); } if (!eq(tFromJs("variant259"), "variant259")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 869, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 869, + 2 + ] + } + }); } if (!eq(tFromJs("variant260"), "variant260")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 870, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 870, + 2 + ] + } + }); } if (!eq(tFromJs("variant261"), "variant261")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 871, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 871, + 2 + ] + } + }); } if (!eq(tFromJs("variant262"), "variant262")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 872, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 872, + 2 + ] + } + }); } if (!eq(tFromJs("variant263"), "variant263")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 873, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 873, + 2 + ] + } + }); } if (!eq(tFromJs("variant264"), "variant264")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 874, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 874, + 2 + ] + } + }); } if (!eq(tFromJs("variant265"), "variant265")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 875, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 875, + 2 + ] + } + }); } if (!eq(tFromJs("variant266"), "variant266")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 876, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 876, + 2 + ] + } + }); } if (!eq(tFromJs("variant267"), "variant267")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 877, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 877, + 2 + ] + } + }); } if (!eq(tFromJs("variant268"), "variant268")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 878, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 878, + 2 + ] + } + }); } if (!eq(tFromJs("variant269"), "variant269")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 879, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 879, + 2 + ] + } + }); } if (!eq(tFromJs("variant270"), "variant270")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 880, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 880, + 2 + ] + } + }); } if (!eq(tFromJs("variant271"), "variant271")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 881, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 881, + 2 + ] + } + }); } if (!eq(tFromJs("variant272"), "variant272")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 882, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 882, + 2 + ] + } + }); } if (!eq(tFromJs("variant273"), "variant273")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 883, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 883, + 2 + ] + } + }); } if (!eq(tFromJs("variant274"), "variant274")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 884, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 884, + 2 + ] + } + }); } if (!eq(tFromJs("variant275"), "variant275")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 885, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 885, + 2 + ] + } + }); } if (!eq(tFromJs("variant276"), "variant276")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 886, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 886, + 2 + ] + } + }); } if (!eq(tFromJs("variant277"), "variant277")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 887, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 887, + 2 + ] + } + }); } if (!eq(tFromJs("variant278"), "variant278")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 888, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 888, + 2 + ] + } + }); } if (!eq(tFromJs("variant279"), "variant279")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 889, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 889, + 2 + ] + } + }); } if (!eq(tFromJs("variant280"), "variant280")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 890, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 890, + 2 + ] + } + }); } if (!eq(tFromJs("variant281"), "variant281")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 891, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 891, + 2 + ] + } + }); } if (!eq(tFromJs("variant282"), "variant282")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 892, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 892, + 2 + ] + } + }); } if (!eq(tFromJs("variant283"), "variant283")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 893, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 893, + 2 + ] + } + }); } if (!eq(tFromJs("variant284"), "variant284")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 894, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 894, + 2 + ] + } + }); } if (!eq(tFromJs("variant285"), "variant285")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 895, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 895, + 2 + ] + } + }); } if (!eq(tFromJs("variant286"), "variant286")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 896, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 896, + 2 + ] + } + }); } if (!eq(tFromJs("variant287"), "variant287")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 897, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 897, + 2 + ] + } + }); } if (!eq(tFromJs("variant288"), "variant288")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 898, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 898, + 2 + ] + } + }); } if (!eq(tFromJs("variant289"), "variant289")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 899, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 899, + 2 + ] + } + }); } if (!eq(tFromJs("variant290"), "variant290")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 900, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 900, + 2 + ] + } + }); } if (!eq(tFromJs("variant291"), "variant291")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 901, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 901, + 2 + ] + } + }); } if (!eq(tFromJs("variant292"), "variant292")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 902, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 902, + 2 + ] + } + }); } if (!eq(tFromJs("variant293"), "variant293")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 903, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 903, + 2 + ] + } + }); } if (!eq(tFromJs("variant294"), "variant294")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 904, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 904, + 2 + ] + } + }); } if (!eq(tFromJs("variant295"), "variant295")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 905, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 905, + 2 + ] + } + }); } if (!eq(tFromJs("variant296"), "variant296")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 906, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 906, + 2 + ] + } + }); } if (!eq(tFromJs("variant297"), "variant297")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 907, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 907, + 2 + ] + } + }); } if (!eq(tFromJs("variant298"), "variant298")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 908, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 908, + 2 + ] + } + }); } if (!eq(tFromJs("variant299"), "variant299")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 909, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 909, + 2 + ] + } + }); } if (!eq(tFromJs("xx"), undefined)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/big_polyvar_test.ml", - 910, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/big_polyvar_test.ml", + 910, + 2 + ] + } + }); } exports.tToJs = tToJs; diff --git a/jscomp/test/dist/jscomp/test/bs_array_test.js b/jscomp/test/dist/jscomp/test/bs_array_test.js index ce2dfa2274..71e7b2adec 100644 --- a/jscomp/test/dist/jscomp/test/bs_array_test.js +++ b/jscomp/test/dist/jscomp/test/bs_array_test.js @@ -137,15 +137,16 @@ var v$1 = [ ]; if (!Belt__Belt_Array.set(v$1, 0, 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_array_test.ml", - 38, - 33 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_array_test.ml", + 38, + 33 + ] + } + }); } b("File \"jscomp/test/bs_array_test.ml\", line 38, characters 4-11", Belt__Belt_Array.getExn(v$1, 0) === 0); @@ -156,15 +157,16 @@ var v$2 = [ ]; if (!Belt__Belt_Array.set(v$2, 1, 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_array_test.ml", - 39, - 32 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_array_test.ml", + 39, + 32 + ] + } + }); } b("File \"jscomp/test/bs_array_test.ml\", line 39, characters 4-11", Belt__Belt_Array.getExn(v$2, 1) === 0); @@ -279,15 +281,16 @@ function addone(x) { function makeMatrixExn(sx, sy, init) { if (!(sx >= 0 && sy >= 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_array_test.ml", - 80, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_array_test.ml", + 80, + 2 + ] + } + }); } var res = new Array(sx); for(var x = 0; x < sx; ++x){ diff --git a/jscomp/test/dist/jscomp/test/bs_hashtbl_string_test.js b/jscomp/test/dist/jscomp/test/bs_hashtbl_string_test.js index 97be2944bf..9a6f819c7e 100644 --- a/jscomp/test/dist/jscomp/test/bs_hashtbl_string_test.js +++ b/jscomp/test/dist/jscomp/test/bs_hashtbl_string_test.js @@ -52,15 +52,16 @@ function bench(param) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashMap.has(empty, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 50, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 50, + 4 + ] + } + }); } } @@ -74,15 +75,16 @@ function bench2(m) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashMap.has(empty, String(i$1))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 76, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 76, + 4 + ] + } + }); } } @@ -92,15 +94,16 @@ function bench2(m) { if (empty.size === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 82, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 82, + 2 + ] + } + }); } function bench3(m) { @@ -112,15 +115,16 @@ function bench3(m) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_MapDict.has(table, String(i$1), cmp)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 98, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 98, + 4 + ] + } + }); } } @@ -130,15 +134,16 @@ function bench3(m) { if (Belt__Belt_MapDict.size(table) === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 105, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 105, + 2 + ] + } + }); } var Sx = Belt__Belt_Id.comparable(Caml.caml_string_compare); @@ -150,15 +155,16 @@ function bench4(param) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashMapString.has(table, String(i$1))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 118, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 118, + 4 + ] + } + }); } } @@ -168,15 +174,16 @@ function bench4(param) { if (Belt__Belt_HashMapString.isEmpty(table)) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 124, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 124, + 2 + ] + } + }); } function bench5(param) { @@ -189,15 +196,16 @@ function bench5(param) { console.time("bs_hashtbl_string_test.ml 137"); for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashMap.has(table, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 138, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 138, + 6 + ] + } + }); } } @@ -210,15 +218,16 @@ function bench5(param) { if (Belt__Belt_HashMap.isEmpty(table)) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 144, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 144, + 2 + ] + } + }); } function bench6(param) { @@ -228,15 +237,16 @@ function bench6(param) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashMapInt.has(table, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 156, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 156, + 4 + ] + } + }); } } @@ -246,15 +256,16 @@ function bench6(param) { if (table.size === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 162, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 162, + 2 + ] + } + }); } function bench7(param) { @@ -264,15 +275,16 @@ function bench7(param) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_HashSetInt.has(table, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 181, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 181, + 4 + ] + } + }); } } @@ -282,15 +294,16 @@ function bench7(param) { if (table.size === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_hashtbl_string_test.ml", - 192, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_hashtbl_string_test.ml", + 192, + 2 + ] + } + }); } console.time("bs_hashtbl_string_test.ml 203"); diff --git a/jscomp/test/dist/jscomp/test/bs_queue_test.js b/jscomp/test/dist/jscomp/test/bs_queue_test.js index ec234b5829..a9423ebb50 100644 --- a/jscomp/test/dist/jscomp/test/bs_queue_test.js +++ b/jscomp/test/dist/jscomp/test/bs_queue_test.js @@ -45,42 +45,45 @@ var q = { }; if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), []) && q.length === 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 21, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 21, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQueue.add(q, 1), q)), [1]) && q.length === 1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 22, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 22, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQueue.add(q, 2), q)), [ 1, 2 ]) && q.length === 2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 23, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 23, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQueue.add(q, 3), q)), [ @@ -88,15 +91,16 @@ if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQue 2, 3 ]) && q.length === 3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 24, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 24, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQueue.add(q, 4), q)), [ @@ -105,27 +109,29 @@ if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray((Belt__Belt_MutableQue 3, 4 ]) && q.length === 4)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 25, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 25, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 26, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 26, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), [ @@ -133,102 +139,110 @@ if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), [ 3, 4 ]) && q.length === 3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 26, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 26, + 27 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 27, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 27, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), [ 3, 4 ]) && q.length === 2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 27, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 27, + 27 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 28, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 28, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), [4]) && q.length === 1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 28, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 28, + 27 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q) !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 29, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 29, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q), []) && q.length === 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 29, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 29, + 27 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.popExn, q)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 30, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 30, + 2 + ] + } + }); } var q$1 = { @@ -238,63 +252,68 @@ var q$1 = { }; if (Belt__Belt_MutableQueue.popExn((Belt__Belt_MutableQueue.add(q$1, 1), q$1)) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 35, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 35, + 2 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.popExn, q$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 35, - 34 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 35, + 34 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn((Belt__Belt_MutableQueue.add(q$1, 2), q$1)) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 36, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 36, + 2 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.popExn, q$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 36, - 34 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 36, + 34 + ] + } + }); } if (q$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 37, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 37, + 2 + ] + } + }); } var q$2 = { @@ -304,135 +323,146 @@ var q$2 = { }; if (Belt__Belt_MutableQueue.peekExn((Belt__Belt_MutableQueue.add(q$2, 1), q$2)) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 42, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 42, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.peekExn((Belt__Belt_MutableQueue.add(q$2, 2), q$2)) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 43, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 43, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.peekExn((Belt__Belt_MutableQueue.add(q$2, 3), q$2)) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 44, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 44, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.peekExn(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 45, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 45, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 45, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 45, + 28 + ] + } + }); } if (Belt__Belt_MutableQueue.peekExn(q$2) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 46, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 46, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q$2) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 46, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 46, + 28 + ] + } + }); } if (Belt__Belt_MutableQueue.peekExn(q$2) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 47, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 47, + 2 + ] + } + }); } if (Belt__Belt_MutableQueue.popExn(q$2) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 47, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 47, + 28 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.peekExn, q$2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 48, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 48, + 2 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.peekExn, q$2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 49, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 49, + 2 + ] + } + }); } var q$3 = { @@ -448,27 +478,29 @@ for(var i = 1; i <= 10; ++i){ Belt__Belt_MutableQueue.clear(q$3); if (q$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 56, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 56, + 2 + ] + } + }); } if (!does_raise(Belt__Belt_MutableQueue.popExn, q$3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 57, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 57, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(q$3, { @@ -476,29 +508,31 @@ if (!Caml_obj.caml_equal(q$3, { first: undefined, last: undefined })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 58, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 58, + 2 + ] + } + }); } Belt__Belt_MutableQueue.add(q$3, 42); if (Belt__Belt_MutableQueue.popExn(q$3) !== 42) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 60, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 60, + 2 + ] + } + }); } var q1 = { @@ -525,15 +559,16 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1), [ 9, 10 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 67, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 67, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2), [ @@ -548,67 +583,72 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2), [ 9, 10 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 68, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 68, + 2 + ] + } + }); } if (q1.length !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 69, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 69, + 2 + ] + } + }); } if (q2.length !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 70, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 70, + 2 + ] + } + }); } for(var i$2 = 1; i$2 <= 10; ++i$2){ if (Belt__Belt_MutableQueue.popExn(q1) !== i$2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 72, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 72, + 4 + ] + } + }); } } for(var i$3 = 1; i$3 <= 10; ++i$3){ if (Belt__Belt_MutableQueue.popExn(q2) !== i$3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 75, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 75, + 4 + ] + } + }); } } @@ -620,92 +660,99 @@ var q$4 = { }; if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 81, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 81, + 2 + ] + } + }); } for(var i$4 = 1; i$4 <= 10; ++i$4){ Belt__Belt_MutableQueue.add(q$4, i$4); if (q$4.length !== i$4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 84, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 84, + 4 + ] + } + }); } if (q$4.length === 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 85, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 85, + 4 + ] + } + }); } } for(var i$5 = 10; i$5 >= 1; --i$5){ if (q$4.length !== i$5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 88, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 88, + 4 + ] + } + }); } if (q$4.length === 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 89, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 89, + 4 + ] + } + }); } Belt__Belt_MutableQueue.popExn(q$4); } if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 92, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 92, + 2 + ] + } + }); } if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 93, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 93, + 2 + ] + } + }); } var q$5 = { @@ -724,15 +771,16 @@ var i$7 = { Belt__Belt_MutableQueue.forEach(q$5, (function (j) { if (i$7.contents !== j) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 100, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 100, + 24 + ] + } + }); } i$7.contents = i$7.contents + 1 | 0; })); @@ -750,101 +798,109 @@ var q2$1 = { }; if (q1$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 105, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 105, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$1), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 105, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 105, + 26 + ] + } + }); } if (q2$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 106, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 106, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$1), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 106, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 106, + 26 + ] + } + }); } Belt__Belt_MutableQueue.transfer(q1$1, q2$1); if (q1$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 108, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 108, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$1), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 108, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 108, + 26 + ] + } + }); } if (q2$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 109, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 109, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$1), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 109, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 109, + 26 + ] + } + }); } var q1$2 = { @@ -864,15 +920,16 @@ for(var i$8 = 1; i$8 <= 4; ++i$8){ } if (q1$2.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 115, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 115, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$2), [ @@ -881,77 +938,83 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$2), [ 3, 4 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 115, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 115, + 26 + ] + } + }); } if (q2$2.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 116, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 116, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$2), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 116, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 116, + 26 + ] + } + }); } Belt__Belt_MutableQueue.transfer(q1$2, q2$2); if (q1$2.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 118, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 118, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$2), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 118, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 118, + 26 + ] + } + }); } if (q2$2.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 119, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 119, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$2), [ @@ -960,15 +1023,16 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$2), [ 3, 4 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 119, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 119, + 26 + ] + } + }); } var q1$3 = { @@ -988,39 +1052,42 @@ for(var i$9 = 5; i$9 <= 8; ++i$9){ } if (q1$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 125, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 125, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$3), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 125, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 125, + 26 + ] + } + }); } if (q2$3.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 126, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 126, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$3), [ @@ -1029,53 +1096,57 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$3), [ 7, 8 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 126, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 126, + 26 + ] + } + }); } Belt__Belt_MutableQueue.transfer(q1$3, q2$3); if (q1$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 128, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 128, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$3), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 128, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 128, + 26 + ] + } + }); } if (q2$3.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 129, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 129, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$3), [ @@ -1084,15 +1155,16 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$3), [ 7, 8 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 129, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 129, + 26 + ] + } + }); } var q1$4 = { @@ -1116,15 +1188,16 @@ for(var i$11 = 5; i$11 <= 8; ++i$11){ } if (q1$4.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 136, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 136, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$4), [ @@ -1133,27 +1206,29 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$4), [ 3, 4 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 136, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 136, + 26 + ] + } + }); } if (q2$4.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 137, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 137, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$4), [ @@ -1162,41 +1237,44 @@ if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$4), [ 7, 8 ])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 137, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 137, + 26 + ] + } + }); } Belt__Belt_MutableQueue.transfer(q1$4, q2$4); if (q1$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 139, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 139, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q1$4), [])) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 139, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 139, + 26 + ] + } + }); } var v = [ @@ -1211,27 +1289,29 @@ var v = [ ]; if (q2$4.length !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 141, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 141, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(Belt__Belt_MutableQueue.toArray(q2$4), v)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 141, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 141, + 26 + ] + } + }); } if (Belt__Belt_MutableQueue.reduce(q2$4, 0, (function (x, y) { @@ -1239,15 +1319,16 @@ if (Belt__Belt_MutableQueue.reduce(q2$4, 0, (function (x, y) { })) !== Belt__Belt_Array.reduce(v, 0, (function (x, y) { return x - y | 0; }))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_queue_test.ml", - 143, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_queue_test.ml", + 143, + 2 + ] + } + }); } console.log("OK"); diff --git a/jscomp/test/dist/jscomp/test/bs_rbset_int_bench.js b/jscomp/test/dist/jscomp/test/bs_rbset_int_bench.js index f64cadb1a6..cb3c9f425a 100644 --- a/jscomp/test/dist/jscomp/test/bs_rbset_int_bench.js +++ b/jscomp/test/dist/jscomp/test/bs_rbset_int_bench.js @@ -13,15 +13,16 @@ function bench(param) { console.time("bs_rbset_int_bench.ml 11"); for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Rbset.mem(i$1, data)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_rbset_int_bench.ml", - 12, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_rbset_int_bench.ml", + 12, + 4 + ] + } + }); } } @@ -34,15 +35,16 @@ function bench(param) { if (Rbset.cardinal(data) === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_rbset_int_bench.ml", - 17, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_rbset_int_bench.ml", + 17, + 2 + ] + } + }); } console.time("bs_rbset_int_bench.ml 21"); diff --git a/jscomp/test/dist/jscomp/test/bs_set_bench.js b/jscomp/test/dist/jscomp/test/bs_set_bench.js index 9acad395cc..6c99dbac06 100644 --- a/jscomp/test/dist/jscomp/test/bs_set_bench.js +++ b/jscomp/test/dist/jscomp/test/bs_set_bench.js @@ -13,15 +13,16 @@ function bench(param) { console.time("bs_set_bench.ml 11"); for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Belt__Belt_SetInt.has(data, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_set_bench.ml", - 12, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_set_bench.ml", + 12, + 4 + ] + } + }); } } @@ -34,15 +35,16 @@ function bench(param) { if (Belt__Belt_SetInt.size(data) === 0) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/bs_set_bench.ml", - 17, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/bs_set_bench.ml", + 17, + 2 + ] + } + }); } console.time("bs_set_bench.ml 21"); diff --git a/jscomp/test/dist/jscomp/test/caml_sys_poly_fill_test.js b/jscomp/test/dist/jscomp/test/caml_sys_poly_fill_test.js index fa21c65bfb..f465a723f7 100644 --- a/jscomp/test/dist/jscomp/test/caml_sys_poly_fill_test.js +++ b/jscomp/test/dist/jscomp/test/caml_sys_poly_fill_test.js @@ -57,7 +57,9 @@ catch (raw_exn){ if (exn.MEL_EXN_ID === Stdlib.Not_found) { tmp = "Z"; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/chn_test.js b/jscomp/test/dist/jscomp/test/chn_test.js index d6e689a3c8..08f6004dfa 100644 --- a/jscomp/test/dist/jscomp/test/chn_test.js +++ b/jscomp/test/dist/jscomp/test/chn_test.js @@ -40,15 +40,16 @@ function convert(s) { if (x$1 !== undefined) { return x$1; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/chn_test.ml", - 20, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/chn_test.ml", + 20, + 22 + ] + } + }); }))); } diff --git a/jscomp/test/dist/jscomp/test/class6_test.js b/jscomp/test/dist/jscomp/test/class6_test.js index 1ac872bd87..86d379bd13 100644 --- a/jscomp/test/dist/jscomp/test/class6_test.js +++ b/jscomp/test/dist/jscomp/test/class6_test.js @@ -116,10 +116,11 @@ function lookup_obj(obj, _param) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/class_fib_open_recursion_test.js b/jscomp/test/dist/jscomp/test/class_fib_open_recursion_test.js index a85c0778be..1a14d42164 100644 --- a/jscomp/test/dist/jscomp/test/class_fib_open_recursion_test.js +++ b/jscomp/test/dist/jscomp/test/class_fib_open_recursion_test.js @@ -70,7 +70,9 @@ function memo_fib_init($$class) { Stdlib__Hashtbl.add(self$2[cache], x, v); return v; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } })); return function (env, self) { diff --git a/jscomp/test/dist/jscomp/test/class_repr.js b/jscomp/test/dist/jscomp/test/class_repr.js index 7e81b215d6..2076479c33 100644 --- a/jscomp/test/dist/jscomp/test/class_repr.js +++ b/jscomp/test/dist/jscomp/test/class_repr.js @@ -49,27 +49,29 @@ var v = Curry._2(x[0], undefined, 3); var u = Caml_oo.caml_set_oo_id(Caml_obj.caml_obj_dup(v)); if (Caml_oo_curry.js1(291546447, 1, v) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/class_repr.ml", - 28, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/class_repr.ml", + 28, + 9 + ] + } + }); } if (Caml_oo_curry.js1(291546447, 2, u) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/class_repr.ml", - 30, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/class_repr.ml", + 30, + 9 + ] + } + }); } function xx_init($$class) { @@ -105,15 +107,16 @@ var v1 = Curry._2(xx[0], undefined, 3); var v2 = Caml_oo_curry.js1(-977586732, 3, v1); if (Caml_oo_curry.js1(-804710761, 4, v1) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/class_repr.ml", - 42, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/class_repr.ml", + 42, + 9 + ] + } + }); } if (typeof Stdlib__Sys.backend_type !== "number" && Stdlib__Sys.backend_type._0 === "Melange") { @@ -124,15 +127,16 @@ if (typeof Stdlib__Sys.backend_type !== "number" && Stdlib__Sys.backend_type._0 } if (Caml_oo_curry.js1(-804710761, 9, v2) !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/class_repr.ml", - 57, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/class_repr.ml", + 57, + 9 + ] + } + }); } function point_init($$class) { @@ -168,15 +172,16 @@ var point = CamlinternalOO.make_class([ var v$1 = Curry._1(point[0], undefined); if (Caml_oo_curry.js1(590348294, 10, v$1) !== 5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/class_repr.ml", - 104, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/class_repr.ml", + 104, + 2 + ] + } + }); } function xx0_init($$class) { diff --git a/jscomp/test/dist/jscomp/test/const_defs_test.js b/jscomp/test/dist/jscomp/test/const_defs_test.js index 4504b11731..56778ba060 100644 --- a/jscomp/test/dist/jscomp/test/const_defs_test.js +++ b/jscomp/test/dist/jscomp/test/const_defs_test.js @@ -5,11 +5,12 @@ var u = 3; function f(param) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "hi", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "hi" + } + }); } exports.u = u; diff --git a/jscomp/test/dist/jscomp/test/custom_error_test.js b/jscomp/test/dist/jscomp/test/custom_error_test.js index 0e8865fee1..92bddaa587 100644 --- a/jscomp/test/dist/jscomp/test/custom_error_test.js +++ b/jscomp/test/dist/jscomp/test/custom_error_test.js @@ -16,7 +16,9 @@ function test_js_error(param) { console.log(exn._1.stack); return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return Caml_option.some(e); } @@ -29,9 +31,13 @@ function test_js_error2(param) { var e = Caml_js_exceptions.internalToOCamlException(raw_e); if (e.MEL_EXN_ID === Js__Js_exn.$$Error) { console.log(e._1.stack); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } @@ -46,7 +52,9 @@ function example1(param) { console.log(exn._1.stack); return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return Caml_option.some(v); } @@ -60,7 +68,9 @@ function example2(param) { if (exn.MEL_EXN_ID === Js__Js_exn.$$Error) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/defunctor_make_test.js b/jscomp/test/dist/jscomp/test/defunctor_make_test.js index 2019042b09..df5d7c7825 100644 --- a/jscomp/test/dist/jscomp/test/defunctor_make_test.js +++ b/jscomp/test/dist/jscomp/test/defunctor_make_test.js @@ -51,17 +51,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -83,17 +85,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, compare, param) { diff --git a/jscomp/test/dist/jscomp/test/demo_int_map.js b/jscomp/test/dist/jscomp/test/demo_int_map.js index afd98df9e8..7d3417f0a1 100644 --- a/jscomp/test/dist/jscomp/test/demo_int_map.js +++ b/jscomp/test/dist/jscomp/test/demo_int_map.js @@ -47,17 +47,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -79,17 +81,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -147,10 +151,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/earger_curry_test.js b/jscomp/test/dist/jscomp/test/earger_curry_test.js index 694970c4bf..9dd7215d07 100644 --- a/jscomp/test/dist/jscomp/test/earger_curry_test.js +++ b/jscomp/test/dist/jscomp/test/earger_curry_test.js @@ -25,11 +25,12 @@ function init(l, f) { return []; } if (l < 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.init", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.init" + } + }); } var res = Caml_array.make(l, f$1(0)); for(var i = 1; i < l; ++i){ diff --git a/jscomp/test/dist/jscomp/test/equal_exception_test.js b/jscomp/test/dist/jscomp/test/equal_exception_test.js index 21c8eac24c..80bc63eef7 100644 --- a/jscomp/test/dist/jscomp/test/equal_exception_test.js +++ b/jscomp/test/dist/jscomp/test/equal_exception_test.js @@ -13,56 +13,62 @@ var v = "gso"; function is_equal(param) { if (Caml_bytes.get(Stdlib__Bytes.make(3, /* 'a' */97), 0) !== /* 'a' */97) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/equal_exception_test.ml", - 9, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/equal_exception_test.ml", + 9, + 4 + ] + } + }); } if (Stdlib__Bytes.make(3, /* 'a' */97)[0] !== /* 'a' */97) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/equal_exception_test.ml", - 10, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/equal_exception_test.ml", + 10, + 4 + ] + } + }); } var u = Stdlib__Bytes.make(3, /* 'a' */97); u[0] = /* 'b' */98; if (u[0] !== /* 'b' */98) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/equal_exception_test.ml", - 13, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/equal_exception_test.ml", + 13, + 4 + ] + } + }); } } function is_exception(param) { try { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -73,7 +79,9 @@ function is_normal_exception(_x) { _1: 3 }; try { - throw v; + throw new Error(v.MEL_EXN_ID, { + cause: v + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -81,19 +89,24 @@ function is_normal_exception(_x) { if (exn._1 === 3) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } function is_arbitrary_exception(param) { var A = /* @__PURE__ */Caml_exceptions.create("A"); try { - throw { - MEL_EXN_ID: A, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A + } + }); } catch (exn){ return ; @@ -143,27 +156,29 @@ var Not_found = /* @__PURE__ */Caml_exceptions.create("Equal_exception_test.Not_ if (Caml_obj.caml_equal(e, { MEL_EXN_ID: Not_found }) !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/equal_exception_test.ml", - 50, - 3 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/equal_exception_test.ml", + 50, + 3 + ] + } + }); } if (Not_found === Stdlib.Not_found !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/equal_exception_test.ml", - 51, - 3 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/equal_exception_test.ml", + 51, + 3 + ] + } + }); } Mt.from_suites("exception", suites); diff --git a/jscomp/test/dist/jscomp/test/exception_raise_test.js b/jscomp/test/dist/jscomp/test/exception_raise_test.js index 4e52223981..cc808e33b3 100644 --- a/jscomp/test/dist/jscomp/test/exception_raise_test.js +++ b/jscomp/test/dist/jscomp/test/exception_raise_test.js @@ -105,15 +105,16 @@ catch (raw_exn$3){ if (exn$3.MEL_EXN_ID === A || exn$3.MEL_EXN_ID === Js__Js_exn.$$Error) { a0 = exn$3._1; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/exception_raise_test.ml", - 102, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/exception_raise_test.ml", + 102, + 9 + ] + } + }); } } @@ -170,15 +171,16 @@ var suites = { _1: 2 }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/exception_raise_test.ml", - 119, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/exception_raise_test.ml", + 119, + 15 + ] + } + }); }) ], tl: /* [] */0 @@ -204,10 +206,11 @@ catch (raw_e$2){ } try { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } catch (raw_e$3){ var e$1 = Caml_js_exceptions.internalToOCamlException(raw_e$3); diff --git a/jscomp/test/dist/jscomp/test/exception_rebound_err_test.js b/jscomp/test/dist/jscomp/test/exception_rebound_err_test.js index 96263d1cbb..615c989965 100644 --- a/jscomp/test/dist/jscomp/test/exception_rebound_err_test.js +++ b/jscomp/test/dist/jscomp/test/exception_rebound_err_test.js @@ -76,7 +76,9 @@ function f(g) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return 1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/exception_value_test.js b/jscomp/test/dist/jscomp/test/exception_value_test.js index f384550f2d..bc5fb10485 100644 --- a/jscomp/test/dist/jscomp/test/exception_value_test.js +++ b/jscomp/test/dist/jscomp/test/exception_value_test.js @@ -8,32 +8,35 @@ var Js__Js_exn = require("melange.js/js_exn.js"); var Stdlib = require("melange/stdlib.js"); function f(param) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function assert_f(x) { if (x <= 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/exception_value_test.ml", - 9, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/exception_value_test.ml", + 9, + 12 + ] + } + }); } return 3; } function hh(param) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var A = /* @__PURE__ */Caml_exceptions.create("Exception_value_test.A"); @@ -56,7 +59,9 @@ function test_not_found(f, param) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return 2; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -68,9 +73,13 @@ function test_js_error2(param) { var e = Caml_js_exceptions.internalToOCamlException(raw_e); if (e.MEL_EXN_ID === Js__Js_exn.$$Error) { console.log(e._1.stack); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } diff --git a/jscomp/test/dist/jscomp/test/exn_error_pattern.js b/jscomp/test/dist/jscomp/test/exn_error_pattern.js index eae775f530..82c3c7fef1 100644 --- a/jscomp/test/dist/jscomp/test/exn_error_pattern.js +++ b/jscomp/test/dist/jscomp/test/exn_error_pattern.js @@ -73,7 +73,9 @@ eq("File \"jscomp/test/exn_error_pattern.ml\", line 33, characters 5-12", f({ var tmp; try { - throw new Error("x"); + throw new Error(new Error("x").MEL_EXN_ID, { + cause: new Error("x") + }); } catch (raw_e){ tmp = Caml_js_exceptions.internalToOCamlException(raw_e); diff --git a/jscomp/test/dist/jscomp/test/ext_array_test.js b/jscomp/test/dist/jscomp/test/ext_array_test.js index 7898765162..0bfe6b035d 100644 --- a/jscomp/test/dist/jscomp/test/ext_array_test.js +++ b/jscomp/test/dist/jscomp/test/ext_array_test.js @@ -106,11 +106,12 @@ function filter_map(f, a) { function range(from, to_) { if (from > to_) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.range", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.range" + } + }); } return Stdlib__Array.init((to_ - from | 0) + 1 | 0, (function (i) { return i + from | 0; @@ -120,11 +121,12 @@ function range(from, to_) { function map2i(f, a, b) { var len = a.length; if (len !== b.length) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_array_test.map2i", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_array_test.map2i" + } + }); } return Stdlib__Array.mapi((function (i, a) { return Curry._3(f, i, a, b[i]); diff --git a/jscomp/test/dist/jscomp/test/ext_bytes_test.js b/jscomp/test/dist/jscomp/test/ext_bytes_test.js index aab299f06e..785da8b8da 100644 --- a/jscomp/test/dist/jscomp/test/ext_bytes_test.js +++ b/jscomp/test/dist/jscomp/test/ext_bytes_test.js @@ -137,10 +137,11 @@ function starts_with(xs, prefix, p) { try { for(var i = 0; i < len2; ++i){ if (!Curry._2(p, Caml_bytes.get(xs, i), Caml_bytes.get(prefix, i))) { - throw { - MEL_EXN_ID: H, - Error: new Error() - }; + throw new Error(H, { + cause: { + MEL_EXN_ID: H + } + }); } } @@ -151,7 +152,9 @@ function starts_with(xs, prefix, p) { if (exn.MEL_EXN_ID === H) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/ext_filename_test.js b/jscomp/test/dist/jscomp/test/ext_filename_test.js index c63fd0bab7..d0321ae4d1 100644 --- a/jscomp/test/dist/jscomp/test/ext_filename_test.js +++ b/jscomp/test/dist/jscomp/test/ext_filename_test.js @@ -96,7 +96,9 @@ function chop_extension(locOpt, name) { _1: "Filename.chop_extension ( %s : %s )" }), loc, name); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -109,7 +111,9 @@ function chop_extension_if_any(fname) { if (exn.MEL_EXN_ID === Stdlib.Invalid_argument) { return fname; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -394,11 +398,12 @@ if (Stdlib__Sys.unix) { simple_convert_node_path_to_os_path = Ext_string_test.replace_slash_backward; } else { var s = "Unknown OS : " + Stdlib__Sys.os_type; - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); } var $slash$slash = Stdlib__Filename.concat; diff --git a/jscomp/test/dist/jscomp/test/ext_list_test.js b/jscomp/test/dist/jscomp/test/ext_list_test.js index 056ba4ab43..59d0f4803d 100644 --- a/jscomp/test/dist/jscomp/test/ext_list_test.js +++ b/jscomp/test/dist/jscomp/test/ext_list_test.js @@ -205,20 +205,22 @@ function filter_map2(f, _xs, _ys) { _xs = us; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.filter_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.filter_map2" + } + }); } if (!ys) { return /* [] */0; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.filter_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.filter_map2" + } + }); }; } @@ -244,20 +246,22 @@ function filter_map2i(f, xs, ys) { _i = i + 1 | 0; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.filter_map2i", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.filter_map2i" + } + }); } if (!ys) { return /* [] */0; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.filter_map2i", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.filter_map2i" + } + }); }; }; return aux(0, xs, ys); @@ -294,18 +298,20 @@ function flat_map2(f, lx, ly) { _acc = Stdlib__List.rev_append(Curry._2(f, lx$1.hd, ly$1.hd), acc); continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.flat_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.flat_map2" + } + }); } if (ly$1) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.flat_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.flat_map2" + } + }); } return Stdlib__List.rev(acc); }; @@ -346,11 +352,12 @@ function map2_last(f, l1, l2) { } } else { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.map2_last", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.map2_last" + } + }); } } if (l2) { @@ -360,20 +367,22 @@ function map2_last(f, l1, l2) { tl: map2_last(f, l1$1, l2.tl) }; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.map2_last", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.map2_last" + } + }); } if (!l2) { return /* [] */0; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.map2_last", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.map2_last" + } + }); } function map_last(f, l1) { @@ -405,28 +414,31 @@ function fold_right2_last(f, l1, l2, accu) { } } else { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } } if (l2) { return Curry._4(f, false, last1, l2.hd, fold_right2_last(f, l1$1, l2.tl, accu)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } if (l2) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } return accu; } @@ -439,11 +451,12 @@ function take(n, l) { var arr = Stdlib__Array.of_list(l); var arr_length = arr.length; if (arr_length < n) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.take", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.take" + } + }); } return [ Stdlib__Array.to_list(Stdlib__Array.sub(arr, 0, n)), @@ -526,11 +539,12 @@ function exclude_tail(x) { }; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.exclude_tail", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.exclude_tail" + } + }); }; } @@ -579,21 +593,23 @@ function drop(_n, _h) { var h = _h; var n = _n; if (n < 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.drop", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.drop" + } + }); } if (n === 0) { return h; } if (Caml_obj.caml_equal(h, /* [] */0)) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.drop", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.drop" + } + }); } _h = Stdlib__List.tl(h); _n = n - 1 | 0; @@ -762,22 +778,24 @@ function reduce_from_right(fn, lst) { return Curry._2(fn, y, x); }), match.hd, match.tl); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.reduce", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.reduce" + } + }); } function reduce_from_left(fn, lst) { if (lst) { return Stdlib__List.fold_left(fn, lst.hd, lst.tl); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.reduce_from_left", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.reduce_from_left" + } + }); } function create_ref_empty(param) { @@ -791,11 +809,12 @@ function ref_top(x) { if (match) { return match.hd; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.ref_top", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.ref_top" + } + }); } function ref_empty(x) { @@ -820,11 +839,12 @@ function ref_pop(refs) { refs.contents = match.tl; return match.hd; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.ref_pop", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.ref_pop" + } + }); } function rev_except_last(xs) { @@ -848,11 +868,12 @@ function rev_except_last(xs) { }; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.rev_except_last", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.rev_except_last" + } + }); }; } @@ -872,11 +893,12 @@ function last(_xs) { _xs = xs.tl; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_list_test.last", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_list_test.last" + } + }); }; } @@ -894,15 +916,16 @@ function assoc_by_string(def, k, _lst) { if (def !== undefined) { return Caml_option.valFromOption(def); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ext_list_test.ml", - 399, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ext_list_test.ml", + 399, + 14 + ] + } + }); }; } @@ -920,15 +943,16 @@ function assoc_by_int(def, k, _lst) { if (def !== undefined) { return Caml_option.valFromOption(def); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ext_list_test.ml", - 409, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ext_list_test.ml", + 409, + 14 + ] + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/ext_pervasives_test.js b/jscomp/test/dist/jscomp/test/ext_pervasives_test.js index 536e6ca31e..0511a82604 100644 --- a/jscomp/test/dist/jscomp/test/ext_pervasives_test.js +++ b/jscomp/test/dist/jscomp/test/ext_pervasives_test.js @@ -16,7 +16,9 @@ function $$finally(v, action, f) { } catch (e$1){ Curry._1(action, v); - throw e$1; + throw new Error(e$1.MEL_EXN_ID, { + cause: e$1 + }); } Curry._1(action, v); return e; @@ -54,10 +56,11 @@ function is_pos_pow(n) { _c = c + 1 | 0; continue ; } - throw { - MEL_EXN_ID: E, - Error: new Error() - }; + throw new Error(E, { + cause: { + MEL_EXN_ID: E + } + }); }; } catch (raw_exn){ @@ -65,18 +68,21 @@ function is_pos_pow(n) { if (exn.MEL_EXN_ID === E) { return -1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } function failwithf(loc, fmt) { return Stdlib__Format.ksprintf((function (s) { var s$1 = loc + s; - throw { - MEL_EXN_ID: "Failure", - _1: s$1, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s$1 + } + }); }), fmt); } @@ -86,11 +92,12 @@ function invalid_argf(fmt) { function bad_argf(fmt) { return Stdlib__Format.ksprintf((function (x) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: x, - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: x + } + }); }), fmt); } diff --git a/jscomp/test/dist/jscomp/test/ext_string_test.js b/jscomp/test/dist/jscomp/test/ext_string_test.js index 838a21d560..6c93fad7b8 100644 --- a/jscomp/test/dist/jscomp/test/ext_string_test.js +++ b/jscomp/test/dist/jscomp/test/ext_string_test.js @@ -218,11 +218,12 @@ function unsafe_for_all_range(s, _start, finish, p) { function for_all_range(s, start, finish, p) { var len = s.length; if (start < 0 || finish >= len) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.for_all_range", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.for_all_range" + } + }); } return unsafe_for_all_range(s, start, finish, p); } @@ -273,10 +274,11 @@ function find(startOpt, sub, s) { try { while((i + n | 0) <= s_len) { if (unsafe_is_sub(sub, 0, s, i, n)) { - throw { - MEL_EXN_ID: Local_exit, - Error: new Error() - }; + throw new Error(Local_exit, { + cause: { + MEL_EXN_ID: Local_exit + } + }); } i = i + 1 | 0; }; @@ -287,7 +289,9 @@ function find(startOpt, sub, s) { if (exn.MEL_EXN_ID === Local_exit) { return i; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -298,11 +302,12 @@ function contain_substring(s, sub) { function non_overlap_count(sub, s) { var sub_len = sub.length; if (sub.length === 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.non_overlap_count", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.non_overlap_count" + } + }); } var _acc = 0; var _off = 0; @@ -325,10 +330,11 @@ function rfind(sub, s) { try { while(i >= 0) { if (unsafe_is_sub(sub, 0, s, i, n)) { - throw { - MEL_EXN_ID: Local_exit, - Error: new Error() - }; + throw new Error(Local_exit, { + cause: { + MEL_EXN_ID: Local_exit + } + }); } i = i - 1 | 0; }; @@ -339,7 +345,9 @@ function rfind(sub, s) { if (exn.MEL_EXN_ID === Local_exit) { return i; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -349,11 +357,12 @@ function tail_from(s, x) { return Stdlib__String.sub(s, x, len - x | 0); } var s$1 = "Ext_string_test.tail_from " + (s + (" : " + String(x))); - throw { - MEL_EXN_ID: "Invalid_argument", - _1: s$1, - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: s$1 + } + }); } function digits_of_str(s, offset, x) { @@ -568,11 +577,12 @@ function unsafe_no_char_idx(x, ch, _i, last_idx) { function no_char(x, ch, i, len) { var str_len = x.length; if (i < 0 || i >= str_len || len >= str_len) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ext_string_test.no_char", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ext_string_test.no_char" + } + }); } return unsafe_no_char(x, ch, i, len); } diff --git a/jscomp/test/dist/jscomp/test/extensible_variant_test.js b/jscomp/test/dist/jscomp/test/extensible_variant_test.js index f78aca15ca..d37cd21b4e 100644 --- a/jscomp/test/dist/jscomp/test/extensible_variant_test.js +++ b/jscomp/test/dist/jscomp/test/extensible_variant_test.js @@ -24,15 +24,16 @@ function to_int(x) { if (x.MEL_EXN_ID === Int$1) { return x._2; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/extensible_variant_test.ml", - 16, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/extensible_variant_test.ml", + 16, + 9 + ] + } + }); } var suites_0 = [ diff --git a/jscomp/test/dist/jscomp/test/flexible_array_test.js b/jscomp/test/dist/jscomp/test/flexible_array_test.js index cea6ccc9bb..819f90df23 100644 --- a/jscomp/test/dist/jscomp/test/flexible_array_test.js +++ b/jscomp/test/dist/jscomp/test/flexible_array_test.js @@ -25,10 +25,11 @@ function sub(_tr, _k) { _tr = tr._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -65,10 +66,11 @@ function update(tr, k, w) { _2: /* Lf */0 }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function $$delete(tr, n) { @@ -93,10 +95,11 @@ function $$delete(tr, n) { }; } } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function loext(tr, w) { @@ -128,20 +131,22 @@ function lorem(tr) { if (!tr._2) { return /* Lf */0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/flexible_array_test.ml", - 66, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/flexible_array_test.ml", + 66, + 9 + ] + } + }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var empty = [ @@ -157,11 +162,12 @@ function get(param, i) { if (i >= 0 && i < param[1]) { return sub(param[0], i + 1 | 0); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.get", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.get" + } + }); } function set(param, i, v) { @@ -172,11 +178,12 @@ function set(param, i, v) { k ]; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.set", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.set" + } + }); } function push_front(param, v) { @@ -194,11 +201,12 @@ function pop_front(param) { k - 1 | 0 ]; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.pop_front", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.pop_front" + } + }); } function push_back(param, v) { @@ -217,11 +225,12 @@ function pop_back(param) { k - 1 | 0 ]; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Array.pop_back", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Array.pop_back" + } + }); } function pp(fmt, s) { @@ -326,15 +335,16 @@ if (!Caml_obj.caml_equal(x, of_array([ 5, 6 ]))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/flexible_array_test.ml", - 166, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/flexible_array_test.ml", + 166, + 4 + ] + } + }); } var v = Stdlib__Array.init(500, (function (i) { diff --git a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js index cc74f1d7b7..9e8c8c6731 100644 --- a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js @@ -2133,10 +2133,11 @@ function eat(f) { todo: match.tl }; } - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } function start(str) { @@ -2186,10 +2187,11 @@ function parse_hex_symbol(f) { var match = f.todo; if (match) { if (match.hd !== 48) { - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } var match$1 = match.tl; if (match$1) { @@ -2198,22 +2200,25 @@ function parse_hex_symbol(f) { return eat(eat(f)); } if (match$2 !== 120) { - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } return eat(eat(f)); } - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } function parse_exponent(f) { @@ -2225,12 +2230,15 @@ function parse_exponent(f) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return { negative: f.negative, @@ -2276,10 +2284,11 @@ function parse_body(_f) { }; continue ; } - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } var ref_char_code; if (c >= /* '0' */48 && c <= /* '9' */57) { @@ -2289,10 +2298,11 @@ function parse_body(_f) { } else if (c >= /* 'a' */97 && c <= /* 'f' */102) { ref_char_code = 87; } else { - throw { - MEL_EXN_ID: No_good, - Error: new Error() - }; + throw new Error(No_good, { + cause: { + MEL_EXN_ID: No_good + } + }); } var value = c - ref_char_code | 0; var e = f.decimal_exponent; @@ -2319,15 +2329,16 @@ function float_of_string(str) { try { var f = parse_body(parse_hex_symbol(parse_sign(start(str)))); if (!Caml_obj.caml_equal(f.todo, /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "lexer_flow.mll", - 546, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "lexer_flow.mll", + 546, + 4 + ] + } + }); } var ret = f.mantissa; var decimal_exponent = f.decimal_exponent; @@ -2342,12 +2353,18 @@ function float_of_string(str) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === No_good) { - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } } @@ -2412,15 +2429,16 @@ function unicode_fix_cols(lb) { function oct_to_int(x) { if (x > 55 || x < 48) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "lexer_flow.mll", - 604, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "lexer_flow.mll", + 604, + 11 + ] + } + }); } return x - /* '0' */48 | 0; } @@ -2439,15 +2457,16 @@ function hexa_to_int(x) { } else if (!(x > 57 || x < 48)) { return x - /* '0' */48 | 0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "lexer_flow.mll", - 610, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "lexer_flow.mll", + 610, + 11 + ] + } + }); } function utf16to8(code) { @@ -3103,7 +3122,9 @@ function token(env, lexbuf) { /* T_IDENTIFIER */0 ]; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case 23 : return [ @@ -5155,7 +5176,9 @@ function type_token(env, lexbuf) { } ]; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return illegal_number(match$4[0], lexbuf, w$3, match$4[1]); @@ -5181,7 +5204,9 @@ function type_token(env, lexbuf) { } ]; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case 15 : var neg$8 = Stdlib__Lexing.sub_lexeme(lexbuf, lexbuf.lex_start_pos, Caml_array.get(lexbuf.lex_mem, 0)); @@ -5224,7 +5249,9 @@ function type_token(env, lexbuf) { /* T_IDENTIFIER */0 ]; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } case 22 : return [ @@ -5500,17 +5527,19 @@ function bal(l, v, r) { if (lr) { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -5530,17 +5559,19 @@ function bal(l, v, r) { if (rl) { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add(x, t) { @@ -5817,15 +5848,16 @@ function record_export(env, param) { function lookahead(iOpt, env) { var i = iOpt !== undefined ? iOpt : 0; if (i >= 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_env.ml", - 288, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_env.ml", + 288, + 2 + ] + } + }); } var t = env.lookahead.contents; lex_until(t, i); @@ -5833,11 +5865,12 @@ function lookahead(iOpt, env) { if (match !== undefined) { return match[1]; } - throw { - MEL_EXN_ID: "Failure", - _1: "Lookahead.peek failed", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Lookahead.peek failed" + } + }); } function with_strict(in_strict_mode, env) { @@ -5998,11 +6031,12 @@ function lex_env(iOpt, env) { if (match !== undefined) { return match[0]; } - throw { - MEL_EXN_ID: "Failure", - _1: "Lookahead.peek failed", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Lookahead.peek failed" + } + }); } function is_line_terminator(env) { @@ -6202,11 +6236,12 @@ function pop_lex_mode(env) { if (match) { new_stack = match.tl; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Popping lex mode from empty stack", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Popping lex mode from empty stack" + } + }); } env.lex_mode_stack.contents = new_stack; env.lookahead.contents = create$1(env.lex_env.contents, Stdlib__List.hd(env.lex_mode_stack.contents)); @@ -6220,18 +6255,20 @@ function double_pop_lex_mode(env) { if (match$1) { new_stack = match$1.tl; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Popping lex mode from empty stack", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Popping lex mode from empty stack" + } + }); } } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Popping lex mode from empty stack", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Popping lex mode from empty stack" + } + }); } env.lex_mode_stack.contents = new_stack; env.lookahead.contents = create$1(env.lex_env.contents, Stdlib__List.hd(env.lex_mode_stack.contents)); @@ -6335,7 +6372,9 @@ function to_parse(env, parse) { env.lookahead.contents = create$1(env.lex_env.contents, Stdlib__List.hd(env.lex_mode_stack.contents)); return /* FailedToParse */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -6395,17 +6434,19 @@ function bal$1(l, v, r) { if (lr) { return create$2(create$2(ll, lv, lr.l), lr.v, create$2(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -6425,17 +6466,19 @@ function bal$1(l, v, r) { if (rl) { return create$2(create$2(l, v, rl.l), rl.v, create$2(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$1(x, t) { @@ -6524,17 +6567,19 @@ function bal$2(l, x, d, r) { if (lr) { return create$3(create$3(ll, lv, ld, lr.l), lr.v, lr.d, create$3(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -6556,17 +6601,19 @@ function bal$2(l, x, d, r) { if (rl) { return create$3(create$3(l, x, d, rl.l), rl.v, rl.d, create$3(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$2(x, data, m) { @@ -6624,10 +6671,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -6677,17 +6725,19 @@ function bal$3(l, v, r) { if (lr) { return create$4(create$4(ll, lv, lr.l), lr.v, create$4(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -6707,17 +6757,19 @@ function bal$3(l, v, r) { if (rl) { return create$4(create$4(l, v, rl.l), rl.v, create$4(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$3(x, t) { @@ -7333,30 +7385,32 @@ function rev_nonempty_acc(acc) { if (acc) { end_loc = acc.hd[0]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 127, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 127, + 13 + ] + } + }); } var acc$1 = Stdlib__List.rev(acc); var start_loc; if (acc$1) { start_loc = acc$1.hd[0]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 131, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 131, + 13 + ] + } + }); } return [ btwn(start_loc, end_loc), @@ -7960,15 +8014,16 @@ function annotation(env) { if (loc !== undefined) { end_loc = loc; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 121, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 121, + 16 + ] + } + }); } return [ btwn(start_loc, end_loc), @@ -9027,7 +9082,9 @@ function number(env, number_type) { error$1(env, /* WindowsFloatOfString */59); value$1 = 789.0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } break; @@ -9160,15 +9217,16 @@ function primary$1(env) { var match$4 = Curry._2(Parser_env_Peek.token, undefined, env); var match$5; if (typeof match$4 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1699, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1699, + 15 + ] + } + }); } if (match$4.TAG === /* T_REGEXP */3) { var match$6 = match$4._0; @@ -9180,15 +9238,16 @@ function primary$1(env) { match$6[2] ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1699, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1699, + 15 + ] + } + }); } var raw_flags = match$5[2]; pop_lex_mode(env); @@ -9507,10 +9566,11 @@ function assignment_but_not_arrow_function(env) { } function error_callback(param, param$1) { - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } function try_assignment_but_not_arrow_function(env) { @@ -9520,27 +9580,30 @@ function try_assignment_but_not_arrow_function(env) { if (typeof match === "number") { if (match !== 10) { if (match === 77) { - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } } else { - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } } if (!Curry._2(Parser_env_Peek.is_identifier, undefined, env$1)) { return ret; } if (Curry._2(Parser_env_Peek.value, undefined, env$1) === "checks") { - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } var match$1 = ret[1]; if (typeof match$1 === "number") { @@ -9553,10 +9616,11 @@ function try_assignment_but_not_arrow_function(env) { return ret; } if (!Curry._1(Parser_env_Peek.is_line_terminator, env$1)) { - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } return ret; } @@ -10095,15 +10159,16 @@ function template_parts(env, _quasis, _expressions) { var match$1 = Curry._2(Parser_env_Peek.token, undefined, env); var match$2; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1602, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1602, + 19 + ] + } + }); } if (match$1.TAG === /* T_TEMPLATE_PART */2) { var match$3 = match$1._0; @@ -10122,15 +10187,16 @@ function template_parts(env, _quasis, _expressions) { tail ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1602, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1602, + 19 + ] + } + }); } var loc = match$2[0]; pop_lex_mode(env); @@ -10306,23 +10372,26 @@ function error_callback$1(param) { if (param === 47) { return ; } - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } if (param > 43 || param < 29) { return ; } - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); } - throw { - MEL_EXN_ID: Parser_env_Try.Rollback, - Error: new Error() - }; + throw new Error(Parser_env_Try.Rollback, { + cause: { + MEL_EXN_ID: Parser_env_Try.Rollback + } + }); }; } @@ -10543,15 +10612,16 @@ function _method(env, kind) { var params; switch (kind) { case /* Init */0 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 1954, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 1954, + 16 + ] + } + }); case /* Get */1 : params = /* [] */0; break; @@ -10899,11 +10969,12 @@ function check_property(env, prop_map, prop) { key = Stdlib.string_of_float(s._0); break; case /* RegExp */3 : - throw { - MEL_EXN_ID: "Failure", - _1: "RegExp cannot be property key", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "RegExp cannot be property key" + } + }); } } @@ -10912,15 +10983,16 @@ function check_property(env, prop_map, prop) { key = match$1._0[1].name; break; case /* Computed */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2103, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2103, + 30 + ] + } + }); } var prev_kinds; @@ -10932,7 +11004,9 @@ function check_property(env, prop_map, prop) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { prev_kinds = /* Empty */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var match$2 = prop$1.kind; @@ -11783,15 +11857,16 @@ function declare_export_declaration(allow_export_typeOpt, env) { } switch (exit$2) { case 3 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 3480, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 3480, + 17 + ] + } + }); case 4 : if (typeof token$5 === "number") { if (token$5 !== 25) { @@ -12419,11 +12494,12 @@ function fold(acc) { tl: acc }; case /* Expression */4 : - throw { - MEL_EXN_ID: "Failure", - _1: "Parser error: No such thing as an expression pattern!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Parser error: No such thing as an expression pattern!" + } + }); } }; @@ -14006,15 +14082,16 @@ function statement(env) { _0: init._0 }); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2573, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2573, + 22 + ] + } + }); } token$4(env, /* T_OF */60); var right = Curry._1(Parse.assignment, env); @@ -14045,15 +14122,16 @@ function statement(env) { _0: init._0 }); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parser_flow.ml", - 2556, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parser_flow.ml", + 2556, + 22 + ] + } + }); } token$4(env, /* T_IN */15); var right$1 = Curry._1(Parse.expression, env); @@ -14309,11 +14387,12 @@ function module_item(env) { var $$interface$1 = $$interface(env$1); var match$2 = $$interface$1[1]; if (typeof match$2 === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" + } + }); } if (match$2.TAG === /* InterfaceDeclaration */21) { record_export(env$1, [ @@ -14321,11 +14400,12 @@ function module_item(env) { extract_ident_name(match$2._0.id) ]); } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export interface` into something other than an interface declaration!" + } + }); } var end_loc = $$interface$1[0]; return [ @@ -14352,11 +14432,12 @@ function module_item(env) { var type_alias$1 = type_alias(env$1); var match$3 = type_alias$1[1]; if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" + } + }); } if (match$3.TAG === /* TypeAlias */7) { record_export(env$1, [ @@ -14364,11 +14445,12 @@ function module_item(env) { extract_ident_name(match$3._0.id) ]); } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Parsed `export type` into something other than a type alias!" + } + }); } var end_loc$1 = type_alias$1[0]; return [ @@ -14565,11 +14647,12 @@ function module_item(env) { var loc$4 = stmt[0]; var names; if (typeof match$8 === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Unexpected export statement declaration!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Unexpected export statement declaration!" + } + }); } switch (match$8.TAG | 0) { case /* FunctionDeclaration */18 : @@ -14619,11 +14702,12 @@ function module_item(env) { } break; default: - throw { - MEL_EXN_ID: "Failure", - _1: "Internal Flow Error! Unexpected export statement declaration!", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Internal Flow Error! Unexpected export statement declaration!" + } + }); } Stdlib__List.iter((function (param) { return record_export(env$1, param); @@ -15047,11 +15131,12 @@ function directives(env, term_fn, item_fn) { } } var s = "Nooo: " + (token_to_string(token) + "\n"); - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); }), Stdlib__List.rev(match[1])); return [ env$1, @@ -15414,11 +15499,12 @@ function program$1(failOpt, token_sinkOpt, parse_optionsOpt, content) { var ast = Curry._1(parser, env); var error_list = filter_duplicate_errors(env.errors.contents); if (fail && Caml_obj.caml_notequal(error_list, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error, - _1: error_list, - Error: new Error() - }; + throw new Error($$Error, { + cause: { + MEL_EXN_ID: $$Error, + _1: error_list + } + }); } return [ ast, @@ -15794,11 +15880,12 @@ function parse(content, options) { operator = "delete"; break; case /* Await */7 : - throw { - MEL_EXN_ID: "Failure", - _1: "matched above", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "matched above" + } + }); } return node("UnaryExpression", loc, [ @@ -17761,11 +17848,12 @@ function parse(content, options) { key = identifier(lit._0); break; case /* Computed */2 : - throw { - MEL_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "There should not be computed object type property keys" + } + }); } return node("ObjectTypeProperty", param[0], [ @@ -17846,7 +17934,9 @@ function parse(content, options) { throw(e); return {}; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -17885,15 +17975,16 @@ if (f !== undefined) { 2842 ], v.range); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "runParser.ml", - 15, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "runParser.ml", + 15, + 12 + ] + } + }); } Mt.from_pair_suites("Flow_parser_reg_test", suites.contents); diff --git a/jscomp/test/dist/jscomp/test/format_regression.js b/jscomp/test/dist/jscomp/test/format_regression.js index 7b7ac73916..73d7f893b9 100644 --- a/jscomp/test/dist/jscomp/test/format_regression.js +++ b/jscomp/test/dist/jscomp/test/format_regression.js @@ -4,51 +4,55 @@ var Curry = require("melange.js/curry.js"); function peek_queue(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/format_regression.ml", - 10, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/format_regression.ml", + 10, + 19 + ] + } + }); } function int_of_size(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/format_regression.ml", - 11, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/format_regression.ml", + 11, + 20 + ] + } + }); } function take_queue(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/format_regression.ml", - 12, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/format_regression.ml", + 12, + 19 + ] + } + }); } function format_pp_token(param, param$1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/format_regression.ml", - 13, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/format_regression.ml", + 13, + 26 + ] + } + }); } function advance_loop(state) { diff --git a/jscomp/test/dist/jscomp/test/fun_pattern_match.js b/jscomp/test/dist/jscomp/test/fun_pattern_match.js index d2aecb0eb4..d85b32bb2f 100644 --- a/jscomp/test/dist/jscomp/test/fun_pattern_match.js +++ b/jscomp/test/dist/jscomp/test/fun_pattern_match.js @@ -17,26 +17,28 @@ function f3(param) { return function (param) { var rhs = param.rank; if (typeof lhs === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/fun_pattern_match.ml", - 41, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/fun_pattern_match.ml", + 41, + 9 + ] + } + }); } if (typeof rhs === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/fun_pattern_match.ml", - 41, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/fun_pattern_match.ml", + 41, + 9 + ] + } + }); } return Caml.caml_int_compare(lhs._0, rhs._0); }; @@ -47,26 +49,28 @@ function f4(param) { return function (param) { var rhs = param.rank; if (typeof lhs === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/fun_pattern_match.ml", - 49, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/fun_pattern_match.ml", + 49, + 9 + ] + } + }); } if (typeof rhs === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/fun_pattern_match.ml", - 49, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/fun_pattern_match.ml", + 49, + 9 + ] + } + }); } return Caml.caml_int_compare(lhs._0, rhs._0); }; diff --git a/jscomp/test/dist/jscomp/test/gpr_1150.js b/jscomp/test/dist/jscomp/test/gpr_1150.js index aa8442b1cf..9aa3825cd7 100644 --- a/jscomp/test/dist/jscomp/test/gpr_1150.js +++ b/jscomp/test/dist/jscomp/test/gpr_1150.js @@ -215,15 +215,16 @@ function f(children) { ]; } if (children$15.tl) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_1150.ml", - 56, - 34 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_1150.ml", + 56, + 34 + ] + } + }); } return [ a0, diff --git a/jscomp/test/dist/jscomp/test/gpr_1245_test.js b/jscomp/test/dist/jscomp/test/gpr_1245_test.js index e26354cff2..17e3fac5ff 100644 --- a/jscomp/test/dist/jscomp/test/gpr_1245_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_1245_test.js @@ -48,7 +48,9 @@ function a1(f) { if (exn.MEL_EXN_ID === E) { return 1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/gpr_1698_test.js b/jscomp/test/dist/jscomp/test/gpr_1698_test.js index 0d2fad1329..4f73d3ffe1 100644 --- a/jscomp/test/dist/jscomp/test/gpr_1698_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_1698_test.js @@ -49,15 +49,16 @@ function compare(context, state, _a, _b) { exit$2 = 4; break; case /* Frac */4 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_1698_test.ml", - 45, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_1698_test.ml", + 45, + 10 + ] + } + }); case /* Pow */3 : case /* Gcd */5 : exit = 1; @@ -75,15 +76,16 @@ function compare(context, state, _a, _b) { case /* Frac */4 : switch (b.TAG | 0) { case /* Val */0 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_1698_test.ml", - 45, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_1698_test.ml", + 45, + 10 + ] + } + }); case /* Neg */1 : exit$3 = 5; break; diff --git a/jscomp/test/dist/jscomp/test/gpr_1701_test.js b/jscomp/test/dist/jscomp/test/gpr_1701_test.js index 43228a2b68..6cf94183b3 100644 --- a/jscomp/test/dist/jscomp/test/gpr_1701_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_1701_test.js @@ -10,10 +10,11 @@ var Foo = /* @__PURE__ */Caml_exceptions.create("Gpr_1701_test.Foo"); function test(n) { if (n === 0) { - throw { - MEL_EXN_ID: Foo, - Error: new Error() - }; + throw new Error(Foo, { + cause: { + MEL_EXN_ID: Foo + } + }); } try { return test(n - 1 | 0); @@ -23,7 +24,9 @@ function test(n) { if (exn.MEL_EXN_ID === Foo) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -42,7 +45,9 @@ function read_lines(inc) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { l = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (l === undefined) { @@ -69,7 +74,9 @@ function read_lines2(inc) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { return Stdlib__List.rev(acc); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } _acc = { hd: l, @@ -93,7 +100,9 @@ function read_lines3(inc) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { return Stdlib__List.rev(acc); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return loop(/* [] */0); diff --git a/jscomp/test/dist/jscomp/test/gpr_2316_test.js b/jscomp/test/dist/jscomp/test/gpr_2316_test.js index f3b1cf0c63..33ce4e4b9c 100644 --- a/jscomp/test/dist/jscomp/test/gpr_2316_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_2316_test.js @@ -33,18 +33,21 @@ function eq(loc, x, y) { var y; try { - throw { - MEL_EXN_ID: "Failure", - _1: "boo", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "boo" + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Failure) { y = exn._1; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -53,18 +56,21 @@ var x; var exit = 0; try { - throw { - MEL_EXN_ID: "Failure", - _1: "boo", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "boo" + } + }); } catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Failure) { x = exn$1._1; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } diff --git a/jscomp/test/dist/jscomp/test/gpr_2474.js b/jscomp/test/dist/jscomp/test/gpr_2474.js index ef304beb83..b64fa239c4 100644 --- a/jscomp/test/dist/jscomp/test/gpr_2474.js +++ b/jscomp/test/dist/jscomp/test/gpr_2474.js @@ -2,15 +2,16 @@ 'use strict'; -throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "gpr_2474.ml", - 6, - 4 - ], - Error: new Error() - }; +throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "gpr_2474.ml", + 6, + 4 + ] + } + }); exports.coordinates = coordinates; /* Not a pure module */ diff --git a/jscomp/test/dist/jscomp/test/gpr_2682_test.js b/jscomp/test/dist/jscomp/test/gpr_2682_test.js index 9ba777bdbe..c87ea3a28d 100644 --- a/jscomp/test/dist/jscomp/test/gpr_2682_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_2682_test.js @@ -49,15 +49,16 @@ var f3 = (()=>true var bbbb = f3(); if (!bbbb) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_2682_test.ml", - 59, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_2682_test.ml", + 59, + 2 + ] + } + }); } exports.sum = sum; diff --git a/jscomp/test/dist/jscomp/test/gpr_3595_test.js b/jscomp/test/dist/jscomp/test/gpr_3595_test.js index 4205e18bfa..95d294d256 100644 --- a/jscomp/test/dist/jscomp/test/gpr_3595_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_3595_test.js @@ -18,15 +18,16 @@ function eq(loc, x, y) { var match = [1]; if (match.length !== 1) { - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "gpr_3595_test.ml", - 9, - 4 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "gpr_3595_test.ml", + 9, + 4 + ] + } + }); } var a = match[0]; diff --git a/jscomp/test/dist/jscomp/test/gpr_3877_test.js b/jscomp/test/dist/jscomp/test/gpr_3877_test.js index 0aa308a67b..854da596e5 100644 --- a/jscomp/test/dist/jscomp/test/gpr_3877_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_3877_test.js @@ -21,27 +21,29 @@ var a = "good response"; var b = "bad response"; if (a !== "good response") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_3877_test.ml", - 14, - 3 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_3877_test.ml", + 14, + 3 + ] + } + }); } if (b !== "bad response") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_3877_test.ml", - 15, - 3 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_3877_test.ml", + 15, + 3 + ] + } + }); } exports.test = test; diff --git a/jscomp/test/dist/jscomp/test/gpr_3980_test.js b/jscomp/test/dist/jscomp/test/gpr_3980_test.js index 8050e5ea3e..540b4ccf1f 100644 --- a/jscomp/test/dist/jscomp/test/gpr_3980_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_3980_test.js @@ -7,42 +7,45 @@ var match = 1; if (match !== undefined) { if (match !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_3980_test.ml", - 16, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_3980_test.ml", + 16, + 10 + ] + } + }); } var match$1 = 1; if (match$1 !== 1) { if (match$1 !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_3980_test.ml", - 14, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_3980_test.ml", + 14, + 12 + ] + } + }); } Js__Js_math.floor_int(1); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_3980_test.ml", - 16, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_3980_test.ml", + 16, + 10 + ] + } + }); } /* Not a pure module */ diff --git a/jscomp/test/dist/jscomp/test/gpr_405_test.js b/jscomp/test/dist/jscomp/test/gpr_405_test.js index 8422cb729d..768bebea81 100644 --- a/jscomp/test/dist/jscomp/test/gpr_405_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_405_test.js @@ -22,7 +22,9 @@ function Make(funarg) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var min_cutset = function (gr, first_node) { @@ -38,26 +40,28 @@ function Make(funarg) { }; var step2 = function (top, rest_of_stack) { if (find_default(already_processed, top)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_405_test.ml", - 43, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_405_test.ml", + 43, + 6 + ] + } + }); } if (find_default(on_the_stack, top)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_405_test.ml", - 44, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_405_test.ml", + 44, + 6 + ] + } + }); } Curry._3(H.add, on_the_stack, top, true); Curry._3(H.add, n_labels, top, counter.contents); @@ -95,11 +99,12 @@ function Make(funarg) { Curry._3(H.add, l_labels, top$1, 0); } if (Curry._2(H.find, l_labels, top$1) > Curry._2(H.find, n_labels, top$1)) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "Graph.Mincut: graph not reducible", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "Graph.Mincut: graph not reducible" + } + }); } if (!rest_of_stack$1) { return cut_set.contents; diff --git a/jscomp/test/dist/jscomp/test/gpr_4632.js b/jscomp/test/dist/jscomp/test/gpr_4632.js index 9c9b6fdcd0..9640deb3b1 100644 --- a/jscomp/test/dist/jscomp/test/gpr_4632.js +++ b/jscomp/test/dist/jscomp/test/gpr_4632.js @@ -21,15 +21,16 @@ var T0 = { tail: T0_tail }; -throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "gpr_4632.ml", - 12, - 6 - ], - Error: new Error() - }; +throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "gpr_4632.ml", + 12, + 6 + ] + } + }); exports.T0 = T0; exports.T1 = T1; diff --git a/jscomp/test/dist/jscomp/test/gpr_858_unit2_test.js b/jscomp/test/dist/jscomp/test/gpr_858_unit2_test.js index bff7f2eb66..20f8a94400 100644 --- a/jscomp/test/dist/jscomp/test/gpr_858_unit2_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_858_unit2_test.js @@ -23,15 +23,16 @@ for(var i = 1; i <= 2; ++i){ if (i === n) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_858_unit2_test.ml", - 6, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_858_unit2_test.ml", + 6, + 13 + ] + } + }); } }(i)); f(0, i); diff --git a/jscomp/test/dist/jscomp/test/gpr_974_test.js b/jscomp/test/dist/jscomp/test/gpr_974_test.js index 08bff99985..86c0253a6e 100644 --- a/jscomp/test/dist/jscomp/test/gpr_974_test.js +++ b/jscomp/test/dist/jscomp/test/gpr_974_test.js @@ -5,39 +5,42 @@ var Caml_obj = require("melange.js/caml_obj.js"); var Caml_option = require("melange.js/caml_option.js"); if (!Caml_obj.caml_equal(Caml_option.nullable_to_opt(""), "")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_974_test.ml", - 3, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_974_test.ml", + 3, + 4 + ] + } + }); } if (!Caml_obj.caml_equal(Caml_option.undefined_to_opt(""), "")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_974_test.ml", - 4, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_974_test.ml", + 4, + 4 + ] + } + }); } if (!Caml_obj.caml_equal(Caml_option.null_to_opt(""), "")) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/gpr_974_test.ml", - 5, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/gpr_974_test.ml", + 5, + 4 + ] + } + }); } /* Not a pure module */ diff --git a/jscomp/test/dist/jscomp/test/imm_map_bench.js b/jscomp/test/dist/jscomp/test/imm_map_bench.js index 71451ee5bb..dc22f51037 100644 --- a/jscomp/test/dist/jscomp/test/imm_map_bench.js +++ b/jscomp/test/dist/jscomp/test/imm_map_bench.js @@ -20,7 +20,9 @@ function should(b) { if (b) { return ; } - throw new Error("impossible"); + throw new Error(new Error("impossible").MEL_EXN_ID, { + cause: new Error("impossible") + }); } var shuffledDataAdd = Belt__Belt_Array.makeByAndShuffle(1000001, (function (i) { diff --git a/jscomp/test/dist/jscomp/test/inline_map2_test.js b/jscomp/test/dist/jscomp/test/inline_map2_test.js index cf5cfc3452..59d8f65a84 100644 --- a/jscomp/test/dist/jscomp/test/inline_map2_test.js +++ b/jscomp/test/dist/jscomp/test/inline_map2_test.js @@ -51,17 +51,19 @@ function Make(Ord) { if (lr) { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -83,17 +85,19 @@ function Make(Ord) { if (rl) { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; - } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); + } + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); }; var is_empty = function (param) { if (param) { @@ -142,10 +146,11 @@ function Make(Ord) { _param = c < 0 ? param._0 : param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var mem = function (x, _param) { @@ -176,10 +181,11 @@ function Make(Ord) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var max_binding = function (_param) { @@ -195,10 +201,11 @@ function Make(Ord) { _param = param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var remove_min_binding = function (param) { @@ -210,11 +217,12 @@ function Make(Ord) { return param._3; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); }; var remove = function (x, param) { if (!param) { @@ -426,15 +434,16 @@ function Make(Ord) { var match$1 = split(v2, s1); return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_map2_test.ml", - 270, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_map2_test.ml", + 270, + 10 + ] + } + }); }; var filter = function (p, param) { if (!param) { @@ -664,17 +673,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; - } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); + } + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -696,17 +707,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -758,10 +771,11 @@ function find(x, _param) { _param = c < 0 ? param._0 : param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -794,10 +808,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -814,10 +829,11 @@ function max_binding(_param) { _param = param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -830,11 +846,12 @@ function remove_min_binding(param) { return param._3; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function remove(x, param) { @@ -1060,15 +1077,16 @@ function merge(f, s1, s2) { var match$1 = split(v2, s1); return concat_or_join(merge(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_map2_test.ml", - 270, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_map2_test.ml", + 270, + 10 + ] + } + }); } function filter(p, param) { @@ -1334,17 +1352,19 @@ function bal$1(l, x, d, r) { if (lr) { return create$1(create$1(ll, lv, ld, lr._0), lr._1, lr._2, create$1(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; - } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); + } + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -1366,17 +1386,19 @@ function bal$1(l, x, d, r) { if (rl) { return create$1(create$1(l, x, d, rl._0), rl._1, rl._2, create$1(rl._3, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty$1(param) { @@ -1428,10 +1450,11 @@ function find$1(x, _param) { _param = c < 0 ? param._0 : param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1464,10 +1487,11 @@ function min_binding$1(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1484,10 +1508,11 @@ function max_binding$1(_param) { _param = param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1500,11 +1525,12 @@ function remove_min_binding$1(param) { return param._3; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function remove$1(x, param) { @@ -1730,15 +1756,16 @@ function merge$1(f, s1, s2) { var match$1 = split$1(v2, s1); return concat_or_join$1(merge$1(f, match$1[0], s2._0), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2._2)), merge$1(f, match$1[2], s2._3)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_map2_test.ml", - 270, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_map2_test.ml", + 270, + 10 + ] + } + }); } function filter$1(p, param) { diff --git a/jscomp/test/dist/jscomp/test/inline_map_test.js b/jscomp/test/dist/jscomp/test/inline_map_test.js index 65c3e1f080..fa7b8dc177 100644 --- a/jscomp/test/dist/jscomp/test/inline_map_test.js +++ b/jscomp/test/dist/jscomp/test/inline_map_test.js @@ -41,17 +41,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr._0), lr._1, lr._2, create(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -73,17 +75,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl._0), rl._1, rl._2, create(rl._3, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, param) { @@ -127,10 +131,11 @@ function find(x, _param) { _param = c < 0 ? param._0 : param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/inline_record_test.js b/jscomp/test/dist/jscomp/test/inline_record_test.js index 2c0ea949b2..af959a6eb0 100644 --- a/jscomp/test/dist/jscomp/test/inline_record_test.js +++ b/jscomp/test/dist/jscomp/test/inline_record_test.js @@ -67,15 +67,16 @@ var tmp; if (A0 === A0) { tmp = 3; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_record_test.ml", - 46, - 54 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_record_test.ml", + 46, + 54 + ] + } + }); } eq("File \"jscomp/test/inline_record_test.ml\", line 46, characters 6-13", tmp, 3); @@ -110,15 +111,16 @@ var tmp$1; if (v4.TAG === /* A0 */0) { tmp$1 = v4.x; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_record_test.ml", - 64, - 48 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_record_test.ml", + 64, + 48 + ] + } + }); } eq("File \"jscomp/test/inline_record_test.ml\", line 64, characters 6-13", tmp$1, 11); @@ -126,15 +128,16 @@ eq("File \"jscomp/test/inline_record_test.ml\", line 64, characters 6-13", tmp$1 var tmp$2; if (v5.TAG === /* A0 */0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_record_test.ml", - 66, - 48 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_record_test.ml", + 66, + 48 + ] + } + }); } tmp$2 = v5.z; @@ -168,15 +171,16 @@ var tmp$3; if (v6.MEL_EXN_ID === A4) { tmp$3 = v6.x; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/inline_record_test.ml", - 82, - 49 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/inline_record_test.ml", + 82, + 49 + ] + } + }); } eq("File \"jscomp/test/inline_record_test.ml\", line 82, characters 6-13", tmp$3, 11); diff --git a/jscomp/test/dist/jscomp/test/int64_string_test.js b/jscomp/test/dist/jscomp/test/int64_string_test.js index b2eb62ea27..d23778a8af 100644 --- a/jscomp/test/dist/jscomp/test/int64_string_test.js +++ b/jscomp/test/dist/jscomp/test/int64_string_test.js @@ -1308,28 +1308,30 @@ var random_data = { Belt__Belt_List.forEach(random_data, (function (u) { if (u) { if (u.tl) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/int64_string_test.ml", - 161, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/int64_string_test.ml", + 161, + 9 + ] + } + }); } var match = u.hd; return eq("File \"jscomp/test/int64_string_test.ml\", line 160, characters 21-28", Caml_format.caml_int64_format("%d", match[0]), match[1]); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/int64_string_test.ml", - 161, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/int64_string_test.ml", + 161, + 9 + ] + } + }); })); eq("File \"jscomp/test/int64_string_test.ml\", line 164, characters 7-14", Caml_format.caml_int64_format("%d", [ diff --git a/jscomp/test/dist/jscomp/test/int_map.js b/jscomp/test/dist/jscomp/test/int_map.js index 094d5ff6fe..400e7a7841 100644 --- a/jscomp/test/dist/jscomp/test/int_map.js +++ b/jscomp/test/dist/jscomp/test/int_map.js @@ -59,17 +59,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -91,17 +93,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -167,10 +171,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -207,10 +212,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -284,10 +290,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -372,10 +379,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -410,10 +418,11 @@ function max_binding(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -443,11 +452,12 @@ function remove_min_binding(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge(t1, t2) { @@ -758,15 +768,16 @@ function merge$1(f, s1, s2) { var match$1 = split(v2, s1); return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union(f, s1, s2) { diff --git a/jscomp/test/dist/jscomp/test/internal_unused_test.js b/jscomp/test/dist/jscomp/test/internal_unused_test.js index e704a15466..792756c85f 100644 --- a/jscomp/test/dist/jscomp/test/internal_unused_test.js +++ b/jscomp/test/dist/jscomp/test/internal_unused_test.js @@ -8,10 +8,11 @@ console.log(3); var A = /* @__PURE__ */Caml_exceptions.create("Internal_unused_test.P1.A"); function f(param) { - throw { - MEL_EXN_ID: A, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A + } + }); } var c = 5; diff --git a/jscomp/test/dist/jscomp/test/js_exception_catch_test.js b/jscomp/test/dist/jscomp/test/js_exception_catch_test.js index 8842a81543..4eb5c30ea4 100644 --- a/jscomp/test/dist/jscomp/test/js_exception_catch_test.js +++ b/jscomp/test/dist/jscomp/test/js_exception_catch_test.js @@ -74,7 +74,9 @@ catch (raw_exn){ }; })); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -135,79 +137,90 @@ eq("File \"jscomp/test/js_exception_catch_test.ml\", line 43, characters 5-12", }), "No_error"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 44, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }), "Not_found"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 45, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "x", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "x" + } + }); }), "Invalid_argument"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 46, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "" + } + }); }), "Invalid_any"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 47, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: A, - _1: 2, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A, + _1: 2 + } + }); }), "A2"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 48, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: A, - _1: 3, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A, + _1: 3 + } + }); }), "A_any"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 49, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: B, - Error: new Error() - }; + throw new Error(B, { + cause: { + MEL_EXN_ID: B + } + }); }), "B"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 50, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: C, - _1: 1, - _2: 2, - Error: new Error() - }; + throw new Error(C, { + cause: { + MEL_EXN_ID: C, + _1: 1, + _2: 2 + } + }); }), "C"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 51, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: C, - _1: 0, - _2: 2, - Error: new Error() - }; + throw new Error(C, { + cause: { + MEL_EXN_ID: C, + _1: 0, + _2: 2 + } + }); }), "C_any"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 52, characters 5-12", test(function (param) { - throw new Error("x"); + throw new Error(new Error("x").MEL_EXN_ID, { + cause: new Error("x") + }); }), "Js_error"); eq("File \"jscomp/test/js_exception_catch_test.ml\", line 53, characters 5-12", test(function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "x", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "x" + } + }); }), "Any"); Mt.from_pair_suites("Js_exception_catch_test", suites.contents); diff --git a/jscomp/test/dist/jscomp/test/js_json_test.js b/jscomp/test/dist/jscomp/test/js_json_test.js index 61f8fe1868..901d09498d 100644 --- a/jscomp/test/dist/jscomp/test/js_json_test.js +++ b/jscomp/test/dist/jscomp/test/js_json_test.js @@ -97,28 +97,30 @@ add_test("File \"jscomp/test/js_json_test.ml\", line 24, characters 11-18", (fun ty2._0.forEach(function (x) { var ty3 = Js__Js_json.classify(x); if (typeof ty3 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_json_test.ml", - 38, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_json_test.ml", + 38, + 21 + ] + } + }); } if (ty3.TAG === /* JSONNumber */1) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_json_test.ml", - 38, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_json_test.ml", + 38, + 21 + ] + } + }); }); return { TAG: /* Ok */4, @@ -258,15 +260,16 @@ function option_get(param) { if (param !== undefined) { return Caml_option.valFromOption(param); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_json_test.ml", - 103, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_json_test.ml", + 103, + 36 + ] + } + }); } var dict = {}; diff --git a/jscomp/test/dist/jscomp/test/js_promise_basic_test.js b/jscomp/test/dist/jscomp/test/js_promise_basic_test.js index a1c913b20b..5c85e62f49 100644 --- a/jscomp/test/dist/jscomp/test/js_promise_basic_test.js +++ b/jscomp/test/dist/jscomp/test/js_promise_basic_test.js @@ -37,23 +37,25 @@ function assert_bool(b) { if (b) { return ; } - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "Assertion Failure.", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "Assertion Failure." + } + }); } function fail(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_promise_basic_test.ml", - 17, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_promise_basic_test.ml", + 17, + 2 + ] + } + }); } function thenTest(param) { @@ -79,15 +81,16 @@ function assertIsNotFound(x) { if (match !== undefined) { return h; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_promise_basic_test.ml", - 34, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_promise_basic_test.ml", + 34, + 9 + ] + } + }); } function catchTest(param) { @@ -150,15 +153,16 @@ function orElseRejectedRejectTest(param) { if (match !== undefined) { return h; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/js_promise_basic_test.ml", - 76, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/js_promise_basic_test.ml", + 76, + 19 + ] + } + }); }); } diff --git a/jscomp/test/dist/jscomp/test/large_obj_test.js b/jscomp/test/dist/jscomp/test/large_obj_test.js index 5f520b1937..8a279a6add 100644 --- a/jscomp/test/dist/jscomp/test/large_obj_test.js +++ b/jscomp/test/dist/jscomp/test/large_obj_test.js @@ -591,15 +591,16 @@ CamlinternalOO.init_class($$class); var raw_object = obj_init(undefined); if (Caml_oo_curry.js1(291536124, 1, raw_object) !== 34) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/large_obj_test.ml", - 124, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/large_obj_test.ml", + 124, + 10 + ] + } + }); } function raw_class_init($$class) { @@ -917,15 +918,16 @@ var raw_class = CamlinternalOO.make_class(shared$2, raw_class_init); var v = Curry._2(raw_class[0], undefined, 3); if (Caml_oo_curry.js1(291536121, 2, v) !== 56) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/large_obj_test.ml", - 251, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/large_obj_test.ml", + 251, + 2 + ] + } + }); } exports.raw_object = raw_object; diff --git a/jscomp/test/dist/jscomp/test/lazy_test.js b/jscomp/test/dist/jscomp/test/lazy_test.js index 6fbab68007..2c46d75301 100644 --- a/jscomp/test/dist/jscomp/test/lazy_test.js +++ b/jscomp/test/dist/jscomp/test/lazy_test.js @@ -39,15 +39,16 @@ function f(param) { if (x !== undefined) { return 1; } - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "lazy_test.ml", - 9, - 8 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "lazy_test.ml", + 9, + 8 + ] + } + }); } var s = { @@ -82,7 +83,9 @@ catch (raw_exn){ if (exn.MEL_EXN_ID === Stdlib.Match_failure) { h = 2; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -134,10 +137,11 @@ var f006 = { var f007 = { LAZY_DONE: false, VAL: (function () { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }) }; @@ -145,10 +149,11 @@ var f008 = { LAZY_DONE: false, VAL: (function () { console.log("hi"); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }) }; @@ -331,10 +336,11 @@ Mt.from_pair_suites("Lazy_test", { _0: !Stdlib__Lazy.is_val({ LAZY_DONE: false, VAL: (function () { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }) }) }; diff --git a/jscomp/test/dist/jscomp/test/lexer_test.js b/jscomp/test/dist/jscomp/test/lexer_test.js index baaed6d635..276ff2a192 100644 --- a/jscomp/test/dist/jscomp/test/lexer_test.js +++ b/jscomp/test/dist/jscomp/test/lexer_test.js @@ -43,10 +43,11 @@ function from_tokens(lst) { l.contents = match.tl; return match.hd; } - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/libqueue_test.js b/jscomp/test/dist/jscomp/test/libqueue_test.js index f6818df143..98d7150a13 100644 --- a/jscomp/test/dist/jscomp/test/libqueue_test.js +++ b/jscomp/test/dist/jscomp/test/libqueue_test.js @@ -50,7 +50,9 @@ function does_raise(f, q) { if (exn.MEL_EXN_ID === Stdlib__Queue.Empty) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -61,15 +63,16 @@ var q = { }; if (!(Caml_obj.caml_equal(to_list(q), /* [] */0) && q.length === 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 28, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 28, + 25 + ] + } + }); } Stdlib__Queue.add(1, q); @@ -78,15 +81,16 @@ if (!(Caml_obj.caml_equal(to_list(q), { hd: 1, tl: /* [] */0 }) && q.length === 1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 29, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 29, + 25 + ] + } + }); } Stdlib__Queue.add(2, q); @@ -98,15 +102,16 @@ if (!(Caml_obj.caml_equal(to_list(q), { tl: /* [] */0 } }) && q.length === 2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 30, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 30, + 25 + ] + } + }); } Stdlib__Queue.add(3, q); @@ -121,15 +126,16 @@ if (!(Caml_obj.caml_equal(to_list(q), { } } }) && q.length === 3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 31, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 31, + 25 + ] + } + }); } Stdlib__Queue.add(4, q); @@ -147,27 +153,29 @@ if (!(Caml_obj.caml_equal(to_list(q), { } } }) && q.length === 4)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 32, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 32, + 25 + ] + } + }); } if (Stdlib__Queue.take(q) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 33, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 33, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(to_list(q), { @@ -180,27 +188,29 @@ if (!(Caml_obj.caml_equal(to_list(q), { } } }) && q.length === 3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 33, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 33, + 25 + ] + } + }); } if (Stdlib__Queue.take(q) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 34, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 34, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(to_list(q), { @@ -210,78 +220,84 @@ if (!(Caml_obj.caml_equal(to_list(q), { tl: /* [] */0 } }) && q.length === 2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 34, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 34, + 25 + ] + } + }); } if (Stdlib__Queue.take(q) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 35, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 35, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(to_list(q), { hd: 4, tl: /* [] */0 }) && q.length === 1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 35, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 35, + 25 + ] + } + }); } if (Stdlib__Queue.take(q) !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 36, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 36, + 2 + ] + } + }); } if (!(Caml_obj.caml_equal(to_list(q), /* [] */0) && q.length === 0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 36, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 36, + 25 + ] + } + }); } if (!does_raise(Stdlib__Queue.take, q)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 37, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 37, + 2 + ] + } + }); } var q$1 = { @@ -293,65 +309,70 @@ var q$1 = { Stdlib__Queue.add(1, q$1); if (Stdlib__Queue.take(q$1) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 42, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 42, + 13 + ] + } + }); } if (!does_raise(Stdlib__Queue.take, q$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 42, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 42, + 36 + ] + } + }); } Stdlib__Queue.add(2, q$1); if (Stdlib__Queue.take(q$1) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 43, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 43, + 13 + ] + } + }); } if (!does_raise(Stdlib__Queue.take, q$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 43, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 43, + 36 + ] + } + }); } if (q$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 44, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 44, + 2 + ] + } + }); } var q$2 = { @@ -363,139 +384,150 @@ var q$2 = { Stdlib__Queue.add(1, q$2); if (Stdlib__Queue.peek(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 49, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 49, + 13 + ] + } + }); } Stdlib__Queue.add(2, q$2); if (Stdlib__Queue.peek(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 50, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 50, + 13 + ] + } + }); } Stdlib__Queue.add(3, q$2); if (Stdlib__Queue.peek(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 51, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 51, + 13 + ] + } + }); } if (Stdlib__Queue.peek(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 52, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 52, + 2 + ] + } + }); } if (Stdlib__Queue.take(q$2) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 52, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 52, + 25 + ] + } + }); } if (Stdlib__Queue.peek(q$2) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 53, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 53, + 2 + ] + } + }); } if (Stdlib__Queue.take(q$2) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 53, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 53, + 25 + ] + } + }); } if (Stdlib__Queue.peek(q$2) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 54, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 54, + 2 + ] + } + }); } if (Stdlib__Queue.take(q$2) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 54, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 54, + 25 + ] + } + }); } if (!does_raise(Stdlib__Queue.peek, q$2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 55, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 55, + 2 + ] + } + }); } if (!does_raise(Stdlib__Queue.peek, q$2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 56, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 56, + 2 + ] + } + }); } var q$3 = { @@ -511,27 +543,29 @@ for(var i = 1; i <= 10; ++i){ Stdlib__Queue.clear(q$3); if (q$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 63, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 63, + 2 + ] + } + }); } if (!does_raise(Stdlib__Queue.take, q$3)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 64, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 64, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(q$3, { @@ -539,29 +573,31 @@ if (!Caml_obj.caml_equal(q$3, { first: /* Nil */0, last: /* Nil */0 })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 65, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 65, + 2 + ] + } + }); } Stdlib__Queue.add(42, q$3); if (Stdlib__Queue.take(q$3) !== 42) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 67, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 67, + 2 + ] + } + }); } var q1 = { @@ -607,15 +643,16 @@ if (!Caml_obj.caml_equal(to_list(q1), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 74, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 74, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2), { @@ -649,67 +686,72 @@ if (!Caml_obj.caml_equal(to_list(q2), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 75, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 75, + 2 + ] + } + }); } if (q1.length !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 76, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 76, + 2 + ] + } + }); } if (q2.length !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 77, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 77, + 2 + ] + } + }); } for(var i$2 = 1; i$2 <= 10; ++i$2){ if (Stdlib__Queue.take(q1) !== i$2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 79, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 79, + 4 + ] + } + }); } } for(var i$3 = 1; i$3 <= 10; ++i$3){ if (Stdlib__Queue.take(q2) !== i$3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 82, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 82, + 4 + ] + } + }); } } @@ -721,92 +763,99 @@ var q$4 = { }; if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 88, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 88, + 2 + ] + } + }); } for(var i$4 = 1; i$4 <= 10; ++i$4){ Stdlib__Queue.add(i$4, q$4); if (q$4.length !== i$4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 91, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 91, + 4 + ] + } + }); } if (q$4.length === 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 92, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 92, + 4 + ] + } + }); } } for(var i$5 = 10; i$5 >= 1; --i$5){ if (q$4.length !== i$5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 95, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 95, + 4 + ] + } + }); } if (q$4.length === 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 96, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 96, + 4 + ] + } + }); } Stdlib__Queue.take(q$4); } if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 99, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 99, + 2 + ] + } + }); } if (q$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 100, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 100, + 2 + ] + } + }); } var q$5 = { @@ -825,15 +874,16 @@ var i$7 = { Stdlib__Queue.iter((function (j) { if (i$7.contents !== j) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 107, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 107, + 19 + ] + } + }); } i$7.contents = i$7.contents + 1 | 0; }), q$5); @@ -851,101 +901,109 @@ var q2$1 = { }; if (q1$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 112, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 112, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$1), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 112, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 112, + 28 + ] + } + }); } if (q2$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 113, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 113, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$1), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 113, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 113, + 28 + ] + } + }); } Stdlib__Queue.transfer(q1$1, q2$1); if (q1$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 115, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 115, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$1), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 115, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 115, + 28 + ] + } + }); } if (q2$1.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 116, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 116, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$1), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 116, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 116, + 28 + ] + } + }); } var q1$2 = { @@ -965,15 +1023,16 @@ for(var i$8 = 1; i$8 <= 4; ++i$8){ } if (q1$2.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 122, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 122, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$2), { @@ -989,77 +1048,83 @@ if (!Caml_obj.caml_equal(to_list(q1$2), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 122, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 122, + 28 + ] + } + }); } if (q2$2.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 123, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 123, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$2), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 123, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 123, + 28 + ] + } + }); } Stdlib__Queue.transfer(q1$2, q2$2); if (q1$2.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 125, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 125, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$2), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 125, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 125, + 28 + ] + } + }); } if (q2$2.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 126, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 126, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$2), { @@ -1075,15 +1140,16 @@ if (!Caml_obj.caml_equal(to_list(q2$2), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 126, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 126, + 28 + ] + } + }); } var q1$3 = { @@ -1103,39 +1169,42 @@ for(var i$9 = 5; i$9 <= 8; ++i$9){ } if (q1$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 132, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 132, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$3), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 132, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 132, + 28 + ] + } + }); } if (q2$3.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 133, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 133, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$3), { @@ -1151,53 +1220,57 @@ if (!Caml_obj.caml_equal(to_list(q2$3), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 133, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 133, + 28 + ] + } + }); } Stdlib__Queue.transfer(q1$3, q2$3); if (q1$3.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 135, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 135, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$3), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 135, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 135, + 28 + ] + } + }); } if (q2$3.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 136, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 136, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$3), { @@ -1213,15 +1286,16 @@ if (!Caml_obj.caml_equal(to_list(q2$3), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 136, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 136, + 28 + ] + } + }); } var q1$4 = { @@ -1245,15 +1319,16 @@ for(var i$11 = 5; i$11 <= 8; ++i$11){ } if (q1$4.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 143, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 143, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$4), { @@ -1269,27 +1344,29 @@ if (!Caml_obj.caml_equal(to_list(q1$4), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 143, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 143, + 28 + ] + } + }); } if (q2$4.length !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 144, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 144, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$4), { @@ -1305,53 +1382,57 @@ if (!Caml_obj.caml_equal(to_list(q2$4), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 144, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 144, + 28 + ] + } + }); } Stdlib__Queue.transfer(q1$4, q2$4); if (q1$4.length !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 146, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 146, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q1$4), /* [] */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 146, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 146, + 28 + ] + } + }); } if (q2$4.length !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 147, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 147, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(to_list(q2$4), { @@ -1379,15 +1460,16 @@ if (!Caml_obj.caml_equal(to_list(q2$4), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/libqueue_test.ml", - 147, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/libqueue_test.ml", + 147, + 28 + ] + } + }); } console.log("OK"); diff --git a/jscomp/test/dist/jscomp/test/map_find_test.js b/jscomp/test/dist/jscomp/test/map_find_test.js index b26f08befd..b2434737c7 100644 --- a/jscomp/test/dist/jscomp/test/map_find_test.js +++ b/jscomp/test/dist/jscomp/test/map_find_test.js @@ -48,17 +48,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -80,17 +82,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -148,10 +152,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -224,17 +229,19 @@ function bal$1(l, x, d, r) { if (lr) { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -256,17 +263,19 @@ function bal$1(l, x, d, r) { if (rl) { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$1(x, data, m) { @@ -324,10 +333,11 @@ function find$1(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/map_test.js b/jscomp/test/dist/jscomp/test/map_test.js index 20a2855af3..2a9ce90583 100644 --- a/jscomp/test/dist/jscomp/test/map_test.js +++ b/jscomp/test/dist/jscomp/test/map_test.js @@ -49,17 +49,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -81,17 +83,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -267,17 +271,19 @@ function bal$1(l, x, d, r) { if (lr) { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -299,17 +305,19 @@ function bal$1(l, x, d, r) { if (rl) { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$1(x, data, m) { @@ -367,10 +375,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/mario_game.js b/jscomp/test/dist/jscomp/test/mario_game.js index 04909bf207..a37798b5b9 100644 --- a/jscomp/test/dist/jscomp/test/mario_game.js +++ b/jscomp/test/dist/jscomp/test/mario_game.js @@ -1481,11 +1481,12 @@ function game_win(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("You win!", 180, 128); - throw { - MEL_EXN_ID: "Failure", - _1: "Game over.", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Game over." + } + }); } function game_loss(ctx) { @@ -1495,11 +1496,12 @@ function game_loss(ctx) { ctx.fillStyle = "white"; ctx.font = "20px 'Press Start 2P'"; ctx.fillText("GAME OVER. You lose!", 60, 128); - throw { - MEL_EXN_ID: "Failure", - _1: "Game over.", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Game over." + } + }); } var Draw = { @@ -2391,11 +2393,12 @@ function choose_enemy_typ(typ) { case 2 : return /* Goomba */0; default: - throw { - MEL_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Shouldn't reach here" + } + }); } } @@ -2414,11 +2417,12 @@ function choose_sblock_typ(typ) { case 4 : return /* Ground */5; default: - throw { - MEL_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Shouldn't reach here" + } + }); } } @@ -2929,11 +2933,12 @@ function choose_block_pattern(blockw, blockh, cbx, cby, prob) { tl: /* [] */0 }; default: - throw { - MEL_EXN_ID: "Failure", - _1: "Shouldn't reach here", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Shouldn't reach here" + } + }); } } @@ -3217,11 +3222,12 @@ function load(param) { }, _1: "cant find canvas %s \n" }), canvas_id); - throw { - MEL_EXN_ID: "Failure", - _1: "fail", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "fail" + } + }); } var context = canvas.getContext("2d"); document.addEventListener("keydown", keydown, true); diff --git a/jscomp/test/dist/jscomp/test/noassert.js b/jscomp/test/dist/jscomp/test/noassert.js index ead896e11a..4d2c65a704 100644 --- a/jscomp/test/dist/jscomp/test/noassert.js +++ b/jscomp/test/dist/jscomp/test/noassert.js @@ -3,15 +3,16 @@ function f(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/noassert.ml", - 5, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/noassert.ml", + 5, + 11 + ] + } + }); } function h(param) { diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index 93de45ca17..32b6851e85 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -41,7 +41,9 @@ try { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -73,10 +75,11 @@ var Fatal_error = /* @__PURE__ */Caml_exceptions.create("Ocaml_parsetree_test.Mi function fatal_error(msg) { Stdlib.prerr_string(">> Fatal error: "); console.error(msg); - throw { - MEL_EXN_ID: Fatal_error, - Error: new Error() - }; + throw new Error(Fatal_error, { + cause: { + MEL_EXN_ID: Fatal_error + } + }); } function create_hashtable(size, init) { @@ -208,21 +211,23 @@ function style_of_tag(param) { case "warning" : return cur_styles.contents.warning; default: - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "misc.ml", - 428, - 19 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "misc.ml", + 428, + 19 + ] + } + }); } } @@ -248,7 +253,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_mark_close_stag = function (param) { @@ -268,7 +275,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg$1, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_print_open_stag = functions.print_open_stag; @@ -621,15 +630,16 @@ function letter(param) { tl: /* [] */0 }; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 176, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 176, + 9 + ] + } + }); } } @@ -691,11 +701,12 @@ function parse_opt(error, active, flags, s) { var match$1 = get_num(0, i$1 + 2 | 0); var n2 = match$1[1]; if (n2 < n1) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } return [ match$1[0], @@ -713,22 +724,24 @@ function parse_opt(error, active, flags, s) { if (c >= 65) { if (c >= 97) { if (c >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(clear, letter(Caml_string.get(s, i))); _i = i + 1 | 0; continue ; } if (c >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(set, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); _i = i + 1 | 0; @@ -738,72 +751,79 @@ function parse_opt(error, active, flags, s) { if (c >= 64) { return loop_letter_num(set_all, i + 1 | 0); } - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } if (c >= 43) { switch (c) { case 43 : return loop_letter_num(set, i + 1 | 0); case 44 : - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); case 45 : return loop_letter_num(clear, i + 1 | 0); } } else { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } }; }; var loop_letter_num = function (myset, i) { if (i >= s.length) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match = Caml_string.get(s, i); if (match >= 65) { if (match >= 97) { if (match >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Caml_string.get(s, i))); return loop(i + 1 | 0); } if (match >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); return loop(i + 1 | 0); } if (match > 57 || match < 48) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match$1 = get_range(i); for(var n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n){ @@ -897,15 +917,16 @@ function message(param) { return "the method " + (lab + " is overridden."); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 283, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 283, + 26 + ] + } + }); case /* Partial_match */3 : var s$1 = param._0; if (s$1 === "") { @@ -934,15 +955,16 @@ function message(param) { return "the instance variable " + (lab$1 + " is overridden.\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 303, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 303, + 37 + ] + } + }); case /* Implicit_public_methods */6 : return "the following private methods were made public implicitly:\n " + (Stdlib__String.concat(" ", param._0) + "."); case /* Undeclared_virtual_method */7 : @@ -1065,15 +1087,16 @@ function message(param) { if (param._2) { return "this record of type " + (ty + (" contains fields that are \nnot visible in the current scope: " + (Stdlib__String.concat(" ", slist) + ".\nThey will not be selected if the type becomes unknown."))); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 365, - 39 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 365, + 39 + ] + } + }); break; case /* Ambiguous_name */24 : var slist$1 = param._0; @@ -1083,15 +1106,16 @@ function message(param) { if (param._2) { return "these field labels belong to several types: " + (Stdlib__String.concat(" ", param._1) + "\nThe first one was selected. Please disambiguate if this is wrong."); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 374, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 374, + 36 + ] + } + }); break; case /* Disambiguated_name */25 : return "this use of " + (param._0 + " required disambiguation."); @@ -1337,10 +1361,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Stdlib__Format.pp_print_flush(ppf, undefined); var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var lines = num_loc_lines.contents; for(var i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i){ @@ -1350,10 +1375,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { } if (lines >= (num_lines - 2 | 0)) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } Caml_io.caml_ml_flush(Stdlib.stdout); Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); @@ -1390,10 +1416,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { function highlight_dumb(ppf, lb, loc) { var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var end_pos = (lb.lex_buffer_len - pos0 | 0) - 1 | 0; var line_start = 0; @@ -1528,7 +1555,9 @@ function highlight_locations(ppf, locs) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { norepeat = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (norepeat) { @@ -1544,7 +1573,9 @@ function highlight_locations(ppf, locs) { if (exn$1.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { status.contents = Caml_external_polyfill.resolve("caml_terminfo_setup")(Stdlib.stdout); @@ -1564,7 +1595,9 @@ function highlight_locations(ppf, locs) { if (exn$2.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } }; @@ -2424,7 +2457,9 @@ function get_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2437,7 +2472,9 @@ function mark_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2461,7 +2498,9 @@ function get_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2474,7 +2513,9 @@ function mark_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2488,7 +2529,9 @@ function get_info(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2510,7 +2553,9 @@ function get_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2532,7 +2577,9 @@ function get_pre_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2554,7 +2601,9 @@ function get_post_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4027,15 +4076,16 @@ function mkexp_constraint(e, param) { _2: t2 }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/parser.mly", - 153, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/parser.mly", + 153, + 18 + ] + } + }); } function array_function(str, name) { @@ -4053,41 +4103,44 @@ function array_function(str, name) { } function unclosed(opening_name, opening_num, closing_name, closing_num) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Unclosed */0, - _0: rhs_loc(opening_num), - _1: opening_name, - _2: rhs_loc(closing_num), - _3: closing_name - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Unclosed */0, + _0: rhs_loc(opening_num), + _1: opening_name, + _2: rhs_loc(closing_num), + _3: closing_name + } + } + }); } function expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Expecting */1, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Expecting */1, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function not_expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function bigarray_function(str, name) { @@ -4149,15 +4202,16 @@ function check_variable(vl, loc, v) { if (!Stdlib__List.mem(v, vl)) { return ; } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Variable_in_scope */4, - _0: loc, - _1: v - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Variable_in_scope */4, + _0: loc, + _1: v + } + } + }); } function varify_constructors(var_names, t) { @@ -4565,11 +4619,12 @@ var yytransl_block = [ var yyact = [ (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "parser", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "parser" + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -4590,10 +4645,11 @@ var yyact = [ return Stdlib__Parsing.peek_val(__caml_parser_env, 1); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -4980,15 +5036,16 @@ var yyact = [ } if (exit === 1) { if (Caml_obj.caml_notequal(lbs.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lbs.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lbs.lbs_loc, + _1: "attributes" + } + } + }); } var bindings$1 = Stdlib__List.map((function (lb) { return mk$17(lb.lb_loc, lb.lb_attributes, CamlinternalLazy.force(lb.lb_docs), CamlinternalLazy.force(lb.lb_text), lb.lb_pattern, lb.lb_expression); @@ -5594,39 +5651,42 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); if (_1.lbs_extension !== undefined) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "extension" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "extension" + } + } + }); } if (Caml_obj.caml_notequal(_1.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "attributes" + } + } + }); } return mkclass({ TAG: /* Pcl_let */4, @@ -5807,10 +5867,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -5883,10 +5944,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -5906,10 +5968,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -6448,15 +6511,16 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); @@ -6568,10 +6632,11 @@ var yyact = [ (function (__caml_parser_env) { Stdlib__Parsing.peek_val(__caml_parser_env, 3); Stdlib__Parsing.peek_val(__caml_parser_env, 2); - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -8134,16 +8199,18 @@ var yyact = [ ]; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -9279,17 +9346,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -9298,17 +9367,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -10090,14 +10161,15 @@ var yyact = [ _1: _3 }; } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Applicative_path */3, - _0: symbol_rloc(undefined) - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Applicative_path */3, + _0: symbol_rloc(undefined) + } + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -10608,53 +10680,60 @@ var yyact = [ }; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }) ]; @@ -10720,19 +10799,20 @@ function assert_same_type(lexbuf, x, y) { var lhs = type_of_directive(x); var rhs = type_of_directive(y); if (lhs !== rhs) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: lhs, - _1: rhs - }, - _2: curr(lexbuf), - Error: new Error() - }; - } - return y; -} + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: lhs, + _1: rhs + }, + _2: curr(lexbuf) + } + }); + } + return y; +} var directive_built_in_values = Stdlib__Hashtbl.create(undefined, 51); @@ -10756,7 +10836,9 @@ catch (raw_exn$1){ if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { tmp = ""; } else { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -10872,7 +10954,9 @@ function query(loc, str) { _0: false }; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } if (exit === 2) { try { @@ -10906,7 +10990,9 @@ function query(loc, str) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (typeof v === "number") { @@ -10933,12 +11019,13 @@ function value_of_token(loc, t) { _0: true }; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } else { switch (t.TAG | 0) { @@ -10960,12 +11047,13 @@ function value_of_token(loc, t) { case /* UIDENT */17 : return query(loc, t._0); default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } } @@ -10986,12 +11074,13 @@ function directive_parse(token_with_comments, lexbuf) { if (typeof t === "number") { switch (t) { case /* EOF */25 : - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); case /* EOL */100 : _param = undefined; continue ; @@ -11012,15 +11101,16 @@ function directive_parse(token_with_comments, lexbuf) { }; var push = function (e) { if (look_ahead.contents !== undefined) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 312, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 312, + 4 + ] + } + }); } look_ahead.contents = e; }; @@ -11061,15 +11151,16 @@ function directive_parse(token_with_comments, lexbuf) { var str = rhs._0; var last_index = str.length - 1 | 0; if (last_index < 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } var v = str.charCodeAt(0); var match; @@ -11088,15 +11179,16 @@ function directive_parse(token_with_comments, lexbuf) { switch (v) { case 60 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } match = str[1] === "=" ? [ "Le", @@ -11111,15 +11203,16 @@ function directive_parse(token_with_comments, lexbuf) { break; case 62 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } match = str[1] === "=" ? [ "Ge", @@ -11178,30 +11271,32 @@ function directive_parse(token_with_comments, lexbuf) { exit$2 = 3; } if (exit$2 === 3) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } } if (exit$1 === 2) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } break; case "<=" : @@ -11245,15 +11340,16 @@ function directive_parse(token_with_comments, lexbuf) { exit$4 = 2; } if (exit$4 === 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 331, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 331, + 17 + ] + } + }); } var curr_loc$1 = curr(lexbuf); var rhs$1 = value_of_token(curr_loc$1, token(undefined)); @@ -11296,36 +11392,39 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 81) { return v; } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_paren_in_conditional */1, + _2: curr(lexbuf) + } + }); case /* TRUE */91 : return true; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } else { switch (curr_token.TAG | 0) { case /* FLOAT */1 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_float */1 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_float */1 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_float */1, _0: Caml_format.caml_float_of_string(curr_token._0) @@ -11346,22 +11445,24 @@ function directive_parse(token_with_comments, lexbuf) { case "undefined" : break; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } var t = token(undefined); var loc = curr(lexbuf); if (typeof t === "number") { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } if (t.TAG === /* UIDENT */17) { var s = t._0; @@ -11375,25 +11476,27 @@ function directive_parse(token_with_comments, lexbuf) { return true; } } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); break; case /* STRING */16 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_string */3 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_string */3 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_string */3, _0: curr_token._0[0] @@ -11406,24 +11509,26 @@ function directive_parse(token_with_comments, lexbuf) { return value_v._0; } var ty = type_of_directive(value_v); - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: ty - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: ty + }, + _2: curr_loc + } + }); }), value_v); default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } }; @@ -11446,12 +11551,13 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 88) { return v; } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Expect_hash_then_in_conditional */5, + _2: curr(lexbuf) + } + }); } function is_elif(i) { @@ -11941,15 +12047,16 @@ function char_for_decimal_code(lexbuf, i) { if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { return /* 'x' */120; } - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_escape */1, - _0: Stdlib__Lexing.lexeme(lexbuf) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_escape */1, + _0: Stdlib__Lexing.lexeme(lexbuf) + }, + _2: curr(lexbuf) + } + }); } function char_for_hexadecimal_code(lexbuf, i) { @@ -11977,15 +12084,16 @@ function cvt_int64_literal(s) { } function cvt_nativeint_literal(s) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 622, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 622, + 30 + ] + } + }); } function remove_underscores(s) { @@ -12019,15 +12127,16 @@ function get_label_name(lexbuf) { var s = Stdlib__Lexing.lexeme(lexbuf); var name = Stdlib__String.sub(s, 1, s.length - 2 | 0); if (Stdlib__Hashtbl.mem(keyword_table, name)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Keyword_as_label */4, - _0: name - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Keyword_as_label */4, + _0: name + }, + _2: curr(lexbuf) + } + }); } return name; } @@ -12305,15 +12414,16 @@ function token(lexbuf) { switch (__ocaml_lex_state$1) { case 0 : if (!escaped_newlines.contents) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); } update_loc(lexbuf, undefined, 1, false, 0); return token(lexbuf); @@ -12369,7 +12479,9 @@ function token(lexbuf) { _0: s }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case 11 : prerr_warning(curr(lexbuf), { @@ -12404,17 +12516,20 @@ function token(lexbuf) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int" + }, + _2: curr(lexbuf) + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case 15 : return { @@ -12431,17 +12546,20 @@ function token(lexbuf) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int32" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int32" + }, + _2: curr(lexbuf) + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } case 17 : try { @@ -12453,17 +12571,20 @@ function token(lexbuf) { catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int64" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int64" + }, + _2: curr(lexbuf) + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } case 18 : try { @@ -12475,17 +12596,20 @@ function token(lexbuf) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "nativeint" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "nativeint" + }, + _2: curr(lexbuf) + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } case 19 : reset_string_buffer(undefined); @@ -12548,15 +12672,16 @@ function token(lexbuf) { case 26 : var l = Stdlib__Lexing.lexeme(lexbuf); var esc = Stdlib__String.sub(l, 1, l.length - 1 | 0); - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_escape */1, - _0: esc - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_escape */1, + _0: esc + }, + _2: curr(lexbuf) + } + }); case 27 : var match = with_comment_buffer(comment, lexbuf); return { @@ -12765,29 +12890,32 @@ function token(lexbuf) { return /* EOF */25; } if (if_then_else.contents === /* Dir_if_true */0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); case 91 : - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -12836,12 +12964,13 @@ function string(lexbuf) { return string(lexbuf); case 7 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 8 : store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); return string(lexbuf); @@ -12869,12 +12998,13 @@ function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { continue ; case 1 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 2 : var edelim = Stdlib__Lexing.lexeme(lexbuf); var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); @@ -12921,15 +13051,16 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { comment_start_loc.contents = /* [] */0; return curr(lexbuf); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 992, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 992, + 16 + ] + } + }); case 2 : string_start_loc.contents = curr(lexbuf); store_string_char(/* '"' */34); @@ -12943,36 +13074,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$1 = exn._1; if (typeof match$1 === "number") { if (match$1) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var match$2 = comment_start_loc.contents; if (match$2) { var start = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start, - _1: exn._2 - }, - _2: match$2.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start, + _1: exn._2 + }, + _2: match$2.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1006, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1006, + 18 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } is_in_string.contents = false; store_string_char(/* '"' */34); @@ -12993,36 +13132,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$3 = exn$1._1; if (typeof match$3 === "number") { if (match$3) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var match$4 = comment_start_loc.contents; if (match$4) { var start$1 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start$1, - _1: exn$1._2 - }, - _2: match$4.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start$1, + _1: exn$1._2 + }, + _2: match$4.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1026, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1026, + 18 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } is_in_string.contents = false; store_string_char(/* '|' */124); @@ -13040,25 +13187,27 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { if (match$5) { var start$2 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_comment */2, - _0: start$2 - }, - _2: match$5.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_comment */2, + _0: start$2 + }, + _2: match$5.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1056, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1056, + 16 + ] + } + }); case 11 : update_loc(lexbuf, undefined, 1, false, 0); store_string(Stdlib__Lexing.lexeme(lexbuf)); @@ -13151,22 +13300,24 @@ function token$1(lexbuf) { switch (match) { case /* ELSE */23 : if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } break; case /* END */24 : if (if_then_else$1 >= 2) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } if_then_else.contents = /* Dir_out */2; return Curry._1(cont, lexbuf); @@ -13180,12 +13331,13 @@ function token$1(lexbuf) { while(true) { var token = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token, /* SHARP */84) && at_bol(lexbuf)) { var token$1 = token_with_comments(lexbuf); @@ -13200,12 +13352,13 @@ function token$1(lexbuf) { } } if (token$1 === 37) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -13221,12 +13374,13 @@ function token$1(lexbuf) { }; } } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); default: return Curry._1(look_ahead, match); } @@ -13238,12 +13392,13 @@ function token$1(lexbuf) { return Curry._1(look_ahead, match); } if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -13255,12 +13410,13 @@ function token$1(lexbuf) { var else_seen = _else_seen; var token$2 = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token$2, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token$2, /* SHARP */84) && at_bol(lexbuf)) { var token$3 = token_with_comments(lexbuf); @@ -13271,33 +13427,36 @@ function token$1(lexbuf) { return Curry._1(cont, lexbuf); } if (else_seen) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } _else_seen = true; continue ; } if (token$3 === 37) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } if (else_seen && is_elif(token$3)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } continue ; } @@ -13433,7 +13592,9 @@ function skip_phrase(lexbuf) { if (tmp === /* Unterminated_string */0) { continue ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } else { switch (tmp.TAG | 0) { case /* Illegal_character */0 : @@ -13441,11 +13602,15 @@ function skip_phrase(lexbuf) { case /* Unterminated_string_in_comment */3 : continue ; default: - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }; @@ -13473,26 +13638,40 @@ function wrap(parsing_fun, lexbuf) { if (err.MEL_EXN_ID === $$Error$2) { var tmp = err._1; if (typeof tmp === "number") { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (tmp.TAG === /* Illegal_character */0) { if (input_name.contents === "//toplevel//") { skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } else { if (err.MEL_EXN_ID === $$Error$1) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (err.MEL_EXN_ID !== Stdlib__Parsing.Parse_error && err.MEL_EXN_ID !== Escape_error) { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } } @@ -13500,14 +13679,15 @@ function wrap(parsing_fun, lexbuf) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Other */5, - _0: loc - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Other */5, + _0: loc + } + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/ocaml_proto_test.js b/jscomp/test/dist/jscomp/test/ocaml_proto_test.js index e56c09a50b..791a997fac 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_proto_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_proto_test.js @@ -199,7 +199,9 @@ function file_option(file_options, name) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return x; } @@ -222,7 +224,9 @@ function rev_split_by_char(c, s) { tl: l }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return loop(0, /* [] */0); @@ -239,11 +243,12 @@ function pop_last(param) { return /* [] */0; } } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid argument [] for pop_last", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid argument [] for pop_last" + } + }); } function apply_until(f, _param) { @@ -743,44 +748,47 @@ Stdlib__Printexc.register_printer(function (exn) { }); function invalid_default_value(field_name, info, param) { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_default_value */2, - _0: { - field_name: field_name, - info: info - } - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_default_value */2, + _0: { + field_name: field_name, + info: info + } + } + } + }); } function unsupported_field_type(field_name, field_type, backend_name, param) { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Unsupported_field_type */3, - _0: { - field_name: field_name, - field_type: field_type, - backend_name: backend_name - } - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Unsupported_field_type */3, + _0: { + field_name: field_name, + field_type: field_type, + backend_name: backend_name + } + } + } + }); } function invalid_enum_specification(enum_name, loc) { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_enum_specification */10, - _0: enum_name, - _1: loc - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_enum_specification */10, + _0: enum_name, + _1: loc + } + } + }); } var yytransl_const = [ @@ -825,11 +833,12 @@ var yytransl_block = [ var yyact = [ (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "parser", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "parser" + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -951,14 +960,15 @@ var yyact = [ Stdlib__Parsing.peek_val(__caml_parser_env, 2); Stdlib__Parsing.peek_val(__caml_parser_env, 1); Stdlib__Parsing.peek_val(__caml_parser_env, 0); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_import_qualifier */5, - _0: _1 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_import_qualifier */5, + _0: _1 + } + } + }); }), (function (__caml_parser_env) { var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -1028,11 +1038,12 @@ var yyact = [ }; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Compilation_error, - _1: /* Syntax_error */0, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: /* Syntax_error */0 + } + }); }), (function (__caml_parser_env) { var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 3); @@ -1112,14 +1123,15 @@ var yyact = [ var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 3); Stdlib__Parsing.peek_val(__caml_parser_env, 1); Stdlib__Parsing.peek_val(__caml_parser_env, 0); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Missing_one_of_name */12, - _0: _1 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Missing_one_of_name */12, + _0: _1 + } + } + }); }), (function (__caml_parser_env) { return /* [] */0; @@ -1187,28 +1199,30 @@ var yyact = [ Stdlib__Parsing.peek_val(__caml_parser_env, 2); Stdlib__Parsing.peek_val(__caml_parser_env, 1); Stdlib__Parsing.peek_val(__caml_parser_env, 0); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Missing_field_label */14, - _0: _1[0] - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Missing_field_label */14, + _0: _1[0] + } + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 4); Stdlib__Parsing.peek_val(__caml_parser_env, 3); Stdlib__Parsing.peek_val(__caml_parser_env, 1); Stdlib__Parsing.peek_val(__caml_parser_env, 0); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Missing_field_label */14, - _0: _1[0] - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Missing_field_label */14, + _0: _1[0] + } + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0)[1]; @@ -1274,14 +1288,15 @@ var yyact = [ }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_field_label */13, - _0: _1[0] - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_field_label */13, + _0: _1[0] + } + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -1424,15 +1439,16 @@ var yyact = [ Stdlib__Parsing.peek_val(__caml_parser_env, 0); var enum_value = _1[1]; var loc = _1[0]; - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Missing_semicolon_for_enum_value */9, - _0: enum_value, - _1: loc - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Missing_semicolon_for_enum_value */9, + _0: enum_value, + _1: loc + } + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 3); @@ -1464,88 +1480,100 @@ var yyact = [ Stdlib__Parsing.peek_val(__caml_parser_env, 1); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }) ]; @@ -1831,11 +1859,12 @@ function lexer(lexbuf) { }, _1: "Unknown character found %s" }), Stdlib__Lexing.lexeme(lexbuf)); - throw { - MEL_EXN_ID: "Failure", - _1: s$1, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s$1 + } + }); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -2132,11 +2161,12 @@ function runtime_function(param) { case /* Bt_int64 */4 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } case /* Pk_bits64 */1 : @@ -2151,11 +2181,12 @@ function runtime_function(param) { case /* Bt_int32 */3 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } case /* Pk_bytes */2 : @@ -2166,11 +2197,12 @@ function runtime_function(param) { if (!match$2) { return "Pbrt.Decoder.string"; } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } } else if (match$1._0) { @@ -2185,11 +2217,12 @@ function runtime_function(param) { case /* Bt_float */1 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } } else { @@ -2203,11 +2236,12 @@ function runtime_function(param) { case /* Bt_string */0 : case /* Bt_float */1 : case /* Bt_bytes */5 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); case /* Bt_bool */6 : return "Pbrt.Decoder.bool"; @@ -2229,11 +2263,12 @@ function runtime_function(param) { case /* Bt_int64 */4 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } case /* Pk_bits64 */1 : @@ -2248,11 +2283,12 @@ function runtime_function(param) { case /* Bt_int32 */3 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } case /* Pk_bytes */2 : @@ -2263,11 +2299,12 @@ function runtime_function(param) { if (!match$4) { return "Pbrt.Encoder.string"; } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } } else if (match$3._0) { @@ -2282,11 +2319,12 @@ function runtime_function(param) { case /* Bt_float */1 : case /* Bt_bytes */5 : case /* Bt_bool */6 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } } else { @@ -2300,22 +2338,24 @@ function runtime_function(param) { case /* Bt_string */0 : case /* Bt_float */1 : case /* Bt_bytes */5 : - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); case /* Bt_bool */6 : return "Pbrt.Encoder.bool"; } } } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid encoding/OCaml type combination", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid encoding/OCaml type combination" + } + }); } } @@ -3903,17 +3943,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -3935,17 +3977,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -4003,10 +4047,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -4048,17 +4093,19 @@ function min_value(param) { if (y !== undefined) { return Caml_option.some(Caml_obj.caml_min(Caml_option.valFromOption(x), Caml_option.valFromOption(y))); } - throw { - MEL_EXN_ID: "Failure", - _1: "min_value error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "min_value error" + } + }); } - throw { - MEL_EXN_ID: "Failure", - _1: "min_value error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "min_value error" + } + }); } function eq_value(param) { @@ -4068,17 +4115,19 @@ function eq_value(param) { if (y !== undefined) { return Caml_obj.caml_equal(Caml_option.valFromOption(x), Caml_option.valFromOption(y)); } - throw { - MEL_EXN_ID: "Failure", - _1: "eq_value error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "eq_value error" + } + }); } - throw { - MEL_EXN_ID: "Failure", - _1: "eq_value error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "eq_value error" + } + }); } function string_of_option(f, param) { @@ -4389,7 +4438,9 @@ function find_field_option(field_options, option_name) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return Caml_option.some(x); } @@ -4466,14 +4517,15 @@ function unresolved_of_string(s) { from_root: Caml_string.get(s, 0) === /* '.' */46 }; } - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Programatic_error */4, - _0: /* Invalid_string_split */0 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Programatic_error */4, + _0: /* Invalid_string_split */0 + } + } + }); } function field_type_of_string(s) { @@ -4625,7 +4677,9 @@ function get_default(field_name, field_options, field_type) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return Caml_option.some(constant); } @@ -4669,7 +4723,9 @@ function not_found(f) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4684,10 +4740,11 @@ function list_assoc2(x, _param) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -4819,18 +4876,19 @@ function compile_message_p1(file_name, file_options, message_scope, param) { }; } else { var previous_field_name = ""; - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Duplicated_field_number */1, - _0: { - field_name: name, - previous_field_name: previous_field_name, - message_name: message_name - } - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Duplicated_field_number */1, + _0: { + field_name: name, + previous_field_name: previous_field_name, + message_name: message_name + } + } + } + }); } }; Stdlib__List.fold_left((function (number_index, param) { @@ -4955,14 +5013,15 @@ function compile_message_p2(types, param, message) { if (typeof field_type === "number") { return field_type; } - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Programatic_error */4, - _0: /* Unexpected_field_type */1 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Programatic_error */4, + _0: /* Unexpected_field_type */1 + } + } + }); } var unresolved = field_type._0; var type_name = unresolved.type_name; @@ -5029,7 +5088,9 @@ function compile_message_p2(types, param, message) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), search_scopes$1); if (id !== undefined) { @@ -5037,18 +5098,19 @@ function compile_message_p2(types, param, message) { _0: id }; } else { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Unresolved_type */0, - _0: { - field_name: field_name, - type_: type_name, - message_name: message_name - } - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Unresolved_type */0, + _0: { + field_name: field_name, + type_: type_name, + message_name: message_name + } + } + } + }); } }; var message_body = Stdlib__List.fold_left((function (message_body, param) { @@ -6441,15 +6503,16 @@ function record_field_default_info(record_field) { _1: "%s (%s)" }), vc_constructor, dfvft(vc_field_type._0, undefined)) : vc_constructor; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "codegen_default.ml", - 74, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "codegen_default.ml", + 74, + 15 + ] + } + }); } break; @@ -6708,11 +6771,12 @@ function gen_default_variant(and_, param, sc) { _1: "%s default_%s () : %s = %s (%s)" }), decl, v_name, v_name, vc_constructor, default_value)); } - throw { - MEL_EXN_ID: "Failure", - _1: "programmatic TODO error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "programmatic TODO error" + } + }); } function gen_default_const_variant(and_, param, sc) { @@ -6722,11 +6786,12 @@ function gen_default_const_variant(and_, param, sc) { if (cv_constructors) { first_constructor_name = cv_constructors.hd[0]; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "programmatic TODO error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "programmatic TODO error" + } + }); } line$1(sc, Curry._4(Stdlib__Printf.sprintf(/* Format */{ _0: { @@ -7083,16 +7148,19 @@ function module_of_file_name(file_name) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_file_name */6, - _0: file_name$1 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_file_name */6, + _0: file_name$1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return constructor_name(Stdlib__String.sub(file_name$1, 0, dot_index) + "_pb"); } @@ -7113,11 +7181,12 @@ function type_name(message_scope, name) { return fix_ocaml_keyword_conflict(all_names$2.hd); } } - throw { - MEL_EXN_ID: "Failure", - _1: "Programmatic error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Programmatic error" + } + }); } function encoding_info_of_field_type(all_types, field_type) { @@ -7169,14 +7238,15 @@ function encoding_of_field(all_types, field) { packed = match._0; } else { var field_name$1 = field_name(field); - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_packed_option */8, - _0: field_name$1 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_packed_option */8, + _0: field_name$1 + } + } + }); } } else { packed = false; @@ -7219,16 +7289,19 @@ function compile_field_type(field_name, all_types, file_options, field_options, catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Programatic_error */4, - _0: /* No_type_found_for_id */2 - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Programatic_error */4, + _0: /* No_type_found_for_id */2 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (is_empty_message(t)) { return /* Ft_unit */0; @@ -7320,14 +7393,15 @@ function is_mutable(field_name, field_options) { if (match.TAG === /* Constant_bool */1) { return match._0; } - throw { - MEL_EXN_ID: Compilation_error, - _1: { - TAG: /* Invalid_mutable_option */11, - _0: field_name - }, - Error: new Error() - }; + throw new Error(Compilation_error, { + cause: { + MEL_EXN_ID: Compilation_error, + _1: { + TAG: /* Invalid_mutable_option */11, + _0: field_name + } + } + }); } function ocaml_container(field_options) { @@ -7407,7 +7481,9 @@ function compile(proto_definition) { } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - throw add_loc(from_lexbuf(lexbuf), exn); + throw new Error(add_loc(from_lexbuf(lexbuf), exn).MEL_EXN_ID, { + cause: add_loc(from_lexbuf(lexbuf), exn) + }); } var all_pbtt_msgs = compile_proto_p1("tmp.proto", proto); var all_pbtt_msgs$1 = Stdlib__List.map((function (param) { @@ -7527,11 +7603,12 @@ function compile(proto_definition) { if (match$2 === "repeated_field") { repeated_type = /* Rt_repeated_field */1; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid ocaml_container attribute value", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid ocaml_container attribute value" + } + }); } } else { repeated_type = /* Rt_list */0; @@ -7617,20 +7694,22 @@ function compile(proto_definition) { var key_pk = encoding_info_of_field_type(all_pbtt_msgs$1, map_key_type); var key_type$1; if (typeof key_type === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "Only Basic Types are supported for map keys", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Only Basic Types are supported for map keys" + } + }); } if (key_type.TAG === /* Ft_basic_type */0) { key_type$1 = key_type._0; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Only Basic Types are supported for map keys", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Only Basic Types are supported for map keys" + } + }); } var value_type = compile_field_type(Curry._1(Stdlib__Printf.sprintf(/* Format */{ _0: { @@ -7651,11 +7730,12 @@ function compile(proto_definition) { if (match$3 === "hashtbl") { associative_type = /* At_hashtable */1; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid ocaml_container attribute value for map", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid ocaml_container attribute value for map" + } + }); } } else { associative_type = /* At_list */0; diff --git a/jscomp/test/dist/jscomp/test/ocaml_re_test.js b/jscomp/test/dist/jscomp/test/ocaml_re_test.js index a459542f8b..c063d74d52 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_re_test.js @@ -333,17 +333,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -365,17 +367,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -433,10 +437,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -539,17 +544,19 @@ function bal$1(l, v, r) { if (lr) { return create$1(create$1(ll, lv, lr.l), lr.v, create$1(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -569,17 +576,19 @@ function bal$1(l, v, r) { if (rl) { return create$1(create$1(l, v, rl.l), rl.v, create$1(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$1(x, t) { @@ -1091,15 +1100,16 @@ function split_at_match_rec(_l$p, _param) { } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "re_automata.ml", - 429, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "re_automata.ml", + 429, + 21 + ] + } + }); } }; } @@ -1539,7 +1549,9 @@ function find_state(re, desc) { Curry._3(Re_automata_State.Table.add, re.states, desc, st); return st; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1620,7 +1632,9 @@ function $$final(info, st, cat) { }; return res; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1641,7 +1655,9 @@ function find_initial_state(re, cat) { }; return st; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1751,7 +1767,9 @@ function trans_set(cache, cm, s) { cache.contents = Curry._3(add, v, l, cache.contents); return l; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1891,15 +1909,16 @@ function colorize(c, regexp) { _regexp = regexp._1; continue ; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "re.ml", - 502, - 35 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "re.ml", + 502, + 35 + ] + } + }); } } }; @@ -2487,15 +2506,16 @@ function translate(ids, kind, _ign_group, ign_case, _greedy, pos, cache, c, _par match$5[1] ]; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "re.ml", - 714, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "re.ml", + 714, + 4 + ] + } + }); } } }; @@ -2528,28 +2548,30 @@ function case_insens(s) { function as_set(param) { if (typeof param === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "re.ml", - 747, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "re.ml", + 747, + 13 + ] + } + }); } if (param.TAG === /* Set */0) { return param._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "re.ml", - 747, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "re.ml", + 747, + 13 + ] + } + }); } function handle_case(_ign_case, _r) { @@ -2770,18 +2792,20 @@ var epsilon = { function repn(r, i, j) { if (i < 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Re.repn", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Re.repn" + } + }); } if (j !== undefined && j < i) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Re.repn", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Re.repn" + } + }); } return { TAG: /* Repeat */3, @@ -2810,11 +2834,12 @@ function compl(l) { if (is_charset(r)) { return r; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Re.compl", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Re.compl" + } + }); } var any = { @@ -3164,11 +3189,12 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { var pos = posOpt !== undefined ? posOpt : 0; var len = lenOpt !== undefined ? lenOpt : -1; if (pos < 0 || len < -1 || (pos + len | 0) > s.length) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: name, - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: name + } + }); } var partial = false; var slen = s.length; @@ -3233,17 +3259,19 @@ function exec_internal(name, posOpt, lenOpt, groups, re, s) { function offset$1(t, i) { if (((i << 1) + 1 | 0) >= t.marks.length) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var m1 = Caml_array.get(t.marks, (i << 1)); if (m1 === -1) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var p1 = Caml_array.get(t.gpos, m1) - 1 | 0; var p2 = Caml_array.get(t.gpos, Caml_array.get(t.marks, (i << 1) + 1 | 0)) - 1 | 0; @@ -3293,11 +3321,12 @@ function posix_class_of_string(class_) { return xdigit; default: var s = "Invalid pcre class: " + class_; - throw { - MEL_EXN_ID: "Invalid_argument", - _1: s, - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: s + } + }); } } @@ -3326,18 +3355,20 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { for(var j = 0; j < len; ++j){ try { if (Caml_string.get(s$p, j) !== Caml_string.get(s, i.contents + j | 0)) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } catch (exn){ - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } i.contents = i.contents + len | 0; @@ -3348,7 +3379,9 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (exn$1.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } }; var get = function (param) { @@ -3496,10 +3529,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (accept(/* ':' */58)) { var r = regexp$p(branch$p(/* [] */0)); if (!accept(/* ')' */41)) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return r; } @@ -3514,17 +3548,19 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { continue ; }; } - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var r$1 = regexp$p(branch$p(/* [] */0)); if (!accept(/* ')' */41)) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return { TAG: /* Group */6, @@ -3556,10 +3592,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } if (accept(/* '\\' */92)) { if (i.contents === l) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var c = get(undefined); switch (c) { @@ -3573,10 +3610,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 55 : case 56 : case 57 : - throw { - MEL_EXN_ID: Not_supported, - Error: new Error() - }; + throw new Error(Not_supported, { + cause: { + MEL_EXN_ID: Not_supported + } + }); case 65 : return /* Beg_of_str */5; case 66 : @@ -3698,10 +3736,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 118 : case 120 : case 121 : - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); case 122 : return /* End_of_str */6; default: @@ -3712,10 +3751,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } } else { if (i.contents === l) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var c$1 = get(undefined); if (c$1 >= 64) { @@ -3726,22 +3766,25 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { _0: single(c$1) }; } - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } if (c$1 >= 44) { if (c$1 >= 63) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return { TAG: /* Set */0, @@ -3749,10 +3792,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } if (c$1 >= 42) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return { TAG: /* Set */0, @@ -3782,10 +3826,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } var i$p = Math.imul(10, i$1) + (d$1 - /* '0' */48 | 0) | 0; if (i$p < i$1) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } _i = i$p; continue ; @@ -3794,18 +3839,20 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; var $$char = function (param) { if (i.contents === l) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var c = get(undefined); if (c === /* '[' */91) { if (accept(/* '=' */61)) { - throw { - MEL_EXN_ID: Not_supported, - Error: new Error() - }; + throw new Error(Not_supported, { + cause: { + MEL_EXN_ID: Not_supported + } + }); } if (accept(/* ':' */58)) { var compl$1 = accept(/* '^' */94); @@ -3855,18 +3902,22 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (!accept_s(":]")) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var posix_class = posix_class_of_string(cls); var re = compl$1 ? compl({ @@ -3885,23 +3936,26 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; } if (i.contents === l) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } var c$1 = get(undefined); if (!accept(/* '.' */46)) { - throw { - MEL_EXN_ID: Not_supported, - Error: new Error() - }; + throw new Error(Not_supported, { + cause: { + MEL_EXN_ID: Not_supported + } + }); } if (!accept(/* ']' */93)) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return { NAME: "Char", @@ -4068,18 +4122,20 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { case 120 : case 121 : case 122 : - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } } else { if (c$2 >= 48) { - throw { - MEL_EXN_ID: Not_supported, - Error: new Error() - }; + throw new Error(Not_supported, { + cause: { + MEL_EXN_ID: Not_supported + } + }); } return { NAME: "Char", @@ -4105,16 +4161,18 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (i$1 !== undefined) { var j = accept(/* ',' */44) ? integer(undefined) : i$1; if (!accept(/* '}' */125)) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } if (j !== undefined && j < i$1) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return greedy_mod(repn(r, i$1, j)); } @@ -4123,10 +4181,11 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; var res = regexp$p(branch$p(/* [] */0)); if (i.contents !== l) { - throw { - MEL_EXN_ID: Parse_error, - Error: new Error() - }; + throw new Error(Parse_error, { + cause: { + MEL_EXN_ID: Parse_error + } + }); } return res; } @@ -4166,10 +4225,11 @@ function exec(rex, pos, s) { var len; var substr = exec_internal("Re.exec", pos, len, true, rex, s); if (typeof substr === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return substr._0; } diff --git a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js index 79b4eb099e..31b47e14a1 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -47,7 +47,9 @@ try { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -165,10 +167,11 @@ var Fatal_error = /* @__PURE__ */Caml_exceptions.create("Ocaml_typedtree_test.Mi function fatal_error(msg) { Stdlib.prerr_string(">> Fatal error: "); console.error(msg); - throw { - MEL_EXN_ID: Fatal_error, - Error: new Error() - }; + throw new Error(Fatal_error, { + cause: { + MEL_EXN_ID: Fatal_error + } + }); } function try_finally(work, cleanup) { @@ -178,7 +181,9 @@ function try_finally(work, cleanup) { } catch (e){ Curry._1(cleanup, undefined); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } Curry._1(cleanup, undefined); return result; @@ -247,15 +252,16 @@ function split_last(param) { match[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 817, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 817, + 10 + ] + } + }); } function may(f, param) { @@ -290,10 +296,11 @@ function find_in_path_uncap(path, name) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -306,7 +313,9 @@ function remove_file(filename) { if (exn.MEL_EXN_ID === Stdlib.Sys_error) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -327,7 +336,9 @@ function chop_extension_if_any(fname) { if (exn.MEL_EXN_ID === Stdlib.Invalid_argument) { return fname; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -489,21 +500,23 @@ function style_of_tag(param) { case "warning" : return cur_styles.contents.warning; default: - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "ocaml_typedtree_test.ml", - 1191, - 19 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "ocaml_typedtree_test.ml", + 1191, + 19 + ] + } + }); } } @@ -529,7 +542,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_mark_close_stag = function (param) { @@ -549,7 +564,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg$1, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_print_open_stag = functions.print_open_stag; @@ -902,15 +919,16 @@ function letter(param) { tl: /* [] */0 }; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 1587, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 1587, + 9 + ] + } + }); } } @@ -972,11 +990,12 @@ function parse_opt(error, active, flags, s) { var match$1 = get_num(0, i$1 + 2 | 0); var n2 = match$1[1]; if (n2 < n1) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } return [ match$1[0], @@ -994,22 +1013,24 @@ function parse_opt(error, active, flags, s) { if (c >= 65) { if (c >= 97) { if (c >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(clear, letter(Caml_string.get(s, i))); _i = i + 1 | 0; continue ; } if (c >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(set, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); _i = i + 1 | 0; @@ -1019,72 +1040,79 @@ function parse_opt(error, active, flags, s) { if (c >= 64) { return loop_letter_num(set_all, i + 1 | 0); } - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } if (c >= 43) { switch (c) { case 43 : return loop_letter_num(set, i + 1 | 0); case 44 : - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); case 45 : return loop_letter_num(clear, i + 1 | 0); } } else { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } }; }; var loop_letter_num = function (myset, i) { if (i >= s.length) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match = Caml_string.get(s, i); if (match >= 65) { if (match >= 97) { if (match >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Caml_string.get(s, i))); return loop(i + 1 | 0); } if (match >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); return loop(i + 1 | 0); } if (match > 57 || match < 48) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match$1 = get_range(i); for(var n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n){ @@ -1178,15 +1206,16 @@ function message(param) { return "the method " + (lab + " is overridden."); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 1694, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 1694, + 26 + ] + } + }); case /* Partial_match */3 : var s$1 = param._0; if (s$1 === "") { @@ -1215,15 +1244,16 @@ function message(param) { return "the instance variable " + (lab$1 + " is overridden.\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 1714, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 1714, + 37 + ] + } + }); case /* Implicit_public_methods */6 : return "the following private methods were made public implicitly:\n " + (Stdlib__String.concat(" ", param._0) + "."); case /* Undeclared_virtual_method */7 : @@ -1346,15 +1376,16 @@ function message(param) { if (param._2) { return "this record of type " + (ty + (" contains fields that are \nnot visible in the current scope: " + (Stdlib__String.concat(" ", slist) + ".\nThey will not be selected if the type becomes unknown."))); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 1776, - 39 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 1776, + 39 + ] + } + }); break; case /* Ambiguous_name */24 : var slist$1 = param._0; @@ -1364,15 +1395,16 @@ function message(param) { if (param._2) { return "these field labels belong to several types: " + (Stdlib__String.concat(" ", param._1) + "\nThe first one was selected. Please disambiguate if this is wrong."); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 1785, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 1785, + 36 + ] + } + }); break; case /* Disambiguated_name */25 : return "this use of " + (param._0 + " required disambiguation."); @@ -1618,10 +1650,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Stdlib__Format.pp_print_flush(ppf, undefined); var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var lines = num_loc_lines.contents; for(var i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i){ @@ -1631,10 +1664,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { } if (lines >= (num_lines - 2 | 0)) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } Caml_io.caml_ml_flush(Stdlib.stdout); Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); @@ -1671,10 +1705,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { function highlight_dumb(ppf, lb, loc) { var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var end_pos = (lb.lex_buffer_len - pos0 | 0) - 1 | 0; var line_start = 0; @@ -1809,7 +1844,9 @@ function highlight_locations(ppf, locs) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { norepeat = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (norepeat) { @@ -1825,7 +1862,9 @@ function highlight_locations(ppf, locs) { if (exn$1.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { status.contents = Caml_external_polyfill.resolve("caml_terminfo_setup")(Stdlib.stdout); @@ -1845,7 +1884,9 @@ function highlight_locations(ppf, locs) { if (exn$2.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } }; @@ -2441,25 +2482,27 @@ function balance(l, d, r) { if (lr) { return mknode(mknode(ll, ld, lr._0), lr._1, mknode(lr._2, d, r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 2781, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 2781, + 11 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 2781, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 2781, + 11 + ] + } + }); } if (hr <= (hl + 1 | 0)) { return mknode(l, d, r); @@ -2477,25 +2520,27 @@ function balance(l, d, r) { if (rl) { return mknode(mknode(l, d, rl._0), rl._1, mknode(rl._2, r._1, r._2)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 2790, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 2790, + 11 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 2790, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 2790, + 11 + ] + } + }); } function add(id, data, param) { @@ -2554,20 +2599,22 @@ function find_same(id, _param) { _param$1 = param$1.previous; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } } _param = c < 0 ? param._0 : param._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2583,10 +2630,11 @@ function find_name(name, _param) { _param = c < 0 ? param._0 : param._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2747,15 +2795,16 @@ function head(_param) { _param = param._0; continue ; case /* Papply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 2970, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 2970, + 22 + ] + } + }); } }; @@ -2972,17 +3021,19 @@ function bal(l, x, d, r) { if (lr) { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -3004,17 +3055,19 @@ function bal(l, x, d, r) { if (rl) { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -3080,10 +3133,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -3120,10 +3174,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -3197,10 +3252,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -3285,10 +3341,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -3323,10 +3380,11 @@ function max_binding(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -3356,11 +3414,12 @@ function remove_min_binding(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge(t1, t2) { @@ -3671,15 +3730,16 @@ function merge$1(f, s1, s2) { var match$1 = split(v2, s1); return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union(f, s1, s2) { @@ -4159,17 +4219,19 @@ function bal$1(l, v, r) { if (lr) { return create$2(create$2(ll, lv, lr.l), lr.v, create$2(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -4189,17 +4251,19 @@ function bal$1(l, v, r) { if (rl) { return create$2(create$2(l, v, rl.l), rl.v, create$2(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$2(x, t) { @@ -4288,10 +4352,11 @@ function min_elt(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -4304,11 +4369,12 @@ function remove_min_elt(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function concat$1(t1, t2) { @@ -4617,17 +4683,19 @@ function bal$2(l, v, r) { if (lr) { return create$3(create$3(ll, lv, lr.l), lr.v, create$3(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -4647,17 +4715,19 @@ function bal$2(l, v, r) { if (rl) { return create$3(create$3(l, v, rl.l), rl.v, create$3(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$3(x, t) { @@ -4746,10 +4816,11 @@ function min_elt$1(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -4762,11 +4833,12 @@ function remove_min_elt$1(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function concat$2(t1, t2) { @@ -5038,17 +5110,19 @@ function bal$3(l, x, d, r) { if (lr) { return create$4(create$4(ll, lv, ld, lr.l), lr.v, lr.d, create$4(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -5070,17 +5144,19 @@ function bal$3(l, x, d, r) { if (rl) { return create$4(create$4(l, x, d, rl.l), rl.v, rl.d, create$4(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$4(x, data, m) { @@ -5138,10 +5214,11 @@ function find$1(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -5166,15 +5243,16 @@ var TypeHash = Stdlib__Hashtbl.Make({ }); function print_raw(param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 4836, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 4836, + 16 + ] + } + }); } var pivot_level = -1; @@ -5394,15 +5472,16 @@ function row_fixed(row) { case /* Tunivar */9 : return true; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 4946, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 4946, + 9 + ] + } + }); } } @@ -5462,15 +5541,16 @@ function proxy(ty) { case /* Tunivar */9 : return ty$1; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 4976, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 4976, + 15 + ] + } + }); } }; case /* Tvariant */8 : @@ -5580,15 +5660,16 @@ function iter_row(f, _row) { case /* Tunivar */9 : break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5023, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5023, + 9 + ] + } + }); } } return may((function (param) { @@ -5857,15 +5938,16 @@ function copy_kind(_param) { if (!param) { return /* Fpresent */0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5172, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5172, + 16 + ] + } + }); } var k = param._0.contents; if (k === undefined) { @@ -5968,25 +6050,27 @@ function copy_type_desc(_keep_namesOpt, f, _ty) { _keep_namesOpt = undefined; continue ; case /* Tsubst */7 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5199, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5199, + 27 + ] + } + }); case /* Tvariant */8 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5194, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5194, + 27 + ] + } + }); case /* Tunivar */9 : return ty; case /* Tpoly */10 : @@ -6014,15 +6098,16 @@ function copy_type_desc(_keep_namesOpt, f, _ty) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5184, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5184, + 26 + ] + } + }); }; }), ty._1); return { @@ -6067,15 +6152,16 @@ var new_kinds = { function dup_kind(r) { var match = r.contents; if (match !== undefined) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5217, - 40 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5217, + 40 + ] + } + }); } if (Stdlib__List.memq(r, new_kinds.contents)) { return ; @@ -6226,15 +6312,16 @@ function memorize_abbrev(mem, priv, path, v, v$p) { function forget_abbrev_rec(mem, path) { if (typeof mem === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5329, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5329, + 6 + ] + } + }); } if (mem.TAG === /* Mcons */0) { if (same(path, mem._1)) { @@ -6252,10 +6339,11 @@ function forget_abbrev_rec(mem, path) { } var mem$p = mem._0; mem$p.contents = forget_abbrev_rec(mem$p.contents, path); - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } function forget_abbrev(mem, path) { @@ -6268,7 +6356,9 @@ function forget_abbrev(mem, path) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -6319,10 +6409,11 @@ function extract_label_aux(_hd, l, _param) { }; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -6495,15 +6586,16 @@ function rev_log(_accu, _param) { var accu = _accu; if (typeof param === "number") { if (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 5465, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 5465, + 15 + ] + } + }); } return accu; } @@ -6525,11 +6617,12 @@ function backtrack(param) { var change = changes.contents; if (typeof change === "number") { if (change) { - throw { - MEL_EXN_ID: "Failure", - _1: "Btype.backtrack", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Btype.backtrack" + } + }); } last_snapshot.contents = old; return ; @@ -6565,24 +6658,26 @@ function read_cmi(filename) { var pre_len = cmi_magic_number.length - 3 | 0; if (Stdlib__String.sub(buffer, 0, pre_len) === Stdlib__String.sub(cmi_magic_number, 0, pre_len)) { var msg = buffer < cmi_magic_number ? "an older" : "a newer"; - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Wrong_version_interface */1, - _0: filename, - _1: msg - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Wrong_version_interface */1, + _0: filename, + _1: msg + } + } + }); } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_an_interface */0, - _0: filename - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_an_interface */0, + _0: filename + } + } + }); } var cmi = input_cmi(ic); Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); @@ -6592,35 +6687,40 @@ function read_cmi(filename) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.End_of_file) { Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Corrupted_interface */2, - _0: filename - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Corrupted_interface */2, + _0: filename + } + } + }); } if (exn.MEL_EXN_ID === Stdlib.Failure) { Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Corrupted_interface */2, - _0: filename - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Corrupted_interface */2, + _0: filename + } + } + }); } if (exn.MEL_EXN_ID === $$Error$1) { Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); - throw { - MEL_EXN_ID: $$Error$1, - _1: exn._1, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: exn._1 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -6771,7 +6871,9 @@ function extract(l, tbl) { tl: assc }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), /* [] */0, l$1); } @@ -7789,7 +7891,9 @@ function get_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7802,7 +7906,9 @@ function mark_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7826,7 +7932,9 @@ function get_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7839,7 +7947,9 @@ function mark_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7853,7 +7963,9 @@ function get_info(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7875,7 +7987,9 @@ function get_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7897,7 +8011,9 @@ function get_pre_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -7919,7 +8035,9 @@ function get_post_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -10230,25 +10348,27 @@ function bal$4(l, x, d, r) { if (lr) { return create$5(create$5(ll, lv, ld, lr._0), lr._1, lr._2, create$5(lr._3, x, d, r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 8866, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 8866, + 11 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 8866, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 8866, + 11 + ] + } + }); } if (hr <= (hl + 1 | 0)) { return create$5(l, x, d, r); @@ -10262,25 +10382,27 @@ function bal$4(l, x, d, r) { if (rl) { return create$5(create$5(l, x, d, rl._0), rl._1, rl._2, create$5(rl._3, r._1, r._2, r._3)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 8873, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 8873, + 11 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 8873, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 8873, + 11 + ] + } + }); } function add$5(x, data, param) { @@ -10324,10 +10446,11 @@ function find$2(x, _param) { _param = c < 0 ? param._0 : param._3; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -10461,7 +10584,9 @@ function module_path(s, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : return { @@ -10496,7 +10621,9 @@ function modtype_path(s, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : return { @@ -10522,7 +10649,9 @@ function type_path(s, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : return { @@ -10730,15 +10859,16 @@ function typexp(s, ty) { exit$3 = 5; break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9179, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9179, + 23 + ] + } + }); } } if (exit$3 === 5) { @@ -11097,7 +11227,9 @@ function modtype(s, mty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return mty; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : return { @@ -11218,15 +11350,16 @@ function modtype_declaration(s, decl) { var add_delayed_check_forward = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9717, - 46 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9717, + 46 + ] + } + }); }) }; @@ -11261,7 +11394,9 @@ function force(f, x) { case /* Done */0 : return x$1._0; case /* Raise */1 : - throw x$1._0; + throw new Error(x$1._0.MEL_EXN_ID, { + cause: x$1._0 + }); case /* Thunk */2 : try { var y = Curry._1(f, x$1._0); @@ -11277,7 +11412,9 @@ function force(f, x) { TAG: /* Raise */1, _0: e }; - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } @@ -11309,7 +11446,9 @@ function already_defined(s, tbl) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -11439,71 +11578,76 @@ function is_implicit_coercion(env) { var components_of_module$p = { contents: (function (env, sub, path, mty) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9965, - 32 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9965, + 32 + ] + } + }); }) }; var components_of_module_maker$p = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9968, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9968, + 37 + ] + } + }); }) }; var components_of_functor_appl$p = { contents: (function (f, p1, p2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9971, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9971, + 23 + ] + } + }); }) }; var check_modtype_inclusion = { contents: (function (env, mty1, path1, mty2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9975, - 35 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9975, + 35 + ] + } + }); }) }; var strengthen = { contents: (function (env, mty, path) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 9979, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 9979, + 28 + ] + } + }); }) }; @@ -11552,17 +11696,19 @@ function bal$5(l, v, r) { if (lr) { return create$6(create$6(ll, lv, lr.l), lr.v, create$6(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -11582,17 +11728,19 @@ function bal$5(l, v, r) { if (rl) { return create$6(create$6(l, v, rl.l), rl.v, create$6(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$7(x, t) { @@ -11686,13 +11834,14 @@ function check_consistency(ps) { if (!Caml_obj.caml_notequal(crco, match[0])) { return ; } - throw { - MEL_EXN_ID: Inconsistency, - _1: name, - _2: source, - _3: match[1], - Error: new Error() - }; + throw new Error(Inconsistency, { + cause: { + MEL_EXN_ID: Inconsistency, + _1: name, + _2: source, + _3: match[1] + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -11702,7 +11851,9 @@ function check_consistency(ps) { source ]); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), ps.ps_crcs); ps.ps_crcs_checked = true; @@ -11711,18 +11862,21 @@ function check_consistency(ps) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Inconsistency) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Inconsistent_import */1, - _0: exn._1, - _1: exn._3, - _2: exn._2 - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Inconsistent_import */1, + _0: exn._1, + _1: exn._3, + _2: exn._2 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -11760,31 +11914,33 @@ function read_pers_struct(modname, filename) { ps_flags: flags }; if (ps.ps_name !== modname) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_renaming */0, - _0: modname, - _1: ps.ps_name, - _2: filename - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_renaming */0, + _0: modname, + _1: ps.ps_name, + _2: filename + } + } + }); } add_import(name); Stdlib__List.iter((function (param) { if (recursive_types.contents) { return ; } - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Need_recursive_types */2, - _0: ps.ps_name, - _1: current_unit.contents - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Need_recursive_types */2, + _0: ps.ps_name, + _1: current_unit.contents + } + } + }); }), ps.ps_flags); Stdlib__Hashtbl.add(persistent_structures, modname, ps); return ps; @@ -11793,10 +11949,11 @@ function read_pers_struct(modname, filename) { function find_pers_struct(checkOpt, name) { var check = checkOpt !== undefined ? checkOpt : true; if (name === "*predef*") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var r; try { @@ -11807,7 +11964,9 @@ function find_pers_struct(checkOpt, name) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { r = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var ps; @@ -11816,10 +11975,11 @@ function find_pers_struct(checkOpt, name) { if (sg !== undefined) { ps = sg; } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { add_import(name); @@ -11831,12 +11991,15 @@ function find_pers_struct(checkOpt, name) { var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { Stdlib__Hashtbl.add(persistent_structures, name, undefined); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } ps = read_pers_struct(name, filename); } @@ -11859,32 +12022,37 @@ function find_module_descr(path, env) { if (id.stamp === 0 && id.name !== current_unit.contents) { return find_pers_struct(undefined, id.name).ps_comps; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : var c = force(components_of_module_maker$p.contents, find_module_descr(path._0, env)); if (c.TAG === /* Structure_comps */0) { return find$2(path._1, c._0.comp_components)[0]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Papply */2 : var p1 = path._0; var f = force(components_of_module_maker$p.contents, find_module_descr(p1, env)); if (f.TAG !== /* Structure_comps */0) { return Curry._3(components_of_functor_appl$p.contents, f._0, p1, path._1); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -11898,15 +12066,17 @@ function find$3(proj1, proj2, path, env) { if (c.TAG === /* Structure_comps */0) { return find$2(path._1, Curry._1(proj2, c._0))[0]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Papply */2 : - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -11964,12 +12134,15 @@ function find_module(alias, path, env) { md_loc: none }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : var c = force(components_of_module_maker$p.contents, find_module_descr(path._0, env)); @@ -11982,19 +12155,21 @@ function find_module(alias, path, env) { md_loc: none }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Papply */2 : var p2 = path._1; var desc1 = find_module_descr(path._0, env); var f = force(components_of_module_maker$p.contents, desc1); if (f.TAG === /* Structure_comps */0) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var f$1 = f._0; var p = f$1.fcomp_res; @@ -12017,7 +12192,9 @@ function find_module(alias, path, env) { Stdlib__Hashtbl.add(f$1.fcomp_subst_cache, p2, mty); md_type$1 = mty; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } @@ -12107,9 +12284,13 @@ function normalize_path(lax, env, path) { if (tmp) { return path$1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -12122,28 +12303,32 @@ function normalize_path$1(oloc, env, path) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { if (oloc !== undefined) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Missing_module */3, - _0: oloc, - _1: path, - _2: normalize_path(true, env, path) - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Missing_module */3, + _0: oloc, + _1: path, + _2: normalize_path(true, env, path) + } + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10272, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10272, + 28 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12161,10 +12346,11 @@ function find_type_expansion(path, env) { } var path$p = normalize_path$1(undefined, env, path); if (same(path, path$p)) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return [ decl.type_params, @@ -12196,10 +12382,11 @@ function find_type_expansion_opt(path, env) { } var path$p = normalize_path$1(undefined, env, path); if (same(path, path$p)) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return [ decl.type_params, @@ -12222,10 +12409,11 @@ function find_modtype_expansion(path, env) { if (mty !== undefined) { return mty; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function is_functor_arg(_path, env) { @@ -12242,7 +12430,9 @@ function is_functor_arg(_path, env) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Pdot */1 : _path = path._0; @@ -12267,10 +12457,11 @@ function lookup_module_descr(lid, env) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { if (s === current_unit.contents) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var ps = find_pers_struct(undefined, s); return [ @@ -12285,7 +12476,9 @@ function lookup_module_descr(lid, env) { ps.ps_comps ]; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Ldot */1 : var s$1 = lid._1; @@ -12303,10 +12496,11 @@ function lookup_module_descr(lid, env) { match$1[0] ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Lapply */2 : var match$2 = lookup_module_descr(lid._0, env); var p1 = match$2[0]; @@ -12314,10 +12508,11 @@ function lookup_module_descr(lid, env) { var match$3 = find_module(false, p2, env); var f = force(components_of_module_maker$p.contents, match$2[1]); if (f.TAG === /* Structure_comps */0) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var f$1 = f._0; may(Curry._3(check_modtype_inclusion.contents, env, match$3.md_type, p2), f$1.fcomp_arg); @@ -12345,10 +12540,11 @@ function lookup_module(load, lid, env) { switch (id.TAG | 0) { case /* Pident */0 : if (id._0.name === "#recmod#") { - throw { - MEL_EXN_ID: Recmodule, - Error: new Error() - }; + throw new Error(Recmodule, { + cause: { + MEL_EXN_ID: Recmodule + } + }); } break; case /* Pdot */1 : @@ -12363,10 +12559,11 @@ function lookup_module(load, lid, env) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { if (s === current_unit.contents) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (transparent_modules.contents && !load) { try { @@ -12380,7 +12577,9 @@ function lookup_module(load, lid, env) { _0: s }); } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } else { @@ -12395,7 +12594,9 @@ function lookup_module(load, lid, env) { } }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Ldot */1 : var s$1 = lid._1; @@ -12410,10 +12611,11 @@ function lookup_module(load, lid, env) { _2: match$1[1] }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Lapply */2 : var match$2 = lookup_module_descr(lid._0, env); var p2 = lookup_module(true, lid._1, env); @@ -12426,10 +12628,11 @@ function lookup_module(load, lid, env) { }; var f = force(components_of_module_maker$p.contents, match$2[1]); if (f.TAG === /* Structure_comps */0) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } may(Curry._3(check_modtype_inclusion.contents, env, match$3.md_type, p2), f._0.fcomp_arg); return p; @@ -12457,15 +12660,17 @@ function lookup(proj1, proj2, lid, env) { match$1[0] ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Lapply */2 : - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -12504,7 +12709,9 @@ function lookup_all_simple(proj1, proj2, shadow, lid, env) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { comps = /* [] */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return Stdlib__List.map((function (param) { @@ -12516,15 +12723,17 @@ function lookup_all_simple(proj1, proj2, shadow, lid, env) { ]; }), comps); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); case /* Lapply */2 : - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -12624,7 +12833,9 @@ function mark_value_used(env, name, vd) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12643,7 +12854,9 @@ function mark_type_used(env, name, vd) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12663,7 +12876,9 @@ function mark_constructor_used(usage, env, name, vd, constr) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12684,7 +12899,9 @@ function mark_extension_used(usage, env, ext, name) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12704,17 +12921,20 @@ function set_type_used_callback(name, td, callback) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10534, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10534, + 22 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } Stdlib__Hashtbl.replace(type_declarations, key, (function (param) { Curry._1(callback, old); @@ -12747,7 +12967,9 @@ function mark_type_path(env, path) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12755,28 +12977,30 @@ function ty_path(t) { var match = repr(t); var match$1 = match.desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10564, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10564, + 9 + ] + } + }); } if (match$1.TAG === /* Tconstr */3) { return match$1._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10564, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10564, + 9 + ] + } + }); } function lookup_constructor(lid, env) { @@ -12788,10 +13012,11 @@ function lookup_constructor(lid, env) { Curry._1(match$1[1], undefined); return desc; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function is_lident(param) { @@ -12826,9 +13051,13 @@ function lookup_all_constructors$1(lid, env) { if (is_lident(lid)) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12856,7 +13085,9 @@ function mark_constructor(usage, env, name, desc) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12868,17 +13099,20 @@ function mark_constructor(usage, env, name, desc) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10601, - 64 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10601, + 64 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var ty_name$1 = last(ty_path$2); mark_constructor_used(usage, env, ty_name$1, ty_decl, name); @@ -12905,9 +13139,13 @@ function lookup_all_labels$1(lid, env) { if (is_lident(lid)) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -12998,7 +13236,9 @@ function iter_types(f) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { safe = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else { @@ -13123,7 +13363,9 @@ function find_all_comps(proj, s, param) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -13242,17 +13484,20 @@ function add_gadt_instances(env, lv, tl) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10759, - 59 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10759, + 59 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } set_typeset(r, Stdlib__List.fold_right(add$3, tl, r.contents)); } @@ -13265,17 +13510,20 @@ function add_gadt_instance_chain(env, lv, t) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 10768, - 59 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 10768, + 59 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var add_instance = function (t) { var t$1 = repr(t); @@ -13304,7 +13552,9 @@ function scrape_alias(env, path, mty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return mty; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Mty_signature */1 : case /* Mty_functor */2 : @@ -13319,7 +13569,9 @@ function scrape_alias(env, path, mty) { if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { return mty; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -13825,7 +14077,9 @@ function prefix_idents_and_subst$1(root, sub, sg) { Stdlib__Hashtbl.add(prefixed_sg, root, sgs$1); sgs = sgs$1; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } try { @@ -13844,7 +14098,9 @@ function prefix_idents_and_subst$1(root, sub, sg) { }; return r; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -13858,7 +14114,9 @@ function add_to_tbl(id, decl, tbl) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { decls = /* [] */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return add$5(id, { @@ -13883,30 +14141,32 @@ function components_of_module(env, sub, path, mty) { function check_value_name(name, loc) { if (bs_only.contents && name === "|.") { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_value_name */4, - _0: loc, - _1: name - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_value_name */4, + _0: loc, + _1: name + } + } + }); } if (!(name.length !== 0 && Caml_string.get(name, 0) === /* '#' */35)) { return ; } for(var i = 1 ,i_finish = name.length; i < i_finish; ++i){ if (Caml_string.get(name, i) === /* '#' */35) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_value_name */4, - _0: loc, - _1: name - }, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_value_name */4, + _0: loc, + _1: name + } + } + }); } } @@ -14477,7 +14737,9 @@ function components_of_functor_appl(f, p1, p2) { Stdlib__Hashtbl.add(f.fcomp_cache, p2, comps); return comps; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -14605,25 +14867,27 @@ function add_local_constraint(id, info, elv, env) { flags: env$1.flags }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 11231, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 11231, + 9 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 11231, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 11231, + 9 + ] + } + }); } function enter(store_fun, name, data, env) { @@ -14893,7 +15157,9 @@ function save_signature(sg, modname, filename) { Caml_io.caml_ml_flush(oc); Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); remove_file(filename); - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -15862,15 +16128,16 @@ register_error_of_exn(function (param) { }); function ill_formed_ast(loc, s) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Ill_formed_ast */6, - _0: loc, - _1: s - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Ill_formed_ast */6, + _0: loc, + _1: s + } + } + }); } function mktyp(d) { @@ -16190,15 +16457,16 @@ function mkexp_constraint(e, param) { _2: t2 }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 12327, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 12327, + 18 + ] + } + }); } function array_function(str, name) { @@ -16216,41 +16484,44 @@ function array_function(str, name) { } function unclosed(opening_name, opening_num, closing_name, closing_num) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Unclosed */0, - _0: rhs_loc(opening_num), - _1: opening_name, - _2: rhs_loc(closing_num), - _3: closing_name - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Unclosed */0, + _0: rhs_loc(opening_num), + _1: opening_name, + _2: rhs_loc(closing_num), + _3: closing_name + } + } + }); } function expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Expecting */1, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Expecting */1, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function not_expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function bigarray_function(str, name) { @@ -16312,15 +16583,16 @@ function check_variable(vl, loc, v) { if (!Stdlib__List.mem(v, vl)) { return ; } - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Variable_in_scope */4, - _0: loc, - _1: v - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Variable_in_scope */4, + _0: loc, + _1: v + } + } + }); } function varify_constructors(var_names, t) { @@ -16728,11 +17000,12 @@ var yytransl_block = [ var yyact = [ (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "parser", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "parser" + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -16753,10 +17026,11 @@ var yyact = [ return Stdlib__Parsing.peek_val(__caml_parser_env, 1); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -17143,15 +17417,16 @@ var yyact = [ } if (exit === 1) { if (Caml_obj.caml_notequal(lbs.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: lbs.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: lbs.lbs_loc, + _1: "attributes" + } + } + }); } var bindings$1 = Stdlib__List.map((function (lb) { return mk$17(lb.lb_loc, lb.lb_attributes, CamlinternalLazy.force(lb.lb_docs), CamlinternalLazy.force(lb.lb_text), lb.lb_pattern, lb.lb_expression); @@ -17757,39 +18032,42 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); if (_1.lbs_extension !== undefined) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "extension" - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "extension" + } + } + }); } if (Caml_obj.caml_notequal(_1.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "attributes" + } + } + }); } return mkclass({ TAG: /* Pcl_let */4, @@ -17970,10 +18248,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -18046,10 +18325,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -18069,10 +18349,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -18611,15 +18892,16 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); @@ -18731,10 +19013,11 @@ var yyact = [ (function (__caml_parser_env) { Stdlib__Parsing.peek_val(__caml_parser_env, 3); Stdlib__Parsing.peek_val(__caml_parser_env, 2); - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -20297,16 +20580,18 @@ var yyact = [ ]; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -21442,17 +21727,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -21461,17 +21748,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -22253,14 +22542,15 @@ var yyact = [ _1: _3 }; } - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Applicative_path */3, - _0: symbol_rloc(undefined) - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Applicative_path */3, + _0: symbol_rloc(undefined) + } + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -22771,53 +23061,60 @@ var yyact = [ }; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }) ]; @@ -22883,16 +23180,17 @@ function assert_same_type(lexbuf, x, y) { var lhs = type_of_directive(x); var rhs = type_of_directive(y); if (lhs !== rhs) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: lhs, - _1: rhs - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: lhs, + _1: rhs + }, + _2: curr(lexbuf) + } + }); } return y; } @@ -22919,7 +23217,9 @@ catch (raw_exn$1){ if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { tmp = ""; } else { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -23035,7 +23335,9 @@ function query(loc, str) { _0: false }; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } if (exit === 2) { try { @@ -23069,7 +23371,9 @@ function query(loc, str) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (typeof v === "number") { @@ -23096,12 +23400,13 @@ function value_of_token(loc, t) { _0: true }; default: - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } else { switch (t.TAG | 0) { @@ -23123,12 +23428,13 @@ function value_of_token(loc, t) { case /* UIDENT */17 : return query(loc, t._0); default: - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } } @@ -23149,12 +23455,13 @@ function directive_parse(token_with_comments, lexbuf) { if (typeof t === "number") { switch (t) { case /* EOF */25 : - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); case /* EOL */100 : _param = undefined; continue ; @@ -23175,15 +23482,16 @@ function directive_parse(token_with_comments, lexbuf) { }; var push = function (e) { if (look_ahead.contents !== undefined) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 24607, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 24607, + 4 + ] + } + }); } look_ahead.contents = e; }; @@ -23224,15 +23532,16 @@ function directive_parse(token_with_comments, lexbuf) { var str = rhs._0; var last_index = str.length - 1 | 0; if (last_index < 0) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } var v = str.charCodeAt(0); var match; @@ -23251,15 +23560,16 @@ function directive_parse(token_with_comments, lexbuf) { switch (v) { case 60 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } match = str[1] === "=" ? [ "Le", @@ -23274,15 +23584,16 @@ function directive_parse(token_with_comments, lexbuf) { break; case 62 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: curr_loc + } + }); } match = str[1] === "=" ? [ "Ge", @@ -23341,30 +23652,32 @@ function directive_parse(token_with_comments, lexbuf) { exit$2 = 3; } if (exit$2 === 3) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } } if (exit$1 === 2) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } break; case "<=" : @@ -23408,15 +23721,16 @@ function directive_parse(token_with_comments, lexbuf) { exit$4 = 2; } if (exit$4 === 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 24626, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 24626, + 17 + ] + } + }); } var curr_loc$1 = curr(lexbuf); var rhs$1 = value_of_token(curr_loc$1, token(undefined)); @@ -23473,52 +23787,56 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 81) { return v; } - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_paren_in_conditional */1, + _2: curr(lexbuf) + } + }); case /* TRUE */91 : return true; default: - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } else { switch (curr_token.TAG | 0) { case /* FLOAT */1 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_float */1 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_float */1 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_float */1, _0: Caml_format.caml_float_of_string(curr_token._0) }); case /* INT */7 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_int */2 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_int */2 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_int */2, _0: curr_token._0 @@ -23530,22 +23848,24 @@ function directive_parse(token_with_comments, lexbuf) { case "undefined" : break; default: - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } var t = token(undefined); var loc = curr(lexbuf); if (typeof t === "number") { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } if (t.TAG === /* UIDENT */17) { var s = t._0; @@ -23559,25 +23879,27 @@ function directive_parse(token_with_comments, lexbuf) { return true; } } - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); break; case /* STRING */16 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_string */3 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_string */3 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_string */3, _0: curr_token._0[0] @@ -23590,24 +23912,26 @@ function directive_parse(token_with_comments, lexbuf) { return value_v._0; } var ty = type_of_directive(value_v); - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: ty - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: ty + }, + _2: curr_loc + } + }); }), value_v); default: - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } }; @@ -23616,12 +23940,13 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 88) { return v; } - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Expect_hash_then_in_conditional */5, + _2: curr(lexbuf) + } + }); } function is_elif(i) { @@ -24111,15 +24436,16 @@ function char_for_decimal_code(lexbuf, i) { if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { return /* 'x' */120; } - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_escape */1, - _0: Stdlib__Lexing.lexeme(lexbuf) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_escape */1, + _0: Stdlib__Lexing.lexeme(lexbuf) + }, + _2: curr(lexbuf) + } + }); } function char_for_hexadecimal_code(lexbuf, i) { @@ -24147,15 +24473,16 @@ function cvt_int64_literal(s) { } function cvt_nativeint_literal(s) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 24914, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 24914, + 30 + ] + } + }); } function remove_underscores(s) { @@ -24189,15 +24516,16 @@ function get_label_name(lexbuf) { var s = Stdlib__Lexing.lexeme(lexbuf); var name = Stdlib__String.sub(s, 1, s.length - 2 | 0); if (Stdlib__Hashtbl.mem(keyword_table, name)) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Keyword_as_label */4, - _0: name - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Keyword_as_label */4, + _0: name + }, + _2: curr(lexbuf) + } + }); } return name; } @@ -24475,15 +24803,16 @@ function token(lexbuf) { switch (__ocaml_lex_state$1) { case 0 : if (!escaped_newlines.contents) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); } update_loc(lexbuf, undefined, 1, false, 0); return token(lexbuf); @@ -24539,7 +24868,9 @@ function token(lexbuf) { _0: s }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case 11 : prerr_warning(curr(lexbuf), { @@ -24574,17 +24905,20 @@ function token(lexbuf) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Literal_overflow */5, - _0: "int" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Literal_overflow */5, + _0: "int" + }, + _2: curr(lexbuf) + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case 15 : return { @@ -24601,17 +24935,20 @@ function token(lexbuf) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Literal_overflow */5, - _0: "int32" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Literal_overflow */5, + _0: "int32" + }, + _2: curr(lexbuf) + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } case 17 : try { @@ -24623,17 +24960,20 @@ function token(lexbuf) { catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Literal_overflow */5, - _0: "int64" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Literal_overflow */5, + _0: "int64" + }, + _2: curr(lexbuf) + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } case 18 : try { @@ -24645,17 +24985,20 @@ function token(lexbuf) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Literal_overflow */5, - _0: "nativeint" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Literal_overflow */5, + _0: "nativeint" + }, + _2: curr(lexbuf) + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } case 19 : reset_string_buffer(undefined); @@ -24718,15 +25061,16 @@ function token(lexbuf) { case 26 : var l = Stdlib__Lexing.lexeme(lexbuf); var esc = Stdlib__String.sub(l, 1, l.length - 1 | 0); - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_escape */1, - _0: esc - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_escape */1, + _0: esc + }, + _2: curr(lexbuf) + } + }); case 27 : var match = with_comment_buffer(comment, lexbuf); return { @@ -24935,29 +25279,32 @@ function token(lexbuf) { return /* EOF */25; } if (if_then_else.contents === /* Dir_if_true */0) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); case 91 : - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -24978,12 +25325,13 @@ function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { continue ; case 1 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 2 : var edelim = Stdlib__Lexing.lexeme(lexbuf); var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); @@ -25045,12 +25393,13 @@ function string(lexbuf) { return string(lexbuf); case 7 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 8 : store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); return string(lexbuf); @@ -25091,15 +25440,16 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { comment_start_loc.contents = /* [] */0; return curr(lexbuf); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 26844, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 26844, + 16 + ] + } + }); case 2 : string_start_loc.contents = curr(lexbuf); store_string_char(/* '"' */34); @@ -25113,36 +25463,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$1 = exn._1; if (typeof match$1 === "number") { if (match$1) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var match$2 = comment_start_loc.contents; if (match$2) { var start = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start, - _1: exn._2 - }, - _2: match$2.hd, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start, + _1: exn._2 + }, + _2: match$2.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 26861, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 26861, + 18 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } is_in_string.contents = false; store_string_char(/* '"' */34); @@ -25163,36 +25521,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$3 = exn$1._1; if (typeof match$3 === "number") { if (match$3) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var match$4 = comment_start_loc.contents; if (match$4) { var start$1 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start$1, - _1: exn$1._2 - }, - _2: match$4.hd, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start$1, + _1: exn$1._2 + }, + _2: match$4.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 26884, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 26884, + 18 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } is_in_string.contents = false; store_string_char(/* '|' */124); @@ -25210,25 +25576,27 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { if (match$5) { var start$2 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$4, - _1: { - TAG: /* Unterminated_comment */2, - _0: start$2 - }, - _2: match$5.hd, - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: { + TAG: /* Unterminated_comment */2, + _0: start$2 + }, + _2: match$5.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 26934, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 26934, + 16 + ] + } + }); case 11 : update_loc(lexbuf, undefined, 1, false, 0); store_string(Stdlib__Lexing.lexeme(lexbuf)); @@ -25321,22 +25689,24 @@ function token$1(lexbuf) { switch (match) { case /* ELSE */23 : if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } break; case /* END */24 : if (if_then_else$1 >= 2) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } if_then_else.contents = /* Dir_out */2; return Curry._1(cont, lexbuf); @@ -25350,12 +25720,13 @@ function token$1(lexbuf) { while(true) { var token = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token, /* SHARP */84) && at_bol(lexbuf)) { var token$1 = token_with_comments(lexbuf); @@ -25370,12 +25741,13 @@ function token$1(lexbuf) { } } if (token$1 === 37) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -25391,12 +25763,13 @@ function token$1(lexbuf) { }; } } - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); default: return Curry._1(look_ahead, match); } @@ -25408,12 +25781,13 @@ function token$1(lexbuf) { return Curry._1(look_ahead, match); } if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -25425,12 +25799,13 @@ function token$1(lexbuf) { var else_seen = _else_seen; var token$2 = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token$2, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token$2, /* SHARP */84) && at_bol(lexbuf)) { var token$3 = token_with_comments(lexbuf); @@ -25441,33 +25816,36 @@ function token$1(lexbuf) { return Curry._1(cont, lexbuf); } if (else_seen) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } _else_seen = true; continue ; } if (token$3 === 37) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } if (else_seen && is_elif(token$3)) { - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$4, { + cause: { + MEL_EXN_ID: $$Error$4, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } continue ; } @@ -25603,7 +25981,9 @@ function skip_phrase(lexbuf) { if (tmp === /* Unterminated_string */0) { continue ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } else { switch (tmp.TAG | 0) { case /* Illegal_character */0 : @@ -25611,11 +25991,15 @@ function skip_phrase(lexbuf) { case /* Unterminated_string_in_comment */3 : continue ; default: - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }; @@ -25643,26 +26027,40 @@ function wrap$1(parsing_fun, lexbuf) { if (err.MEL_EXN_ID === $$Error$4) { var tmp = err._1; if (typeof tmp === "number") { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (tmp.TAG === /* Illegal_character */0) { if (input_name.contents === "//toplevel//") { skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } else { if (err.MEL_EXN_ID === $$Error$3) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (err.MEL_EXN_ID !== Stdlib__Parsing.Parse_error && err.MEL_EXN_ID !== Escape_error) { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } } @@ -25670,14 +26068,15 @@ function wrap$1(parsing_fun, lexbuf) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); } - throw { - MEL_EXN_ID: $$Error$3, - _1: { - TAG: /* Other */5, - _0: loc - }, - Error: new Error() - }; + throw new Error($$Error$3, { + cause: { + MEL_EXN_ID: $$Error$3, + _1: { + TAG: /* Other */5, + _0: loc + } + } + }); } } @@ -25860,7 +26259,9 @@ function alpha_pat(env, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { tmp = /* Tpat_any */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return { @@ -25893,7 +26294,9 @@ function alpha_pat(env, p) { if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { return new_p; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } default: @@ -27498,7 +27901,9 @@ catch (raw_exn$2){ if (exn$3.MEL_EXN_ID === Stdlib.Not_found) { need_to_clear_env = true; } else { - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } @@ -28031,15 +28436,16 @@ function is_object_type(path) { name = path._1; break; case /* Papply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30161, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30161, + 23 + ] + } + }); } return Caml_string.get(name, 0) === /* '#' */35; @@ -28173,7 +28579,9 @@ function set_mode_pattern(generate, injective, f) { umode.contents = old_unification_mode; generate_equations.contents = old_gen; assume_injective.contents = old_inj; - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } @@ -28201,7 +28609,9 @@ function in_pervasives(p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -28217,28 +28627,30 @@ function is_datatype(decl) { function object_fields(ty) { var match = repr(ty).desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30296, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30296, + 27 + ] + } + }); } if (match.TAG === /* Tobject */4) { return match._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30296, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30296, + 27 + ] + } + }); } function flatten_fields(ty) { @@ -28427,15 +28839,16 @@ function concrete_object(ty) { function close_object(ty) { var match = repr(ty).desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30363, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30363, + 25 + ] + } + }); } if (match.TAG === /* Tobject */4) { var _ty = match._0; @@ -28444,15 +28857,16 @@ function close_object(ty) { var ty$2 = repr(ty$1); var match$1 = ty$2.desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30359, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30359, + 30 + ] + } + }); } switch (match$1.TAG | 0) { case /* Tvar */0 : @@ -28461,41 +28875,44 @@ function close_object(ty) { _ty = match$1._3; continue ; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30359, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30359, + 30 + ] + } + }); } }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30363, - 25 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30363, + 25 + ] + } + }); } function row_variable(ty) { var match = repr(ty).desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30377, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30377, + 23 + ] + } + }); } if (match.TAG === /* Tobject */4) { var _ty = match._0; @@ -28504,15 +28921,16 @@ function row_variable(ty) { var ty$2 = repr(ty$1); var match$1 = ty$2.desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30373, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30373, + 30 + ] + } + }); } switch (match$1.TAG | 0) { case /* Tvar */0 : @@ -28521,41 +28939,44 @@ function row_variable(ty) { _ty = match$1._3; continue ; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30373, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30373, + 30 + ] + } + }); } }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30377, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30377, + 23 + ] + } + }); } function set_object_name(id, rv, params, ty) { var match = repr(ty).desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30387, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30387, + 6 + ] + } + }); } if (match.TAG === /* Tobject */4) { return set_name(match._1, [ @@ -28569,29 +28990,31 @@ function set_object_name(id, rv, params, ty) { } ]); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30387, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30387, + 6 + ] + } + }); } function hide_private_methods(ty) { var match = repr(ty).desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30409, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30409, + 6 + ] + } + }); } if (match.TAG === /* Tobject */4) { match._1.contents = undefined; @@ -28605,15 +29028,16 @@ function hide_private_methods(ty) { } }), match$1[0]); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30409, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30409, + 6 + ] + } + }); } function signature_of_class_type(_param) { @@ -28787,10 +29211,11 @@ function closed_schema_rec(_ty) { switch (row.TAG | 0) { case /* Tvar */0 : if (level !== 100000000) { - throw { - MEL_EXN_ID: Non_closed0, - Error: new Error() - }; + throw new Error(Non_closed0, { + cause: { + MEL_EXN_ID: Non_closed0 + } + }); } return iter_type_expr(closed_schema_rec, ty$1); case /* Tfield */5 : @@ -28825,7 +29250,9 @@ function closed_schema(ty) { unmark_type(ty); return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -28887,7 +29314,9 @@ function free_vars_rec(_real, _ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -28946,12 +29375,13 @@ function closed_type(ty) { return ; } var match$1 = match.hd; - throw { - MEL_EXN_ID: Non_closed, - _1: match$1[0], - _2: match$1[1], - Error: new Error() - }; + throw new Error(Non_closed, { + cause: { + MEL_EXN_ID: Non_closed, + _1: match$1[0], + _2: match$1[1] + } + }); } function closed_parameterized_type(params, ty) { @@ -28966,7 +29396,9 @@ function closed_parameterized_type(params, ty) { if (exn.MEL_EXN_ID === Non_closed) { ok = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } Stdlib__List.iter(unmark_type, params); @@ -29006,7 +29438,9 @@ function closed_type_decl(decl) { it_type_declaration(unmark_iterators, decl); return exn._1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29028,7 +29462,9 @@ function closed_extension_constructor(ext) { unmark_extension_constructor(ext); return exn._1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29059,19 +29495,22 @@ function closed_class(params, sign) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Non_closed) { - throw { - MEL_EXN_ID: CCFailure, - _1: { - TAG: /* CC_Method */0, - _0: exn._1, - _1: exn._2, - _2: param[0], - _3: ty - }, - Error: new Error() - }; + throw new Error(CCFailure, { + cause: { + MEL_EXN_ID: CCFailure, + _1: { + TAG: /* CC_Method */0, + _0: exn._1, + _1: exn._2, + _2: param[0], + _3: ty + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), fields); iter_type_expr(mark_type, repr(sign.csig_self)); @@ -29087,7 +29526,9 @@ function closed_class(params, sign) { unmark_class_signature(sign); return exn._1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29195,10 +29636,11 @@ function generalize_spine(_ty) { var forward_try_expand_once = { contents: (function (env, ty) { - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); }) }; @@ -29216,7 +29658,9 @@ function get_level(env, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return binding_time(p); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29232,7 +29676,9 @@ function normalize_package_path(env, _p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { t = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (t === undefined) { @@ -29255,20 +29701,21 @@ function update_level(env, level, _ty) { } var lv = gadt_instance_level(env, ty$1); if (lv !== undefined && level < lv) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty$1, - newty2(level, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty$1, + newty2(level, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); } var row = ty$1.desc; if (typeof row !== "number") { @@ -29284,26 +29731,29 @@ function update_level(env, level, _ty) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Cannot_expand) { if (level < get_level(env, p)) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty$1, - newty2(level, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty$1, + newty2(level, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); } return iter_type_expr((function (param) { return update_level(env, level, param); }), ty$1); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } break; @@ -29319,20 +29769,21 @@ function update_level(env, level, _ty) { case /* Tfield */5 : var ty1 = row._2; if (row._0 === dummy_method && repr(ty1).level > level) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty1, - newty2(level, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty1, + newty2(level, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); } break; case /* Tvariant */8 : @@ -29361,20 +29812,21 @@ function update_level(env, level, _ty) { if (level < get_level(env, p$1)) { var p$p = normalize_package_path(env, p$1); if (same(p$1, p$p)) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty$1, - newty2(level, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty$1, + newty2(level, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); } log_type(ty$1); ty$1.desc = { @@ -29443,7 +29895,9 @@ function generalize_expansive(env, var_level, _ty) { return Types_Variance.may_inv; }), tyl); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } match._2.contents = /* Mnil */0; @@ -29480,23 +29934,30 @@ function generalize_expansive$1(env, ty) { var tr = exn._1; if (tr) { if (tr.tl) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty, - tr.hd[1] - ], - tl: tr - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty, + tr.hd[1] + ], + tl: tr + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29605,7 +30066,9 @@ function inv_type(hash, pty, ty) { return inv_type(hash, partial_arg, param); }), ty$1); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -29639,7 +30102,9 @@ function compute_univars(ty) { return add_univar(univ, param); }), inv.inv_parents); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; Curry._2(TypeHash.iter, (function (ty, inv) { @@ -29657,7 +30122,9 @@ function compute_univars(ty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* Empty */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; } @@ -29718,15 +30185,16 @@ function copy(env, partial, keep_names, ty) { partial[1] ? ty$1.level : current_level.contents ) : 100000000; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 30996, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 30996, + 16 + ] + } + }); } if (forget !== 100000000) { return newty2(forget, { @@ -29865,15 +30333,16 @@ function copy(env, partial, keep_names, ty) { exit$3 = 4; break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31059, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31059, + 24 + ] + } + }); } } switch (exit$3) { @@ -30021,7 +30490,9 @@ function get_new_abstract_name(s) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { index = 0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } reified_var_counter.contents = Curry._3(Meths.add, s, index, reified_var_counter.contents); @@ -30092,15 +30563,16 @@ function instance_constructor(in_pattern, cstr) { }); var tv = copy(undefined, undefined, undefined, existential); if (!is_Tvar(tv)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31182, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31182, + 8 + ] + } + }); } link_type(tv, to_unify); }; @@ -30242,11 +30714,12 @@ function diff_list(l1, l2) { tl: diff_list(l1.tl, l2) }; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Ctype.diff_list", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Ctype.diff_list" + } + }); } function conflicts(free, bound) { @@ -30286,10 +30759,11 @@ function copy_sep(fixed, free, bound, visited, ty) { var match = Stdlib__List.assq(ty$1, visited); var dl = is_Tunivar(ty$1) ? /* [] */0 : diff_list(bound, match[1]); if (Caml_obj.caml_notequal(dl, /* [] */0) && conflicts(univars, dl)) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return match[0]; } @@ -30377,7 +30851,9 @@ function copy_sep(fixed, free, bound, visited, ty) { t$1.desc = tmp; return t$1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30387,15 +30863,16 @@ function instance_poly(keep_namesOpt, fixed, univars, sch) { var copy_var = function (ty) { var name = ty.desc; if (typeof name === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31319, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31319, + 11 + ] + } + }); } if (name.TAG === /* Tunivar */9) { if (keep_names) { @@ -30407,15 +30884,16 @@ function instance_poly(keep_namesOpt, fixed, univars, sch) { return newvar(undefined, undefined); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31319, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31319, + 11 + ] + } + }); }; var vars = Stdlib__List.map(copy_var, univars$1); var pairs = Stdlib__List.map2((function (u, v) { @@ -30465,21 +30943,23 @@ function instance_label(fixed, lbl) { var unify$p = { contents: (function (env, ty1, ty2) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); }) }; function subst(env, level, priv, abbrev, ty, params, args, body) { if (Stdlib__List.length(params) !== Stdlib__List.length(args)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var old_level = current_level.contents; current_level.contents = level; @@ -30488,30 +30968,32 @@ function subst(env, level, priv, abbrev, ty, params, args, body) { if (ty !== undefined) { var match = ty.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31359, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31359, + 8 + ] + } + }); } if (match.TAG === /* Tconstr */3) { var path = match._0; var abbrev$1 = proper_abbrevs(path, match._1, abbrev); memorize_abbrev(abbrev$1, priv, path, ty, body0); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31359, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31359, + 8 + ] + } + }); } } abbreviations.contents = abbrev; @@ -30529,9 +31011,13 @@ function subst(env, level, priv, abbrev, ty, params, args, body) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { current_level.contents = old_level; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30552,15 +31038,16 @@ function expand_abbrev_gen(kind, find_type_expansion, env, ty) { check_abbrev_env(env); var match = ty.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31468, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31468, + 6 + ] + } + }); } if (match.TAG === /* Tconstr */3) { var abbrev = match._2; @@ -30577,7 +31064,9 @@ function expand_abbrev_gen(kind, find_type_expansion, env, ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Unify) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30591,12 +31080,15 @@ function expand_abbrev_gen(kind, find_type_expansion, env, ty) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var ty$p = subst(env, level, kind, abbrev, ty, match$1[0], args, match$1[1]); var ty$2 = repr(ty$p); @@ -30625,20 +31117,21 @@ function expand_abbrev_gen(kind, find_type_expansion, env, ty) { var lv = Caml_obj.caml_max(match$1[2], gadt_instance_level(env, ty)); if (lv !== undefined) { if (level < lv) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty, - newty2(level, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty, + newty2(level, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); } add_gadt_instances(env, lv, { hd: ty, @@ -30652,15 +31145,16 @@ function expand_abbrev_gen(kind, find_type_expansion, env, ty) { } return ty$p; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31468, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31468, + 6 + ] + } + }); } function expand_abbrev(ty) { @@ -30676,17 +31170,20 @@ function expand_head_once(env, ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Cannot_expand) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31476, - 56 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31476, + 56 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30706,7 +31203,9 @@ function safe_abbrev(env, ty) { backtrack(snap); return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30714,18 +31213,20 @@ function try_expand_once(env, ty) { var ty$1 = repr(ty); var match = ty$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } if (match.TAG === /* Tconstr */3) { return repr(expand_abbrev(env)(ty$1)); } - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } function try_expand_safe(env, ty) { @@ -30737,12 +31238,15 @@ function try_expand_safe(env, ty) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { backtrack(snap); - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30756,7 +31260,9 @@ function try_expand_head(try_once, env, ty) { if (exn.MEL_EXN_ID === Cannot_expand) { return ty$p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30778,7 +31284,9 @@ function expand_head_unif(env, ty) { if (exn.MEL_EXN_ID === Cannot_expand) { return repr(ty); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30791,7 +31299,9 @@ function expand_head(env, ty) { if (exn.MEL_EXN_ID === Cannot_expand) { return repr(ty); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30801,10 +31311,11 @@ function extract_concrete_typedecl(env, ty) { var ty$1 = repr(ty); var match = ty$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match.TAG === /* Tconstr */3) { var p = match._0; @@ -30823,12 +31334,15 @@ function extract_concrete_typedecl(env, ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Cannot_expand) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var match$1 = extract_concrete_typedecl(env, ty$2); return [ @@ -30837,10 +31351,11 @@ function extract_concrete_typedecl(env, ty) { match$1[2] ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function expand_abbrev_opt(param, param$1) { @@ -30851,18 +31366,20 @@ function try_expand_once_opt(env, ty) { var ty$1 = repr(ty); var match = ty$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } if (match.TAG === /* Tconstr */3) { return repr(expand_abbrev_opt(env, ty$1)); } - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } function try_expand_head_opt(env, ty) { @@ -30875,7 +31392,9 @@ function try_expand_head_opt(env, ty) { if (exn.MEL_EXN_ID === Cannot_expand) { return ty$p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -30894,22 +31413,25 @@ function expand_head_opt(env, ty) { backtrack(snap); return repr(ty); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } function enforce_constraints(env, ty) { var match = ty.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31586, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31586, + 6 + ] + } + }); } if (match.TAG === /* Tconstr */3) { var level = ty.level; @@ -30928,18 +31450,21 @@ function enforce_constraints(env, ty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31586, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31586, + 6 + ] + } + }); } } @@ -30980,7 +31505,9 @@ function generic_abbrev(env, path) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31009,7 +31536,9 @@ function generic_private_abbrev(env, path) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31033,7 +31562,9 @@ function is_contractive(env, ty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31041,10 +31572,11 @@ var Occur = /* @__PURE__ */Caml_exceptions.create("Ocaml_typedtree_test.Ctype.Oc function occur_rec(env, visited, ty0, ty) { if (ty === ty0) { - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } var occur_ok = recursive_types.contents && is_contractive(env, ty); var match = ty.desc; @@ -31053,10 +31585,11 @@ function occur_rec(env, visited, ty0, ty) { case /* Tconstr */3 : try { if (occur_ok || Stdlib__List.memq(ty, visited)) { - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } var partial_arg = { hd: ty, @@ -31072,10 +31605,11 @@ function occur_rec(env, visited, ty0, ty) { try { var ty$p = try_expand_head$1(try_expand_once, env, ty); if (ty$p === ty0 || Stdlib__List.memq(ty$p, visited)) { - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } var match$1 = ty$p.desc; var exit = 0; @@ -31110,15 +31644,20 @@ function occur_rec(env, visited, ty0, ty) { if (occur_ok) { return ; } - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } break; @@ -31160,10 +31699,17 @@ function occur(env, ty0, ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); merge$2(type_changed, old); - throw exn.MEL_EXN_ID === Occur ? ({ - MEL_EXN_ID: Unify, - _1: /* [] */0 - }) : exn; + throw new Error(( + exn.MEL_EXN_ID === Occur ? ({ + MEL_EXN_ID: Unify, + _1: /* [] */0 + }) : exn + ).MEL_EXN_ID, { + cause: exn.MEL_EXN_ID === Occur ? ({ + MEL_EXN_ID: Unify, + _1: /* [] */0 + }) : exn + }); } } @@ -31177,7 +31723,9 @@ function occur_in(env, ty0, t) { if (exn.MEL_EXN_ID === Unify) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31198,7 +31746,9 @@ function unify_univar(t1, t2, _param) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var match$1 = find_univ(t1, match[0]); @@ -31210,51 +31760,57 @@ function unify_univar(t1, t2, _param) { if (t2 === repr(t$p2)) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$2 !== undefined) { var match$3 = match$2.contents; if (match$3 !== undefined) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } set_univar(match$1, t2); return set_univar(match$2, t1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$2 !== undefined) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); }; } @@ -31293,7 +31849,9 @@ function occur_univar(env, ty) { visited.contents = Curry._3(add$4, ty$1, bound, visited.contents); tmp$1 = true; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -31336,26 +31894,29 @@ function occur_univar(env, ty) { } }(bound)), tl); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case /* Tunivar */9 : if (Curry._2(mem$3, ty$1, bound)) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - ty$1, - newty2(100000000, { - TAG: /* Tvar */0, - _0: undefined - }) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + ty$1, + newty2(100000000, { + TAG: /* Tvar */0, + _0: undefined + }) + ], + tl: /* [] */0 + } + } + }); case /* Tpoly */10 : var bound$1 = Stdlib__List.fold_right(add$3, Stdlib__List.map(repr, match._1), bound); _ty = match._0; @@ -31376,7 +31937,9 @@ function occur_univar(env, ty) { } catch (exn){ unmark_type(ty); - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31441,16 +32004,19 @@ function univars_escape(env, univar_pairs, vl, ty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Stdlib__List.iter(occur, tl); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Tunivar */9 : if (!Curry._2(mem$3, t$1, family)) { return ; } - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); case /* Tpoly */10 : if (Stdlib__List.exists((function (t) { return Curry._2(mem$3, repr(t), family); @@ -31473,7 +32039,9 @@ function univars_escape(env, univar_pairs, vl, ty) { if (exn.MEL_EXN_ID === Occur) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31497,11 +32065,12 @@ function enter_poly(env, univar_pairs, t1, tl1, t2, tl2, f) { _0: t1, _1: tl1$1 }))) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var cl1 = Stdlib__List.map((function (t) { return [ @@ -31539,7 +32108,9 @@ function enter_poly(env, univar_pairs, t1, tl1, t2, tl2, f) { } catch (exn){ univar_pairs.contents = old_univars; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31610,10 +32181,11 @@ function deep_occur(t0, ty) { return ; } if (ty$1 === t0) { - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } ty$1.level = pivot_level - ty$1.level | 0; iter_type_expr(occur_rec, ty$1); @@ -31629,7 +32201,9 @@ function deep_occur(t0, ty) { unmark_type(ty); return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31642,15 +32216,16 @@ function get_newtype_level(param) { if (x !== undefined) { return x; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31961, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31961, + 12 + ] + } + }); } function reify(env, t) { @@ -31710,15 +32285,16 @@ function reify(env, t) { var m = r.row_more; var o$2 = m.desc; if (typeof o$2 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31999, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31999, + 19 + ] + } + }); } if (o$2.TAG === /* Tvar */0) { var o$3 = o$2._0; @@ -31740,15 +32316,16 @@ function reify(env, t) { _0: row })); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 31999, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 31999, + 19 + ] + } + }); } } } @@ -31774,7 +32351,9 @@ function is_newtype(env, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31810,7 +32389,9 @@ function expands_to_datatype(env, ty) { if (exn.MEL_EXN_ID === Cannot_expand) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -31908,52 +32489,57 @@ function mcomp(type_pairs, env, _t1, _t2) { if (match$3.TAG === /* Tconstr */3) { exit$3 = 3; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { switch (match$2.TAG | 0) { case /* Tvar */0 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tvar */0 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32063, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32063, + 30 + ] + } + }); case /* Tconstr */3 : exit$3 = 3; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tarrow */1 : var l1 = match$2._0; if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tarrow */1 : @@ -31964,29 +32550,32 @@ function mcomp(type_pairs, env, _t1, _t2) { _t1 = match$2._2; continue ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tconstr */3 : exit$3 = 3; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Ttuple */2 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Ttuple */2 : @@ -31995,11 +32584,12 @@ function mcomp(type_pairs, env, _t1, _t2) { exit$3 = 3; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tconstr */3 : @@ -32027,7 +32617,9 @@ function mcomp(type_pairs, env, _t1, _t2) { return false; }), tl1); } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } return Stdlib__List.iter2((function (i, param) { @@ -32038,11 +32630,12 @@ function mcomp(type_pairs, env, _t1, _t2) { }), inj, Stdlib__List.combine(tl1, tl2)); } if (non_aliasable(p1, decl) && non_aliasable(p2, decl$p)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var match$4 = decl.type_kind; var match$5 = decl$p.type_kind; @@ -32071,22 +32664,24 @@ function mcomp(type_pairs, env, _t1, _t2) { } exit$4 = 1; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else if (match$4.TAG === /* Type_record */0) { if (typeof match$5 === "number") { if (match$5 === /* Type_abstract */0) { exit$4 = 1; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { if (match$5.TAG === /* Type_record */0) { @@ -32094,35 +32689,39 @@ function mcomp(type_pairs, env, _t1, _t2) { mcomp_list(type_pairs, env, tl1, tl2); return mcomp_record_description(type_pairs, env)(match$4._0, match$5._0); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else if (typeof match$5 === "number") { if (match$5 === /* Type_abstract */0) { exit$4 = 1; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { if (match$5.TAG === /* Type_record */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } mcomp_list(type_pairs, env, tl1, tl2); var xs = match$4._0; @@ -32143,51 +32742,57 @@ function mcomp(type_pairs, env, _t1, _t2) { _x = x.tl; continue ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!y) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); }; } if (exit$4 === 1) { if (typeof match$5 === "number") { if (match$5) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!non_aliasable(p2, decl$p)) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -32196,7 +32801,9 @@ function mcomp(type_pairs, env, _t1, _t2) { if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } p = p1; @@ -32205,11 +32812,12 @@ function mcomp(type_pairs, env, _t1, _t2) { break; case /* Tobject */4 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32218,20 +32826,22 @@ function mcomp(type_pairs, env, _t1, _t2) { case /* Tobject */4 : return mcomp_fields(type_pairs, env, match$2._0, match$3._0); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tfield */5 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32240,11 +32850,12 @@ function mcomp(type_pairs, env, _t1, _t2) { case /* Tfield */5 : return mcomp_fields(type_pairs, env, t1$p$1, t2$p$1); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tlink */6 : @@ -32253,11 +32864,12 @@ function mcomp(type_pairs, env, _t1, _t2) { break; case /* Tvariant */8 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32278,11 +32890,12 @@ function mcomp(type_pairs, env, _t1, _t2) { } }; if (row1$1.row_closed && Stdlib__List.exists(cannot_erase, match$6[1]) || row2$1.row_closed && Stdlib__List.exists(cannot_erase, match$6[0])) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } return Stdlib__List.iter((function (param) { var match = row_field_repr_aux(/* [] */0, param[1]); @@ -32295,59 +32908,65 @@ function mcomp(type_pairs, env, _t1, _t2) { var t1 = match._0; if (t1 !== undefined) { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { var t2 = match$1._0; if (t2 !== undefined) { return mcomp(type_pairs, env, t1, t2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1._0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } return Stdlib__List.iter((function (param) { return mcomp(type_pairs, env, t1, param); }), match$1._1); } else { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { if (match$1._0 === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!match$1._1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { var exit$2 = 0; @@ -32381,11 +33000,12 @@ function mcomp(type_pairs, env, _t1, _t2) { if (match$1._0 !== undefined) { exit = 1; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit === 1) { @@ -32408,31 +33028,34 @@ function mcomp(type_pairs, env, _t1, _t2) { if (match$1._0 === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } }), match$6[2]); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tunivar */9 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32441,11 +33064,12 @@ function mcomp(type_pairs, env, _t1, _t2) { case /* Tunivar */9 : return unify_univar(t1$p$1, t2$p$1, univar_pairs.contents); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tpoly */10 : @@ -32456,11 +33080,12 @@ function mcomp(type_pairs, env, _t1, _t2) { exit$6 = 4; } else { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32476,20 +33101,22 @@ function mcomp(type_pairs, env, _t1, _t2) { } break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$6 === 4) { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32500,21 +33127,23 @@ function mcomp(type_pairs, env, _t1, _t2) { return mcomp(type_pairs, env, param, param$1); })); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } break; case /* Tpackage */11 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$3.TAG | 0) { case /* Tconstr */3 : @@ -32523,11 +33152,12 @@ function mcomp(type_pairs, env, _t1, _t2) { case /* Tpackage */11 : return ; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; @@ -32535,21 +33165,23 @@ function mcomp(type_pairs, env, _t1, _t2) { } if (exit$3 === 3) { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tconstr */3) { p = match$3._0; exit$2 = 2; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$2 === 2) { @@ -32558,23 +33190,28 @@ function mcomp(type_pairs, env, _t1, _t2) { if (!(non_aliasable(p, decl$1) || is_datatype(decl$1))) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -32584,11 +33221,12 @@ function mcomp(type_pairs, env, _t1, _t2) { function mcomp_list(type_pairs, env, tl1, tl2) { if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter2((function (param, param$1) { return mcomp(type_pairs, env, param, param$1); @@ -32597,26 +33235,28 @@ function mcomp_list(type_pairs, env, tl1, tl2) { function mcomp_fields(type_pairs, env, ty1, ty2) { if (!(concrete_object(ty1) && concrete_object(ty2))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32108, - 59 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32108, + 59 + ] + } + }); } var match = flatten_fields(ty2); var match$1 = flatten_fields(ty1); var match$2 = associate_fields(match$1[0], match[0]); mcomp(type_pairs, env, match$1[1], match[1]); if (Caml_obj.caml_notequal(match$2[1], /* [] */0) && Caml_obj.caml_equal(object_row(ty1).desc, /* Tnil */0) || Caml_obj.caml_notequal(match$2[2], /* [] */0) && Caml_obj.caml_equal(object_row(ty2).desc, /* Tnil */0)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter((function (param) { mcomp_kind(param[1], param[3]); @@ -32629,34 +33269,38 @@ function mcomp_kind(k1, k2) { var k2$1 = field_kind_repr(k2); if (typeof k1$1 === "number") { if (k1$1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof k2$1 === "number") { if (!k2$1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof k2$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -32666,20 +33310,22 @@ function mcomp_type_option(type_pairs, env, t, t$p) { if (t$p !== undefined) { return mcomp(type_pairs, env, t, t$p); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (t$p === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } function mcomp_record_description(type_pairs, env) { @@ -32697,26 +33343,29 @@ function mcomp_record_description(type_pairs, env) { _x = x.tl; continue ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!y) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); }; }; return iter; @@ -32752,30 +33401,34 @@ function find_newtype_level(env, path) { if (x !== undefined) { return x; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32239, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32239, + 12 + ] + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32240, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32240, + 20 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -32821,29 +33474,31 @@ function eq_package_path(env, p1, p2) { var nondep_type$p = { contents: (function (param, param$1, param$2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32262, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32262, + 37 + ] + } + }); }) }; var package_subtype = { contents: (function (param, param$1, param$2, param$3, param$4, param$5, param$6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32263, - 48 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32263, + 48 + ] + } + }); }) }; @@ -32919,18 +33574,20 @@ function complete_type_list(allow_absentOpt, env, nl1, lv2, mty2, nl2, tl2) { })(n), env$p); var decl = match[1]; if (decl.type_arity !== 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var match$1 = decl.type_kind; if (typeof match$1 === "number") { if (match$1) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (decl.type_private) { var t2 = decl.type_manifest; @@ -32946,20 +33603,23 @@ function complete_type_list(allow_absentOpt, env, nl1, lv2, mty2, nl2, tl2) { if (allow_absent) { return complete(nl, ntl2); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -32975,12 +33635,15 @@ function complete_type_list(allow_absentOpt, env, nl1, lv2, mty2, nl2, tl2) { } if (exit$1 === 2) { if (exn.MEL_EXN_ID === Stdlib.Exit) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -33008,10 +33671,11 @@ function unify_package(env, unify_list, lv1, p1, n1, tl1, lv2, p2, n2, tl2) { if (eq_package_path(env, p1, p2) || Curry._7(package_subtype.contents, env, p1, n1, tl1, p2, n2, tl2) && Curry._7(package_subtype.contents, env, p2, n2, tl2, p1, n1, tl1)) { return ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function unify_eq(env, t1, t2) { @@ -33031,7 +33695,9 @@ function unify_eq(env, t1, t2) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -33102,7 +33768,9 @@ function unify(env, t1, t2) { if (exn.MEL_EXN_ID === Cannot_expand) { unify2(env, t1$1, t2$1); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else { @@ -33153,19 +33821,22 @@ function unify(env, t1, t2) { var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { reset_trace_gadt_instances(reset_tracing); - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - t1$1, - t2$1 - ], - tl: exn$1._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + t1$1, + t2$1 + ], + tl: exn$1._1 + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -33268,15 +33939,16 @@ function unify_kind(k1, k2) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32636, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32636, + 37 + ] + } + }); } function unify3(env, t1, t1$p, t2, t2$p) { @@ -33368,11 +34040,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { exit$2 = 3; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -33381,11 +34054,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { case /* Tarrow */1 : var l1 = d1._0; if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tarrow */1 : @@ -33405,31 +34079,34 @@ function unify3(env, t1, t1$p, t2, t2$p) { set_commu(match$1._0, match$2); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tconstr */3 : exit$4 = 5; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Ttuple */2 : if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Ttuple */2 : @@ -33439,11 +34116,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { exit$4 = 5; break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tconstr */3 : @@ -33492,7 +34170,9 @@ function unify3(env, t1, t1$p, t2, t2$p) { return false; }), tl1); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } Stdlib__List.iter2((function (i, param) { @@ -33513,7 +34193,9 @@ function unify3(env, t1, t1$p, t2, t2$p) { reify(env, t1); return reify(env, t2); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } })); } @@ -33579,11 +34261,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { break; case /* Tobject */4 : if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tconstr */3 : @@ -33629,11 +34312,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { } break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tfield */5 : @@ -33645,21 +34329,23 @@ function unify3(env, t1, t1$p, t2, t2$p) { } else if (d2.TAG === /* Tconstr */3) { exit$4 = 5; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tvariant */8 : var row1 = d1._0; if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tconstr */3 : @@ -33685,17 +34371,20 @@ function unify3(env, t1, t1$p, t2, t2$p) { } } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tpoly */10 : @@ -33706,11 +34395,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { exit$8 = 6; } else { if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tconstr */3 : @@ -33724,20 +34414,22 @@ function unify3(env, t1, t1$p, t2, t2$p) { } break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$8 === 6) { if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tconstr */3 : @@ -33749,22 +34441,24 @@ function unify3(env, t1, t1$p, t2, t2$p) { })); break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } break; case /* Tpackage */11 : var tl1$2 = d1._2; if (typeof d2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (d2.TAG | 0) { case /* Tconstr */3 : @@ -33781,26 +34475,30 @@ function unify3(env, t1, t1$p, t2, t2$p) { var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { if (umode.contents === /* Expression */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter((function (param) { return reify(env, param); }), Stdlib.$at(tl1$2, tl2$1)); } else { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } break; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; default: @@ -33831,20 +34529,22 @@ function unify3(env, t1, t1$p, t2, t2$p) { } if (exit$3 === 4) { if (typeof d1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (d1.TAG === /* Tconstr */3) { exit$2 = 2; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } switch (exit$2) { @@ -33857,21 +34557,23 @@ function unify3(env, t1, t1$p, t2, t2$p) { } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case 3 : var r = field_kind_repr(kind); if (typeof r === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f !== dummy_method) { set_kind(r._0, /* Fabsent */1); @@ -33881,11 +34583,12 @@ function unify3(env, t1, t1$p, t2, t2$p) { unify(env, newty2(rem.level, /* Tnil */0), rem); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; @@ -33912,13 +34615,16 @@ function unify3(env, t1, t1$p, t2, t2$p) { var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Unify) { t1$p.desc = d1; - throw { - MEL_EXN_ID: Unify, - _1: exn$3._1, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: exn$3._1 + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } @@ -33972,19 +34678,22 @@ function unify_fields(env, ty1, ty2) { _2: t2, _3: desc_3$1 }; - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, desc), - newty2(current_level.contents, desc$1) - ], - tl: exn._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, desc), + newty2(current_level.contents, desc$1) + ], + tl: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$2[0]); } @@ -33993,17 +34702,20 @@ function unify_fields(env, ty1, ty2) { rest1.desc = d1; log_type(rest2); rest2.desc = d2; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } function unify_list(env, tl1, tl2) { if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter2((function (param, param$1) { return unify(env, param, param$1); @@ -34031,19 +34743,22 @@ function unify_row(env, row1, row2) { Stdlib__List.iter((function (param) { var l = param[0]; try { - throw { - MEL_EXN_ID: Tags, - _1: l, - _2: Stdlib__Hashtbl.find(ht, hash_variant(l)), - Error: new Error() - }; + throw new Error(Tags, { + cause: { + MEL_EXN_ID: Tags, + _1: l, + _2: Stdlib__Hashtbl.find(ht, hash_variant(l)) + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), r2); } @@ -34079,17 +34794,18 @@ function unify_row(env, row1, row2) { return Caml_obj.caml_equal(row_field_repr_aux(/* [] */0, param[2]), /* Rabsent */0); } }), pairs)) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - mkvariant(/* [] */0, true), - mkvariant(/* [] */0, true) - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + mkvariant(/* [] */0, true), + mkvariant(/* [] */0, true) + ], + tl: /* [] */0 + } + } + }); } var name = row1$1.row_name !== undefined && (row1$1.row_closed || empty(r2)) && (!row2$1.row_closed || keep(function (f1, f2) { return [ @@ -34109,20 +34825,21 @@ function unify_row(env, row1, row2) { if (Caml_obj.caml_notequal(rest$1, /* [] */0) && (row.row_closed || row_fixed(row)) || closed && row_fixed(row) && !row.row_closed) { var t1 = mkvariant(/* [] */0, true); var t2 = mkvariant(rest$1, false); - throw { - MEL_EXN_ID: Unify, - _1: { - hd: row === row1$1 ? [ - t1, - t2 - ] : [ - t2, - t1 - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: row === row1$1 ? [ + t1, + t2 + ] : [ + t2, + t1 + ], + tl: /* [] */0 + } + } + }); } var rm = row_more(row); if (trace_gadt_instances.contents && Caml_obj.caml_equal(rm.desc, /* Tnil */0) || !trace_gadt_instances.contents) { @@ -34181,61 +34898,68 @@ function unify_row(env, row1, row2) { return ; } if (f2$2.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2._2) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!fixed2) { return set_row_field(f2$2._3, f1$2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } else if (f1$2.TAG === /* Rpresent */0) { var t1 = f1$2._0; if (t1 !== undefined) { if (typeof f2$2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2.TAG === /* Rpresent */0) { var t2 = f2$2._0; if (t2 !== undefined) { return unify(env, t1, t2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2._0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (fixed2) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var e2 = f2$2._3; set_row_field(e2, f1$2); @@ -34249,48 +34973,55 @@ function unify_row(env, row1, row2) { } catch (exn){ e2.contents = undefined; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { if (typeof f2$2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2.TAG === /* Rpresent */0) { if (f2$2._0 === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2._0) { if (f2$2._1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!fixed2) { return set_row_field(f2$2._3, f1$2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { var c1 = f1$2._0; @@ -34299,54 +35030,60 @@ function unify_row(env, row1, row2) { var e1 = f1$2._3; if (typeof f2$2 === "number") { if (m1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!fixed1) { return set_row_field(f1$2._3, f2$2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2.TAG === /* Rpresent */0) { if (c1) { if (f1$2._1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2$2._0 !== undefined) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!fixed1) { return set_row_field(f1$2._3, f2$2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var t2$1 = f2$2._0; if (t2$1 !== undefined) { if (fixed1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var e1$1 = f1$2._3; set_row_field(e1$1, f2$2); @@ -34360,14 +35097,17 @@ function unify_row(env, row1, row2) { } catch (exn$1){ e1$1.contents = undefined; - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { var e2$1 = f2$2._3; @@ -34384,11 +35124,12 @@ function unify_row(env, row1, row2) { if (match) { var t1$1 = match.hd; if (c1 || c2) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter((function(t1$1){ return function (param) { @@ -34465,31 +35206,34 @@ function unify_row(env, row1, row2) { catch (raw_exn){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn$2.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - mkvariant({ - hd: [ - l, - f1 - ], - tl: /* [] */0 - }, true), - mkvariant({ - hd: [ - l, - f2 - ], - tl: /* [] */0 - }, true) - ], - tl: exn$2._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + mkvariant({ + hd: [ + l, + f1 + ], + tl: /* [] */0 + }, true), + mkvariant({ + hd: [ + l, + f2 + ], + tl: /* [] */0 + }, true) + ], + tl: exn$2._1 + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } }), pairs); } @@ -34498,7 +35242,9 @@ function unify_row(env, row1, row2) { rm1.desc = md1; log_type(rm2); rm2.desc = md2; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -34578,18 +35324,21 @@ function unify2(env, t1, t2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: Stdlib__List.map((function (param) { - return [ - param[1], - param[0] - ]; - }), exn._1), - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: Stdlib__List.map((function (param) { + return [ + param[1], + param[0] + ]; + }), exn._1) + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -34600,26 +35349,30 @@ function unify$1(env, ty1, ty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: expand_trace(env.contents, exn._1), - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: expand_trace(env.contents, exn._1) + } + }); } if (exn.MEL_EXN_ID === Recursive_abbrev) { - throw { - MEL_EXN_ID: Unification_recursive_abbrev, - _1: expand_trace(env.contents, { - hd: [ - ty1, - ty2 - ], - tl: /* [] */0 - }), - Error: new Error() - }; + throw new Error(Unification_recursive_abbrev, { + cause: { + MEL_EXN_ID: Unification_recursive_abbrev, + _1: expand_trace(env.contents, { + hd: [ + ty1, + ty2 + ], + tl: /* [] */0 + }) + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -34658,13 +35411,16 @@ function unify_var(env, t1, t2) { ], tl: exn._1 }); - throw { - MEL_EXN_ID: Unify, - _1: expanded_trace, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: expanded_trace + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -34692,11 +35448,12 @@ function filter_arrow(env, t, l) { var t$1 = expand_head_trace(env, t); var match = t$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match.TAG | 0) { case /* Tvar */0 : @@ -34729,17 +35486,19 @@ function filter_arrow(env, t, l) { match._2 ]; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -34749,11 +35508,12 @@ function filter_method_field(env, name, priv, _ty) { var ty$1 = expand_head_trace(env, ty); var match = ty$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match.TAG | 0) { case /* Tvar */0 : @@ -34790,11 +35550,12 @@ function filter_method_field(env, name, priv, _ty) { _ty = match._3; continue ; default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } }; } @@ -34803,11 +35564,12 @@ function filter_method(env, name, priv, ty) { var ty$1 = expand_head_trace(env, ty); var match = ty$1.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match.TAG | 0) { case /* Tvar */0 : @@ -34819,11 +35581,12 @@ function filter_method(env, name, priv, ty) { case /* Tobject */4 : return filter_method_field(env, name, priv, match._0); default: - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -34843,7 +35606,9 @@ function filter_self_method(env, lab, priv, meths, ty) { meths.contents = Curry._3(add$1, lab, pair, meths.contents); return pair; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -34854,10 +35619,11 @@ function moregen_occur(env, level, ty) { return ; } if (is_Tvar(ty$1) && ty$1.level >= 99999999) { - throw { - MEL_EXN_ID: Occur, - Error: new Error() - }; + throw new Error(Occur, { + cause: { + MEL_EXN_ID: Occur + } + }); } ty$1.level = pivot_level - ty$1.level | 0; var row = ty$1.desc; @@ -34882,13 +35648,16 @@ function moregen_occur(env, level, ty) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Occur) { unmark_type(ty); - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } occur_univar(env, ty); update_level(env, level, ty); @@ -34968,11 +35737,12 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { if (typeof match$3 === "number") { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$2.TAG | 0) { case /* Tvar */0 : @@ -34980,18 +35750,20 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { moregen_occur(env, t1$p$1.level, t2$1); return link_type(t1$p$1, t2$1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tarrow */1 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tarrow */1) { var l2 = match$3._0; @@ -35000,102 +35772,115 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { moregen(inst_nongen, type_pairs, env, match$2._1, match$3._1); return moregen(inst_nongen, type_pairs, env, match$2._2, match$3._2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Ttuple */2 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Ttuple */2) { return moregen_list(inst_nongen, type_pairs, env, match$2._0, match$3._0); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tconstr */3 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tconstr */3) { if (same(match$2._0, match$3._0)) { return moregen_list(inst_nongen, type_pairs, env, match$2._1, match$3._1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tobject */4 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tobject */4) { return moregen_fields(inst_nongen, type_pairs, env, match$2._0, match$3._0); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tfield */5 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tfield */5) { return moregen_fields(inst_nongen, type_pairs, env, t1$p$1, t2$p$1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tlink */6 : case /* Tsubst */7 : - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tvariant */8 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tvariant */8) { var row1 = match$2._0; @@ -35120,11 +35905,12 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { ]; var r2$1 = match$5[1]; if (Caml_obj.caml_notequal(match$5[0], /* [] */0) || row1$1.row_closed && (!row2$1.row_closed || Caml_obj.caml_notequal(r2$1, /* [] */0))) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var match$6 = rm1.desc; var match$7 = rm2.desc; @@ -35134,20 +35920,22 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { exit$2 = 2; } else { if (typeof match$7 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$7.TAG === /* Tunivar */9) { unify_univar(rm1, rm2, univar_pairs.contents); } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$2 === 2) { @@ -35155,11 +35943,12 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { exit$1 = 1; } else { if (match$7.TAG === /* Tunivar */9) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } exit$1 = 1; } @@ -35181,35 +35970,39 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { link_type(rm1, ext); } else { if (typeof match$6 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$6.TAG === /* Tconstr */3) { if (typeof match$7 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$7.TAG === /* Tconstr */3) { moregen(inst_nongen, type_pairs, env, rm1, rm2); } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } } @@ -35223,81 +36016,90 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { if (typeof f2 === "number") { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f1.TAG === /* Rpresent */0) { var t1 = f1._0; if (t1 !== undefined) { if (typeof f2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2.TAG === /* Rpresent */0) { var t2 = f2._0; if (t2 !== undefined) { return moregen(inst_nongen, type_pairs, env, t1, t2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } else { if (typeof f2 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2.TAG === /* Rpresent */0) { if (f2._0 === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { var c1 = f1._0; if (c1) { if (!f1._1 && typeof f2 !== "number" && f2.TAG === /* Rpresent */0) { if (f2._0 !== undefined) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (may_inst) { return set_row_field(f1._3, f2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else if (typeof f2 !== "number" && f2.TAG === /* Rpresent */0) { @@ -35309,17 +36111,19 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { moregen(inst_nongen, type_pairs, env, t1, t2$1); }), f1._1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var e1 = f1._3; var tl1 = f1._1; @@ -35327,18 +36131,20 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { if (may_inst) { return set_row_field(e1, f2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (f2.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var e2 = f2._3; if (e1 === e2) { @@ -35347,11 +36153,12 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { var tl2 = f2._1; var c2 = f2._0; if (c1 && !c2) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } set_row_field(e1, { TAG: /* Reither */1, @@ -35374,35 +36181,39 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { if (!Caml_obj.caml_notequal(tl1, /* [] */0)) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } }), match$4[2]); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tunivar */9 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tunivar */9) { return unify_univar(t1$p$1, t2$p$1, univar_pairs.contents); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tpoly */10 : var tl1 = match$2._1; var t1$2 = match$2._0; @@ -35411,11 +36222,12 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { exit$3 = 2; } else { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpoly */10) { if (!match$3._1) { @@ -35423,40 +36235,44 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { } exit$3 = 2; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$3 === 2) { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpoly */10) { return enter_poly(env, univar_pairs, t1$2, tl1, match$3._0, match$3._1, (function (param, param$1) { return moregen(inst_nongen, type_pairs, env, param, param$1); })); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tpackage */11 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpackage */11) { try { @@ -35467,25 +36283,31 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -35494,29 +36316,33 @@ function moregen(inst_nongen, type_pairs, env, t1, t2) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - t1$1, - t2$1 - ], - tl: exn$2._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + t1$1, + t2$1 + ], + tl: exn$2._1 + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } function moregen_list(inst_nongen, type_pairs, env, tl1, tl2) { if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter2((function (param, param$1) { return moregen(inst_nongen, type_pairs, env, param, param$1); @@ -35529,11 +36355,12 @@ function moregen_fields(inst_nongen, type_pairs, env, ty1, ty2) { var rest2 = match$1[1]; var match$2 = associate_fields(match[0], match$1[0]); if (Caml_obj.caml_notequal(match$2[1], /* [] */0)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } moregen(inst_nongen, type_pairs, env, match[1], build_fields(repr(ty2).level)(match$2[2], rest2)); Stdlib__List.iter((function (param) { @@ -35549,31 +36376,34 @@ function moregen_fields(inst_nongen, type_pairs, env, ty1, ty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, { - TAG: /* Tfield */5, - _0: n, - _1: k1, - _2: t1, - _3: rest2 - }), - newty2(current_level.contents, { - TAG: /* Tfield */5, - _0: n, - _1: k2, - _2: t2, - _3: rest2 - }) - ], - tl: exn._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, { + TAG: /* Tfield */5, + _0: n, + _1: k1, + _2: t1, + _3: rest2 + }), + newty2(current_level.contents, { + TAG: /* Tfield */5, + _0: n, + _1: k2, + _2: t2, + _3: rest2 + }) + ], + tl: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$2[0]); } @@ -35586,38 +36416,42 @@ function moregen_kind(k1, k2) { } if (typeof k1$1 === "number") { if (k1$1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof k2$1 === "number") { if (!k2$1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var r = k1$1._0; if (typeof k2$1 !== "number") { return set_kind(r, k2$1); } if (k2$1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } set_kind(r, k2$1); } @@ -35644,7 +36478,9 @@ function moregeneral(env, inst_nongen, pat_sch, subj_sch) { if (exn.MEL_EXN_ID === Unify) { res = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } current_level.contents = old_level; @@ -35754,7 +36590,9 @@ function matches(env, ty, ty$p) { if (exn.MEL_EXN_ID === Unify) { ok = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } backtrack(snap); @@ -35815,11 +36653,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (Stdlib__List.assq(t1$1, subst.contents) === t2$1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -35827,11 +36666,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (Stdlib__List.exists((function (param) { return param[1] === t2$1; }), subst.contents)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } subst.contents = { hd: [ @@ -35842,7 +36682,9 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { }; return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } break; @@ -35887,20 +36729,22 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (typeof match$3 === "number") { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } switch (match$2.TAG | 0) { case /* Tvar */0 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tvar */0) { if (rename) { @@ -35909,11 +36753,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (Stdlib__List.assq(t1$p$1, subst.contents) === t2$p$1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); @@ -35921,11 +36766,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (Stdlib__List.exists((function (param) { return param[1] === t2$p$1; }), subst.contents)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } subst.contents = { hd: [ @@ -35936,29 +36782,34 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { }; return ; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } case /* Tarrow */1 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tarrow */1) { var l2 = match$3._0; @@ -35967,102 +36818,115 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { eqtype(rename, type_pairs, subst, env, match$2._1, match$3._1); return eqtype(rename, type_pairs, subst, env, match$2._2, match$3._2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Ttuple */2 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Ttuple */2) { return eqtype_list(rename, type_pairs, subst, env, match$2._0, match$3._0); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tconstr */3 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tconstr */3) { if (same(match$2._0, match$3._0)) { return eqtype_list(rename, type_pairs, subst, env, match$2._1, match$3._1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tobject */4 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tobject */4) { return eqtype_fields(rename, type_pairs, subst, env, match$2._0, match$3._0); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tfield */5 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tfield */5) { return eqtype_fields(rename, type_pairs, subst, env, t1$p$1, t2$p$1); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tlink */6 : case /* Tsubst */7 : - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tvariant */8 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tvariant */8) { var row1 = match$2._0; @@ -36081,11 +36945,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { var r2 = match$5[1]; var r1 = match$5[0]; if (row1$1.row_closed !== row2$2.row_closed || !row1$1.row_closed && (Caml_obj.caml_notequal(r1, /* [] */0) || Caml_obj.caml_notequal(r2, /* [] */0)) || Caml_obj.caml_notequal(filter_row_fields(false, Stdlib.$at(r1, r2)), /* [] */0)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (!static_row(row1$1)) { eqtype(rename, type_pairs, subst, env, row1$1.row_more, row2$2.row_more); @@ -36097,124 +36962,139 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { if (typeof match$1 === "number") { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match.TAG === /* Rpresent */0) { var t1 = match._0; if (t1 !== undefined) { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { var t2 = match$1._0; if (t2 !== undefined) { return eqtype(rename, type_pairs, subst, env, t1, t2); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } else { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { if (match$1._0 === undefined) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } else if (match._0) { if (match._1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1._0) { if (match$1._1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } else { var match$2 = match._1; if (match$2) { var tl1 = match$2.tl; var t1$1 = match$2.hd; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$1._0) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } var match$3 = match$1._1; if (match$3) { @@ -36234,43 +37114,48 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { }), tl1); } } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } }), match$5[2]); }; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tunivar */9 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tunivar */9) { return unify_univar(t1$p$1, t2$p$1, univar_pairs.contents); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); case /* Tpoly */10 : var tl1 = match$2._1; var t1$2 = match$2._0; @@ -36279,11 +37164,12 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { exit$1 = 2; } else { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpoly */10) { if (!match$3._1) { @@ -36291,40 +37177,44 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { } exit$1 = 2; } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } if (exit$1 === 2) { if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpoly */10) { return enter_poly(env, univar_pairs, t1$2, tl1, match$3._0, match$3._1, (function (param, param$1) { return eqtype(rename, type_pairs, subst, env, param, param$1); })); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } break; case /* Tpackage */11 : if (typeof match$3 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (match$3.TAG === /* Tpackage */11) { try { @@ -36335,25 +37225,31 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } else { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } @@ -36362,29 +37258,33 @@ function eqtype(rename, type_pairs, subst, env, t1, t2) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - t1$1, - t2$1 - ], - tl: exn$4._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + t1$1, + t2$1 + ], + tl: exn$4._1 + } + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } } function eqtype_list(rename, type_pairs, subst, env, tl1, tl2) { if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } Stdlib__List.iter2((function (param, param$1) { return eqtype(rename, type_pairs, subst, env, param, param$1); @@ -36417,11 +37317,12 @@ function eqtype_fields(rename, type_pairs, subst, env, ty1, _ty2) { var match$4 = associate_fields(match[0], match$1[0]); eqtype(rename, type_pairs, subst, env, rest1, rest2); if (Caml_obj.caml_notequal(match$4[1], /* [] */0) || Caml_obj.caml_notequal(match$4[2], /* [] */0)) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } return Stdlib__List.iter((function(rest2){ return function (param) { @@ -36437,31 +37338,34 @@ function eqtype_fields(rename, type_pairs, subst, env, ty1, _ty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, { - TAG: /* Tfield */5, - _0: n, - _1: k1, - _2: t1, - _3: rest2 - }), - newty2(current_level.contents, { - TAG: /* Tfield */5, - _0: n, - _1: k2, - _2: t2, - _3: rest2 - }) - ], - tl: exn._1 - }, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, { + TAG: /* Tfield */5, + _0: n, + _1: k1, + _2: t1, + _3: rest2 + }), + newty2(current_level.contents, { + TAG: /* Tfield */5, + _0: n, + _1: k2, + _2: t2, + _3: rest2 + }) + ], + tl: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }(rest2)), match$4[0]); @@ -36473,34 +37377,38 @@ function eqtype_kind(k1, k2) { var k2$1 = field_kind_repr(k2); if (typeof k1$1 === "number") { if (k1$1) { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof k2$1 === "number") { if (!k2$1) { return ; } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } if (typeof k2$1 === "number") { - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } } @@ -36518,7 +37426,9 @@ function equal$5(env, rename, tyl1, tyl2) { if (exn.MEL_EXN_ID === Unify) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -36555,21 +37465,24 @@ function moregen_clty(trace, type_pairs, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Meth_type_mismatch */5, - _0: param[0], - _1: env, - _2: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Meth_type_mismatch */5, + _0: param[0], + _1: env, + _2: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$2[0]); return Curry._2(Meths.iter, (function (lab, param) { @@ -36580,29 +37493,33 @@ function moregen_clty(trace, type_pairs, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Val_type_mismatch */4, - _0: lab, - _1: env, - _2: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Val_type_mismatch */4, + _0: lab, + _1: env, + _2: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), sign2.csig_vars); case /* Cty_arrow */2 : - throw { - MEL_EXN_ID: Failure, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: /* [] */0 + } + }); } break; @@ -36612,11 +37529,12 @@ function moregen_clty(trace, type_pairs, env, cty1, cty2) { exit = 1; break; case /* Cty_signature */1 : - throw { - MEL_EXN_ID: Failure, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: /* [] */0 + } + }); case /* Cty_arrow */2 : if (cty1._0 === cty2._0) { try { @@ -36625,28 +37543,32 @@ function moregen_clty(trace, type_pairs, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Parameter_mismatch */3, - _0: env, - _1: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Parameter_mismatch */3, + _0: env, + _1: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return moregen_clty(false, type_pairs, env, cty1._2, cty2._2); } - throw { - MEL_EXN_ID: Failure, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: /* [] */0 + } + }); } break; @@ -36662,23 +37584,28 @@ function moregen_clty(trace, type_pairs, env, cty1, cty2) { if (exn$1.MEL_EXN_ID === Failure) { var error = exn$1._1; if (trace || Caml_obj.caml_equal(error, /* [] */0)) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Class_type_mismatch */2, - _0: env, - _1: cty1, - _2: cty2 - }, - tl: error - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Class_type_mismatch */2, + _0: env, + _1: cty1, + _2: cty2 + }, + tl: error + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -36752,7 +37679,9 @@ function match_class_types(traceOpt, env, pat_sch, subj_sch) { tl: err }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$4[0], error$1); var error$3 = Curry._3(Meths.fold, (function (lab, param, err) { @@ -36789,7 +37718,9 @@ function match_class_types(traceOpt, env, pat_sch, subj_sch) { tl: err }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), sign2.csig_vars, error$2); var error$4 = Curry._3(Meths.fold, (function (lab, param, err) { @@ -36840,7 +37771,9 @@ function match_class_types(traceOpt, env, pat_sch, subj_sch) { if (exn.MEL_EXN_ID === Failure) { res = exn._1; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -36887,21 +37820,24 @@ function equal_clty(trace, type_pairs, subst, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Meth_type_mismatch */5, - _0: param[0], - _1: env, - _2: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Meth_type_mismatch */5, + _0: param[0], + _1: env, + _2: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$2[0]); return Curry._2(Meths.iter, (function (lab, param) { @@ -36912,21 +37848,24 @@ function equal_clty(trace, type_pairs, subst, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Val_type_mismatch */4, - _0: lab, - _1: env, - _2: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Val_type_mismatch */4, + _0: lab, + _1: env, + _2: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), sign2.csig_vars); case /* Cty_arrow */2 : @@ -36951,20 +37890,23 @@ function equal_clty(trace, type_pairs, subst, env, cty1, cty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Parameter_mismatch */3, - _0: env, - _1: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Parameter_mismatch */3, + _0: env, + _1: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return equal_clty(false, type_pairs, subst, env, cty1._2, cty2._2); } @@ -36979,19 +37921,20 @@ function equal_clty(trace, type_pairs, subst, env, cty1, cty2) { case 1 : return equal_clty(true, type_pairs, subst, env, cty1, cty2._2); case 2 : - throw { - MEL_EXN_ID: Failure, - _1: trace ? /* [] */0 : ({ - hd: { - TAG: /* CM_Class_type_mismatch */2, - _0: env, - _1: cty1, - _2: cty2 - }, - tl: /* [] */0 - }), - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: trace ? /* [] */0 : ({ + hd: { + TAG: /* CM_Class_type_mismatch */2, + _0: env, + _1: cty1, + _2: cty2 + }, + tl: /* [] */0 + }) + } + }); } } @@ -36999,23 +37942,28 @@ function equal_clty(trace, type_pairs, subst, env, cty1, cty2) { var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Failure) { if (trace) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Class_type_mismatch */2, - _0: env, - _1: cty1, - _2: cty2 - }, - tl: exn$1._1 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Class_type_mismatch */2, + _0: env, + _1: cty1, + _2: cty2 + }, + tl: exn$1._1 + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -37104,15 +38052,16 @@ function match_class_declarations(env, patt_params, patt_type, subj_params, subj } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33612, - 34 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33612, + 34 + ] + } + }); }), match$2[0], error$1); var error$3 = Curry._3(Meths.fold, (function (lab, param, err) { try { @@ -37148,7 +38097,9 @@ function match_class_declarations(env, patt_params, patt_type, subj_params, subj tl: err }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), sign2.csig_vars, error$2); var error$4 = Curry._3(Meths.fold, (function (lab, param, err) { @@ -37185,18 +38136,19 @@ function match_class_declarations(env, patt_params, patt_type, subj_params, subj var lp = Stdlib__List.length(patt_params); var ls = Stdlib__List.length(subj_params); if (lp !== ls) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Parameter_arity_mismatch */0, - _0: lp, - _1: ls - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Parameter_arity_mismatch */0, + _0: lp, + _1: ls + }, + tl: /* [] */0 + } + } + }); } Stdlib__List.iter2((function (p, s) { try { @@ -37205,20 +38157,23 @@ function match_class_declarations(env, patt_params, patt_type, subj_params, subj catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Failure, - _1: { - hd: { - TAG: /* CM_Type_parameter_mismatch */1, - _0: env, - _1: expand_trace(env, exn._1) - }, - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error(Failure, { + cause: { + MEL_EXN_ID: Failure, + _1: { + hd: { + TAG: /* CM_Type_parameter_mismatch */1, + _0: env, + _1: expand_trace(env, exn._1) + }, + tl: /* [] */0 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), patt_params, subj_params); equal_clty(false, type_pairs, subst, env, { @@ -37245,7 +38200,9 @@ function match_class_declarations(env, patt_params, patt_type, subj_params, subj if (exn.MEL_EXN_ID === Failure) { return exn._1; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -37337,10 +38294,11 @@ function find_cltype_for_path(env, p) { if (ty !== undefined) { var match$1 = repr(ty).desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$1.TAG === /* Tobject */4) { var match$2 = match$1._1.contents; @@ -37351,30 +38309,34 @@ function find_cltype_for_path(env, p) { ty ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33719, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33719, + 12 + ] + } + }); } } @@ -37419,7 +38381,9 @@ function build_subtype(env, visited, loops, posi, level, t) { /* Unchanged */0 ]; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Tarrow */1 : if (memq_warn(t$1, visited)) { @@ -37491,10 +38455,11 @@ function build_subtype(env, visited, loops, posi, level, t) { try { var match$2 = t$p$1.desc; if (typeof match$2 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$2.TAG === /* Tobject */4) { if (posi && !opened_object(t$p$1)) { @@ -37504,10 +38469,11 @@ function build_subtype(env, visited, loops, posi, level, t) { var match$4 = ty$1.desc; var match$5; if (typeof match$4 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$4.TAG === /* Tobject */4) { var match$6 = match$4._1.contents; @@ -37518,31 +38484,35 @@ function build_subtype(env, visited, loops, posi, level, t) { match$6[1] ]; } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var tl1 = match$5[1]; if (Stdlib__List.exists((function (param) { return deep_occur(ty$1, param); }), tl1)) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } ty$1.desc = { TAG: /* Tvar */0, @@ -37563,15 +38533,16 @@ function build_subtype(env, visited, loops, posi, level, t) { }, loops$1, posi, pred_enlarge(level$p), match$5[0]); var ty1$p = match$7[0]; if (!is_Tvar(t$p$p)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33782, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33782, + 10 + ] + } + }); } var nm = match$7[1] > /* Equiv */1 || deep_occur(ty$1, ty1$p) ? undefined : [ p, @@ -37590,32 +38561,37 @@ function build_subtype(env, visited, loops, posi, level, t) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33786, - 50 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33786, + 50 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } return [ t$p$p, /* Changed */2 ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); @@ -37634,7 +38610,9 @@ function build_subtype(env, visited, loops, posi, level, t) { ]; } } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } else { if (memq_warn(t$1, visited)) { @@ -37696,7 +38674,9 @@ function build_subtype(env, visited, loops, posi, level, t) { /* Unchanged */0 ]; } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } case /* Tobject */4 : @@ -37755,15 +38735,16 @@ function build_subtype(env, visited, loops, posi, level, t) { } case /* Tlink */6 : case /* Tsubst */7 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33877, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33877, + 6 + ] + } + }); case /* Tvariant */8 : var row = row_repr_aux(/* [] */0, tlist._0); if (memq_warn(t$1, visited) || !static_row(row)) { @@ -37783,15 +38764,16 @@ function build_subtype(env, visited, loops, posi, level, t) { var l = orig[0]; var match = row_field_repr_aux(/* [] */0, orig[1]); if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33844, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33844, + 17 + ] + } + }); } if (match.TAG === /* Rpresent */0) { var t = match._0; @@ -37844,15 +38826,16 @@ function build_subtype(env, visited, loops, posi, level, t) { match$1[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 33844, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 33844, + 17 + ] + } + }); }), fields); var c$6 = collect(fields$1); var row_row_fields = Stdlib__List.map((function (prim) { @@ -37915,12 +38898,13 @@ function enlarge_type(env, ty) { var subtypes = Curry._1(TypePairs.create, 17); function subtype_error(env, trace) { - throw { - MEL_EXN_ID: Subtype, - _1: expand_trace(env, Stdlib__List.rev(trace)), - _2: /* [] */0, - Error: new Error() - }; + throw new Error(Subtype, { + cause: { + MEL_EXN_ID: Subtype, + _1: expand_trace(env, Stdlib__List.rev(trace)), + _2: /* [] */0 + } + }); } function subtype_rec(env, _trace, _t1, _t2, _cstrs) { @@ -38192,10 +39176,11 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { break; case /* Tunivar */9 : if (typeof match$7 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$7.TAG === /* Tunivar */9) { if (row1$1.row_closed === row2$1.row_closed && Caml_obj.caml_equal(r1, /* [] */0) && Caml_obj.caml_equal(match$5[1], /* [] */0)) { @@ -38216,19 +39201,21 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { if (typeof match$1 === "number") { return cstrs; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match.TAG === /* Rpresent */0) { var t1$1 = match._0; if (t1$1 !== undefined) { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { var t2$1 = match$1._0; @@ -38236,118 +39223,135 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { t1 = t1$1; t2 = t2$1; } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { if (match$1._0 !== undefined) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } return cstrs; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else if (match._0) { if (match._1) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1._0) { if (match$1._1) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } return cstrs; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } else { var match$2 = match._1; if (match$2) { if (match$2.tl) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1._0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var match$3 = match$1._1; if (match$3) { if (match$3.tl) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } t1 = match$2.hd; t2 = match$3.hd; } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } return subtype_rec(env, { @@ -38360,20 +39364,23 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { } }(trace)), cstrs$4, pairs); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); default: - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } if (exit$5 === 1) { @@ -38387,10 +39394,11 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { exit$6 = 2; break; default: - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } if (exit$6 === 2) { @@ -38406,10 +39414,11 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { var t1 = match._0; if (t1 !== undefined) { if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { var t2 = match$1._0; @@ -38422,15 +39431,17 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: trace }, t1, t2, cstrs); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else if (!match._0) { @@ -38438,10 +39449,11 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { if (match$2) { var t1$1 = match$2.hd; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { var t2$1 = match$1._0; @@ -38454,48 +39466,55 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: trace }, t1$1, t2$1, cstrs); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$1.TAG === /* Rpresent */0) { if (match$1._0 !== undefined) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } return cstrs; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } }(trace)), cstrs, pairs); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } @@ -38514,7 +39533,9 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: cstrs }; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } default: exit = 1; @@ -38584,7 +39605,9 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: cstrs }; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } else { var match$8 = instance_poly(undefined, false, tl1$1, u1$1); @@ -38647,22 +39670,26 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { backtrack(snap); return Stdlib.$at(cstrs$p, cstrs); } - throw { - MEL_EXN_ID: Unify, - _1: /* [] */0, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: /* [] */0 + } + }); } catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Unify) { backtrack(snap); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } catch (raw_exn$4){ @@ -38678,7 +39705,9 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: cstrs }; } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } default: exit = 1; @@ -38796,7 +39825,9 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { tl: cstrs }; } - throw exn$5; + throw new Error(exn$5.MEL_EXN_ID, { + cause: exn$5 + }); } } if (exit$8 === 4) { @@ -38825,7 +39856,9 @@ function subtype_rec(env, _trace, _t1, _t2, _cstrs) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }; @@ -38852,14 +39885,17 @@ function subtype(env, ty1, ty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Subtype, - _1: expand_trace(env, Stdlib__List.rev(param[0])), - _2: Stdlib__List.tl(Stdlib__List.tl(exn._1)), - Error: new Error() - }; + throw new Error(Subtype, { + cause: { + MEL_EXN_ID: Subtype, + _1: expand_trace(env, Stdlib__List.rev(param[0])), + _2: Stdlib__List.tl(Stdlib__List.tl(exn._1)) + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), Stdlib__List.rev(cstrs)); }; @@ -38890,15 +39926,16 @@ function unalias_object(ty) { case /* Tunivar */9 : return ty$1; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 34141, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 34141, + 6 + ] + } + }); } } @@ -38980,7 +40017,9 @@ function cyclic_abbrev(env, id, ty) { if (exn.MEL_EXN_ID === Unify) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return check_cycle(/* [] */0, ty); @@ -39199,18 +40238,22 @@ function nondep_type_rec(env, id, _ty) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Cannot_expand) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { tmp = { @@ -39283,7 +40326,9 @@ function nondep_type_rec(env, id, _ty) { _0: row$2 }); } else { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } break; @@ -39292,10 +40337,11 @@ function nondep_type_rec(env, id, _ty) { if (isfree(id, p$2)) { var p$p = normalize_package_path(env, p$2); if (isfree(id, p$p)) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } tmp = { TAG: /* Tpackage */11, @@ -39321,7 +40367,9 @@ function nondep_type_rec(env, id, _ty) { ty$p.desc = tmp; return ty$p; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -39340,12 +40388,15 @@ function nondep_type(env, id, ty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { Curry._1(TypeHash.clear, nondep_hash); Curry._1(TypeHash.clear, nondep_variants); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -39421,10 +40472,14 @@ function nondep_type_decl(env, mid, id, is_covariant, decl) { if (is_covariant) { tk = /* Type_abstract */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var tm; @@ -39438,10 +40493,14 @@ function nondep_type_decl(env, mid, id, is_covariant, decl) { if (is_covariant) { tm = undefined; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } Curry._1(TypeHash.clear, nondep_hash); @@ -39464,12 +40523,15 @@ function nondep_type_decl(env, mid, id, is_covariant, decl) { if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { Curry._1(TypeHash.clear, nondep_hash); Curry._1(TypeHash.clear, nondep_variants); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -39488,10 +40550,11 @@ function nondep_extension_constructor(env, mid, ext) { var ty$p = nondep_type_rec(env, mid, ty); var match$1 = repr(ty$p).desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$1.TAG === /* Tconstr */3) { match = [ @@ -39499,10 +40562,11 @@ function nondep_extension_constructor(env, mid, ext) { match$1._1 ]; } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { var type_params = Stdlib__List.map((function (param) { @@ -39536,12 +40600,15 @@ function nondep_extension_constructor(env, mid, ext) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { Curry._1(TypeHash.clear, nondep_hash); Curry._1(TypeHash.clear, nondep_variants); - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -39604,15 +40671,16 @@ function nondep_class_type(env, id, _param) { function nondep_class_declaration(env, id, decl) { if (isfree(id, decl.cty_path)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 34461, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 34461, + 2 + ] + } + }); } var ty = decl.cty_new; var decl$1 = { @@ -39633,15 +40701,16 @@ function nondep_class_declaration(env, id, decl) { function nondep_cltype_declaration(env, id, decl) { if (isfree(id, decl.clty_path)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 34480, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 34480, + 2 + ] + } + }); } var decl_clty_params = Stdlib__List.map((function (param) { return nondep_type_rec(env, id, param); @@ -40156,10 +41225,11 @@ function print_simple_out_type(ppf, ty) { var single = tys.hd; if (typeof single !== "number" && single.TAG === /* Otyp_tuple */9) { if (tys.tl) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (variant === "Arity_1") { return { @@ -40180,10 +41250,11 @@ function print_simple_out_type(ppf, ty) { } } if (tys.tl) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return { TAG: /* Otyp_arrow */1, @@ -40192,10 +41263,11 @@ function print_simple_out_type(ppf, ty) { _2: result }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; var exit$3 = 0; var res; @@ -40317,10 +41389,11 @@ function print_simple_out_type(ppf, ty) { var single = tys.hd; if (typeof single !== "number" && single.TAG === /* Otyp_tuple */9) { if (tys.tl) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (variant$1 === "Arity_1") { return { @@ -40341,10 +41414,11 @@ function print_simple_out_type(ppf, ty) { } } if (tys.tl) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return { TAG: /* Otyp_arrow */1, @@ -40353,10 +41427,11 @@ function print_simple_out_type(ppf, ty) { _2: result }; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; var exit$4 = 0; var res$1; @@ -40481,15 +41556,16 @@ function print_simple_out_type(ppf, ty) { _1: "@[<0>(%a@ [@mel.meth])@]" }), print_out_type_1, res$1); default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 34910, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 34910, + 17 + ] + } + }); } } @@ -41563,41 +42639,45 @@ var out_class_type = { var out_module_type = { contents: (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "Oprint.out_module_type", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Oprint.out_module_type" + } + }); }) }; var out_sig_item = { contents: (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "Oprint.out_sig_item", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Oprint.out_sig_item" + } + }); }) }; var out_signature = { contents: (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "Oprint.out_signature", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Oprint.out_signature" + } + }); }) }; var out_type_extension = { contents: (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "Oprint.out_type_extension", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Oprint.out_type_extension" + } + }); }) }; @@ -43529,7 +44609,9 @@ function ident_name(id) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return id.name; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -43544,7 +44626,9 @@ function add_unique(id) { unique_names.contents = add(id, unique_toplevel_name(id), unique_names.contents); return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -45303,17 +46387,19 @@ function bal$6(l, x, d, r) { if (lr) { return create$7(create$7(ll, lv, ld, lr.l), lr.v, lr.d, create$7(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -45335,17 +46421,19 @@ function bal$6(l, x, d, r) { if (rl) { return create$7(create$7(l, x, d, rl.l), rl.v, rl.d, create$7(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$8(x, data, m) { @@ -45403,10 +46491,11 @@ function find$4(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -45426,10 +46515,11 @@ function index(l, x) { return 1 + index(l.tl, x) | 0; } } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function uniq(_param) { @@ -45502,7 +46592,9 @@ function normalize_type_path(cacheOpt, env, p) { /* Id */0 ]; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -45594,7 +46686,9 @@ function set_printing_env(env) { }, printing_map.contents); return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }); var cont = function (param) { @@ -45682,10 +46776,11 @@ function best_type_path(p) { }), l); continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; while((function () { @@ -45701,7 +46796,9 @@ function best_type_path(p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { tmp$1 = true; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } tmp = tmp$1; @@ -45722,7 +46819,9 @@ function best_type_path(p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { p$p$p = p$p; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return [ @@ -45846,7 +46945,9 @@ function name_of_type(t) { } return name; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -46395,15 +47496,16 @@ function tree_of_typobject(sch, fi, nm) { }), match.tl); var match$1 = best_type_path(nm[0]); if (!Caml_obj.caml_equal(match$1[1], /* Id */0)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 36171, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 36171, + 6 + ] + } + }); } return { TAG: /* Otyp_class */2, @@ -48081,15 +49183,16 @@ function mismatch(unif, param) { return ; } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 36822, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 36822, + 9 + ] + } + }); } function explanation(unif, mis, ppf) { @@ -49166,29 +50269,33 @@ function report_unification_error(ppf, env, unifOpt, tr, txt1, txt2) { } catch (exn){ print_labels.contents = true; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 36921, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 36921, + 20 + ] + } + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 36921, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 36921, + 20 + ] + } + }); } })); } @@ -49221,7 +50328,9 @@ function trace$1(fst, keep_last, txt, ppf, tr) { } catch (exn){ print_labels.contents = true; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -50015,7 +51124,9 @@ function type_manifest(env, ty1, params1, ty2, params2, priv2) { if (exn.MEL_EXN_ID === Cannot_expand) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return check_super(ty1); @@ -50689,7 +51800,9 @@ function scrape(env, mty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return mty; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -50983,10 +52096,11 @@ function nondep_supertype(env, mid, mty) { var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { if (va) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } return { hd: { @@ -51001,7 +52115,9 @@ function nondep_supertype(env, mid, mty) { tl: rem$p }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Sig_class */5 : return { @@ -51073,7 +52189,9 @@ function enrich_typedecl(env, p, decl) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return decl; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -51197,20 +52315,24 @@ function contains_type(env, _param) { if (mty !== undefined) { return contains_type(env, mty); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Mty_signature */1 : return contains_type_sig(env)(param._0); @@ -51241,22 +52363,25 @@ function contains_type_sig(env) { if (match.type_private) { return ; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); case /* Sig_module */3 : return contains_type(env, param._1.md_type); case /* Sig_modtype */4 : - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); default: return ; } @@ -51274,7 +52399,9 @@ function contains_type$1(env, mty) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -51323,17 +52450,19 @@ function bal$7(l, v, r) { if (lr) { return create$8(create$8(ll, lv, lr.l), lr.v, create$8(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -51353,17 +52482,19 @@ function bal$7(l, v, r) { if (rl) { return create$8(create$8(l, v, rl.l), rl.v, create$8(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$9(x, t) { @@ -51549,17 +52680,19 @@ function bal$8(l, x, d, r) { if (lr) { return create$9(create$9(ll, lv, ld, lr.l), lr.v, lr.d, create$9(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -51581,17 +52714,19 @@ function bal$8(l, x, d, r) { if (rl) { return create$9(create$9(l, x, d, rl.l), rl.v, rl.d, create$9(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$10(x, data, m) { @@ -51649,10 +52784,11 @@ function find$5(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -51695,17 +52831,19 @@ function bal$9(l, v, r) { if (lr) { return create$10(create$10(ll, lv, lr.l), lr.v, create$10(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -51725,17 +52863,19 @@ function bal$9(l, v, r) { if (rl) { return create$10(create$10(l, v, rl.l), rl.v, create$10(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$11(x, t) { @@ -51950,7 +53090,9 @@ function rollback_path(subst, _p) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }; @@ -51970,7 +53112,9 @@ function collect_ids(subst, bindings, p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { ids = /* Empty */0; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return Curry._2(add$11, id$1, ids); @@ -52153,10 +53297,11 @@ function value_descriptions(env, cxt, subst, id, vd1, vd2) { if (Caml_obj.caml_equal(p1, match$1._0)) { return /* Tcoerce_none */0; } - throw { - MEL_EXN_ID: Dont_match, - Error: new Error() - }; + throw new Error(Dont_match, { + cause: { + MEL_EXN_ID: Dont_match + } + }); } if (typeof match$1 === "number") { return /* Tcoerce_none */0; @@ -52164,39 +53309,44 @@ function value_descriptions(env, cxt, subst, id, vd1, vd2) { if (match$1.TAG !== /* Val_prim */0) { return /* Tcoerce_none */0; } - throw { - MEL_EXN_ID: Dont_match, - Error: new Error() - }; + throw new Error(Dont_match, { + cause: { + MEL_EXN_ID: Dont_match + } + }); } else { - throw { - MEL_EXN_ID: Dont_match, - Error: new Error() - }; + throw new Error(Dont_match, { + cause: { + MEL_EXN_ID: Dont_match + } + }); } } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Dont_match) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Value_descriptions */1, - _0: id, - _1: vd1, - _2: vd2$1 + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Value_descriptions */1, + _0: id, + _1: vd1, + _2: vd2$1 + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -52208,24 +53358,25 @@ function type_declarations$2(env, old_envOpt, cxt, subst, id, decl1, decl2) { if (!Caml_obj.caml_notequal(err, /* [] */0)) { return ; } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - old_env, - { - TAG: /* Type_declarations */2, - _0: id, - _1: decl1, - _2: decl2$1, - _3: err + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + old_env, + { + TAG: /* Type_declarations */2, + _0: id, + _1: decl1, + _2: decl2$1, + _3: err + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } function extension_constructors$1(env, cxt, subst, id, ext1, ext2) { @@ -52233,23 +53384,24 @@ function extension_constructors$1(env, cxt, subst, id, ext1, ext2) { if (extension_constructors(env, id, ext1, ext2$1)) { return ; } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Extension_constructors */3, - _0: id, - _1: ext1, - _2: ext2$1 + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Extension_constructors */3, + _0: id, + _1: ext1, + _2: ext2$1 + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } function class_type_declarations$1(old_env, env, cxt, subst, id, decl1, decl2) { @@ -52258,24 +53410,25 @@ function class_type_declarations$1(old_env, env, cxt, subst, id, decl1, decl2) { if (!reason) { return ; } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - old_env, - { - TAG: /* Class_type_declarations */7, - _0: id, - _1: decl1, - _2: decl2$1, - _3: reason + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + old_env, + { + TAG: /* Class_type_declarations */7, + _0: id, + _1: decl1, + _2: decl2$1, + _3: reason + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } function class_declarations$1(old_env, env, cxt, subst, id, decl1, decl2) { @@ -52284,24 +53437,25 @@ function class_declarations$1(old_env, env, cxt, subst, id, decl1, decl2) { if (!reason) { return ; } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - old_env, - { - TAG: /* Class_declarations */8, - _0: id, - _1: decl1, - _2: decl2$1, - _3: reason + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + old_env, + { + TAG: /* Class_declarations */8, + _0: id, + _1: decl1, + _2: decl2$1, + _3: reason + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } var Dont_match$1 = /* @__PURE__ */Caml_exceptions.create("Ocaml_typedtree_test.Includemod.Dont_match"); @@ -52316,7 +53470,9 @@ function may_expand_module_path(env, path) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -52327,23 +53483,26 @@ function expand_module_path(env, cxt, path) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Unbound_modtype_path */9, - _0: path + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Unbound_modtype_path */9, + _0: path + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -52354,23 +53513,26 @@ function expand_module_alias(env, cxt, path) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Unbound_module_path */10, - _0: path + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Unbound_module_path */10, + _0: path + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -52495,48 +53657,56 @@ function modtypes(env, cxt, subst, mty1, mty2) { catch (raw_err){ var err = Caml_js_exceptions.internalToOCamlException(raw_err); if (err.MEL_EXN_ID === Dont_match$1) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Module_types */4, - _0: mty1, - _1: modtype(subst, mty2) + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Module_types */4, + _0: mty1, + _1: modtype(subst, mty2) + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } if (err.MEL_EXN_ID === $$Error$5) { if (mty1.TAG === /* Mty_alias */3) { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (mty2.TAG === /* Mty_alias */3) { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Module_types */4, - _0: mty1, - _1: modtype(subst, mty2) + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Module_types */4, + _0: mty1, + _1: modtype(subst, mty2) + } + ], + tl: err._1 + } } - ], - tl: err._1 - }, - Error: new Error() - }; + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } } @@ -52559,10 +53729,11 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { return signatures(env, cxt, subst, mty1._0, mty2._0); case /* Mty_functor */2 : case /* Mty_alias */3 : - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); } break; @@ -52604,16 +53775,18 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { }; } } - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); case /* Mty_signature */1 : case /* Mty_alias */3 : - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); } } else { @@ -52622,10 +53795,11 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { break; case /* Mty_functor */2 : if (mty2._1 !== undefined) { - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); } var cc = modtypes(env, { hd: { @@ -52645,10 +53819,11 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { } case /* Mty_signature */1 : case /* Mty_alias */3 : - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); } } @@ -52658,21 +53833,22 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { if (mty2.TAG === /* Mty_alias */3) { var p2 = mty2._0; if (is_functor_arg(p2, env)) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Invalid_module_alias */11, - _0: p2 + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Invalid_module_alias */11, + _0: p2 + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } if (same(p1$1, p2)) { return /* Tcoerce_none */0; @@ -52682,10 +53858,11 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { if (same(p1$2, p2$1)) { return /* Tcoerce_none */0; } - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); } var p1$3; try { @@ -52696,25 +53873,30 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { if (exn.MEL_EXN_ID === $$Error$2) { var match = exn._1; if (match.TAG === /* Missing_module */3) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Unbound_module_path */10, - _0: match._2 + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Unbound_module_path */10, + _0: match._2 + } + ], + tl: /* [] */0 + } } - ], - tl: /* [] */0 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var mty1$1 = strengthen$1(env, expand_module_alias(env, cxt, p1$3), p1$3); return { @@ -52733,34 +53915,37 @@ function try_modtypes(env, cxt, subst, _mty1, mty2) { } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38374, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38374, + 6 + ] + } + }); } } if (mty2$1.TAG === /* Mty_ident */0) { return try_modtypes(env, cxt, identity, mty1, expand_module_path(env, cxt, mty2$1._0)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38374, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38374, + 6 + ] + } + }); } - throw { - MEL_EXN_ID: Dont_match$1, - Error: new Error() - }; + throw new Error(Dont_match$1, { + cause: { + MEL_EXN_ID: Dont_match$1 + } + }); }; } @@ -52915,15 +54100,18 @@ function signatures(env, cxt, subst, sig1, sig2) { _unpaired = unpaired$1; continue ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { if (unpaired) { - throw { - MEL_EXN_ID: $$Error$5, - _1: unpaired, - Error: new Error() - }; + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: unpaired + } + }); } var cc = signature_components(env, new_env, cxt, subst, Stdlib__List.rev(paired)); if (len1 === len2) { @@ -53071,15 +54259,16 @@ function signature_components(old_env, env, cxt, subst, paired) { break; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38499, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38499, + 6 + ] + } + }); } function modtype_infos(env, cxt, subst, id, info1, info2) { @@ -53116,25 +54305,28 @@ function modtype_infos(env, cxt, subst, id, info1, info2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - { - TAG: /* Modtype_infos */5, - _0: id, - _1: info1, - _2: info2$1 + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + { + TAG: /* Modtype_infos */5, + _0: id, + _1: info1, + _2: info2$1 + } + ], + tl: exn._1 + } } - ], - tl: exn._1 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -53144,18 +54336,19 @@ function check_modtype_equiv(env, cxt, mty1, mty2) { if (typeof match === "number" && typeof match$1 === "number") { return ; } - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - cxt, - env, - /* Modtype_permutation */0 - ], - tl: /* [] */0 - }, - Error: new Error() - }; + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + cxt, + env, + /* Modtype_permutation */0 + ], + tl: /* [] */0 + } + } + }); } function check_modtype_inclusion$1(env, mty1, path1, mty2) { @@ -53166,12 +54359,15 @@ function check_modtype_inclusion$1(env, mty1, path1, mty2) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -53184,24 +54380,27 @@ function compunit(env, impl_name, impl_sig, intf_name, intf_sig) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$5, - _1: { - hd: [ - /* [] */0, - empty, - { - TAG: /* Interface_mismatch */6, - _0: impl_name, - _1: intf_name + throw new Error($$Error$5, { + cause: { + MEL_EXN_ID: $$Error$5, + _1: { + hd: [ + /* [] */0, + empty, + { + TAG: /* Interface_mismatch */6, + _0: impl_name, + _1: intf_name + } + ], + tl: exn._1 + } } - ], - tl: exn._1 - }, - Error: new Error() - }; + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -54299,36 +55498,39 @@ function path_of_context(param) { }; continue ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38670, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38670, + 15 + ] + } + }); }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38672, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38672, + 9 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 38672, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 38672, + 9 + ] + } + }); } function context$1(ppf, cxt) { @@ -54986,15 +56188,16 @@ function compat(_p, _q) { _q = match$1._1; continue ; case 3 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39141, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39141, + 6 + ] + } + }); } }; @@ -55013,28 +56216,30 @@ function compats(_ps, _qs) { _ps = ps.tl; continue ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39146, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39146, + 12 + ] + } + }); } if (!qs) { return true; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39146, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39146, + 12 + ] + } + }); }; } @@ -56167,7 +57372,9 @@ function simple_match_args(p1, _p2) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return omega; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }(arg$1)), omegas); @@ -56351,7 +57558,9 @@ function discr_pat(q, pss) { tl: r }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), match$1._0, record_arg(acc)); _pss = pss$1.tl; @@ -56452,15 +57661,16 @@ function do_set_args(erase_mutable, q, r) { r.tl ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39485, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39485, + 13 + ] + } + }); } } else { match$2 = [ @@ -56942,55 +58152,59 @@ function row_of_pat(pat) { var match = expand_head(pat.pat_env, pat.pat_type); var row = match.desc; if (typeof row === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39637, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39637, + 9 + ] + } + }); } if (row.TAG === /* Tvariant */8) { return row_repr_aux(/* [] */0, row._0); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39637, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39637, + 9 + ] + } + }); } function generalized_constructor(x) { var match = x[0].pat_desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39648, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39648, + 9 + ] + } + }); } if (match.TAG === /* Tpat_construct */4) { return match._1.cstr_generalized; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39648, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39648, + 9 + ] + } + }); } function clean_env(env) { @@ -57045,28 +58259,30 @@ function full_match(ignore_generalized, closing, env) { var fields = Stdlib__List.map((function (param) { var match = param[0].pat_desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39675, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39675, + 17 + ] + } + }); } if (match.TAG === /* Tpat_variant */5) { return match._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39675, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39675, + 17 + ] + } + }); }), env); var row = row_of_pat(p); if (closing && !row_fixed(row)) { @@ -57153,15 +58369,16 @@ function complete_tags(nconsts, nconstrs, tags) { case /* Cstr_block */1 : return Caml_array.set(seen_constr, param._0, true); case /* Cstr_extension */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39738, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39738, + 14 + ] + } + }); } }), tags); @@ -57236,10 +58453,11 @@ function pat_of_constrs(ex_pat, param) { return pat_of_constr(ex_pat, cstr); } } - throw { - MEL_EXN_ID: Empty, - Error: new Error() - }; + throw new Error(Empty, { + cause: { + MEL_EXN_ID: Empty + } + }); } function get_variant_constructors(env, _ty) { @@ -57342,15 +58560,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39892, - 55 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39892, + 55 + ] + } + }); }), (function (i) { return { TAG: /* Tpat_constant */2, @@ -57372,15 +58591,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39867, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39867, + 15 + ] + } + }); }), env); var _param = { hd: [ @@ -57425,10 +58645,11 @@ function build_other(ext, env) { while(true) { var i = _i; if (i > imax) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var ci = Stdlib__Char.chr(i); if (!Stdlib__List.mem(ci, all_chars)) { @@ -57450,7 +58671,9 @@ function build_other(ext, env) { _param = param.tl; continue ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; case /* Const_string */2 : @@ -57462,15 +58685,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39913, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39913, + 21 + ] + } + }); }), (function (i) { return { TAG: /* Tpat_constant */2, @@ -57492,15 +58716,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39919, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39919, + 21 + ] + } + }); }), (function (f) { return { TAG: /* Tpat_constant */2, @@ -57521,15 +58746,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39897, - 57 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39897, + 57 + ] + } + }); }), (function (i) { return { TAG: /* Tpat_constant */2, @@ -57548,15 +58774,16 @@ function build_other(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39902, - 57 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39902, + 57 + ] + } + }); }), (function (i) { return { TAG: /* Tpat_constant */2, @@ -57567,15 +58794,16 @@ function build_other(ext, env) { }; }), Caml_int64.zero, Stdlib__Int64.succ, p, env); case /* Const_nativeint */6 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39909, - 33 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39909, + 33 + ] + } + }); } case /* Tpat_construct */4 : @@ -57652,28 +58880,30 @@ function build_other(ext, env) { var tags = Stdlib__List.map((function (param) { var match = param[0].pat_desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39836, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39836, + 23 + ] + } + }); } if (match.TAG === /* Tpat_variant */5) { return match._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39836, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39836, + 23 + ] + } + }); }), env); var row = row_of_pat(p); var make_other_pat = function (tag, $$const) { @@ -57721,28 +58951,30 @@ function build_other(ext, env) { var all_lengths = Stdlib__List.map((function (param) { var args = param[0].pat_desc; if (typeof args === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39928, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39928, + 15 + ] + } + }); } if (args.TAG === /* Tpat_array */7) { return Stdlib__List.length(args._0); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39928, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39928, + 15 + ] + } + }); }), env); var _l = 0; while(true) { @@ -57782,15 +59014,16 @@ function build_other_gadt(ext, env) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 39952, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 39952, + 11 + ] + } + }); } function has_instance(_p) { @@ -57945,15 +59178,16 @@ function orify_many(param) { return x; } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40024, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40024, + 12 + ] + } + }); } function try_many_gadt(f, param) { @@ -58041,7 +59275,9 @@ function exhaust(ext, pss, n) { if (exn.MEL_EXN_ID === Empty) { return fatal_error("Parmatch.exhaust"); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { var r$2 = exhaust(ext, filter_extra(pss), n - 1 | 0); @@ -58141,7 +59377,9 @@ function exhaust_gadt(ext, pss, n) { if (exn.MEL_EXN_ID === Empty) { return fatal_error("Parmatch.exhaust"); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { var r$1 = exhaust_gadt(ext, filter_extra(pss), n - 1 | 0); @@ -58174,27 +59412,29 @@ function exhaust_gadt$1(ext, pss, n) { var singletons = Stdlib__List.map((function (param) { if (param) { if (param.tl) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40200, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40200, + 19 + ] + } + }); } return param.hd; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40200, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40200, + 19 + ] + } + }); }), lst); return /* Rsome */{ _0: { @@ -58295,15 +59535,16 @@ function is_var_column(rs) { return false; } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40309, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40309, + 14 + ] + } + }); }), rs); } @@ -58312,15 +59553,16 @@ function or_args(_p) { var p = _p; var match = p.pat_desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40316, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40316, + 23 + ] + } + }); } switch (match.TAG | 0) { case /* Tpat_alias */1 : @@ -58332,15 +59574,16 @@ function or_args(_p) { match._1 ]; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40316, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40316, + 23 + ] + } + }); } }; } @@ -58354,15 +59597,16 @@ function remove$1(r) { active: match.tl }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40321, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40321, + 12 + ] + } + }); } function push_no_or(r) { @@ -58377,15 +59621,16 @@ function push_no_or(r) { active: match.tl }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40328, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40328, + 8 + ] + } + }); } function push_or(r) { @@ -58400,15 +59645,16 @@ function push_or(r) { active: match.tl }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40332, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40332, + 8 + ] + } + }); } function discr_pat$1(q, rs) { @@ -58486,15 +59732,16 @@ function filter_one$1(q, rs) { _rs = rem; continue ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40349, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40349, + 14 + ] + } + }); }; }; return filter_rec(rs); @@ -58548,15 +59795,16 @@ function extract_columns(pss, qs) { }), param, param$1); }), i, rs.tl); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40392, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40392, + 8 + ] + } + }); } else { return Stdlib__List.map((function (param) { return /* [] */0; @@ -58631,15 +59879,16 @@ function every_satisfiables(_pss, _qs) { var match = qs.active; if (match) { if (match.tl) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40429, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40429, + 23 + ] + } + }); } var match$1 = or_args(match.hd); var r_loc = every_both(pss, qs, match$1[0], match$1[1]); @@ -58665,15 +59914,16 @@ function every_satisfiables(_pss, _qs) { return r_loc; } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40429, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40429, + 23 + ] + } + }); }), extract_columns(pss, qs), extract_elements(qs), /* Used */0); } else if (satisfiable(Stdlib__List.map(make_vector, pss), qs.no_ors)) { return /* Used */0; @@ -59035,10 +60285,11 @@ function initial_all(no_guard, param) { if (!no_guard) { return /* [] */0; } - throw { - MEL_EXN_ID: NoGuard, - Error: new Error() - }; + throw new Error(NoGuard, { + cause: { + MEL_EXN_ID: NoGuard + } + }); } function do_filter_var(param) { @@ -59190,7 +60441,9 @@ function check_partial_all(v, casel) { if (exn.MEL_EXN_ID === NoGuard) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -59298,15 +60551,16 @@ function conv(typed) { _0: lst }) : lst.hd; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40764, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40764, + 28 + ] + } + }); } return mk$1(undefined, undefined, { TAG: /* Ppat_construct */5, @@ -59877,15 +61131,16 @@ function warning_leave_scope(param) { warning_scope.contents = match.tl; return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41342, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41342, + 10 + ] + } + }); } function warning_attribute(attrs) { @@ -59910,7 +61165,9 @@ function warning_attribute(attrs) { _1: "Ill-formed list of warnings" }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; Stdlib__List.iter((function (param) { @@ -59956,15 +61213,18 @@ function narrow_unbound_lid_error(env, loc, lid, make_error) { })); } if (exn.MEL_EXN_ID === Recmodule) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: /* Illegal_reference_to_recursive_module */1, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: /* Illegal_reference_to_recursive_module */1 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; switch (lid.TAG | 0) { @@ -59976,40 +61236,43 @@ function narrow_unbound_lid_error(env, loc, lid, make_error) { var md = find_module(false, lookup_module(true, mlid, env), env); var match = scrape_alias(env, undefined, md.md_type); if (match.TAG === /* Mty_functor */2) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Access_functor_as_structure */25, - _0: mlid - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Access_functor_as_structure */25, + _0: mlid + } + } + }); } break; case /* Lapply */2 : check_module(lid._0); check_module(lid._1); - throw { + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Ill_typed_functor_application */24, + _0: lid + } + } + }); + + } + throw new Error($$Error$6, { + cause: { MEL_EXN_ID: $$Error$6, _1: loc, _2: env, - _3: { - TAG: /* Ill_typed_functor_application */24, - _0: lid - }, - Error: new Error() - }; - - } - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: Curry._1(make_error, lid), - Error: new Error() - }; + _3: Curry._1(make_error, lid) + } + }); } function find_component(lookup, make_error, env, loc, lid) { @@ -60044,15 +61307,18 @@ function find_component(lookup, make_error, env, loc, lid) { return narrow_unbound_lid_error(env, loc, lid, make_error); } if (exn.MEL_EXN_ID === Recmodule) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: /* Illegal_reference_to_recursive_module */1, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: /* Illegal_reference_to_recursive_module */1 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -60184,29 +61450,31 @@ function unbound_label_error(env, lid) { var transl_modtype_longident = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41489, - 45 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41489, + 45 + ] + } + }); }) }; var transl_modtype = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41490, - 35 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41490, + 35 + ] + } + }); }) }; @@ -60215,16 +61483,17 @@ function create_package_mty(fake, loc, env, param) { var s2 = param$1[0]; var s1 = param[0]; if (Caml_obj.caml_equal(s1.txt, s2.txt)) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Multiple_constraints_on_type */15, - _0: s1.txt - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Multiple_constraints_on_type */15, + _0: s1.txt + } + } + }); } return Caml_obj.caml_compare(s1.txt, s2.txt); }), param[1]); @@ -60337,22 +61606,24 @@ function transl_type_param(env, styp) { var ty$1; try { if (name$1 !== "" && Caml_string.get(name$1, 0) === /* '_' */95) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: empty, - _3: { - TAG: /* Invalid_variable_name */13, - _0: "'" + name$1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: empty, + _3: { + TAG: /* Invalid_variable_name */13, + _0: "'" + name$1 + } + } + }); } find$2(name$1, type_variables.contents); - throw { - MEL_EXN_ID: Already_bound, - Error: new Error() - }; + throw new Error(Already_bound, { + cause: { + MEL_EXN_ID: Already_bound + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -60361,7 +61632,9 @@ function transl_type_param(env, styp) { type_variables.contents = add$5(name$1, v, type_variables.contents); ty$1 = v; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return { @@ -60375,15 +61648,16 @@ function transl_type_param(env, styp) { ctyp_attributes: styp.ptyp_attributes }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41575, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41575, + 9 + ] + } + }); } function new_pre_univar(name, param) { @@ -60431,16 +61705,17 @@ function transl_type(env, policy, styp) { ty = new_pre_univar(undefined, undefined); } else { if (policy === /* Fixed */0) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Unbound_type_variable */0, - _0: "_" - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Unbound_type_variable */0, + _0: "_" + } + } + }); } ty = newvar(validate_name(undefined), undefined); } @@ -60450,16 +61725,17 @@ function transl_type(env, policy, styp) { case /* Ptyp_var */0 : var name$1 = name._0; if (name$1 !== "" && Caml_string.get(name$1, 0) === /* '_' */95) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Invalid_variable_name */13, - _0: "'" + name$1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Invalid_variable_name */13, + _0: "'" + name$1 + } + } + }); } var ty$1; try { @@ -60481,11 +61757,15 @@ function transl_type(env, policy, styp) { ], used_variables.contents); ty$1 = v; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return ctyp({ @@ -60544,18 +61824,19 @@ function transl_type(env, policy, styp) { stl$2 = stl$1; } if (Stdlib__List.length(stl$2) !== decl.type_arity) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Type_arity_mismatch */3, - _0: lid.txt, - _1: decl.type_arity, - _2: Stdlib__List.length(stl$2) - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Type_arity_mismatch */3, + _0: lid.txt, + _1: decl.type_arity, + _2: Stdlib__List.length(stl$2) + } + } + }); } var args = Stdlib__List.map((function (param) { return transl_type(env, policy, param); @@ -60570,18 +61851,21 @@ function transl_type(env, policy, styp) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: param[0].ptyp_loc, - _2: env, - _3: { - TAG: /* Type_mismatch */6, - _0: swap_list(exn._1) - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: param[0].ptyp_loc, + _2: env, + _3: { + TAG: /* Type_mismatch */6, + _0: swap_list(exn._1) + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), Stdlib__List.combine(stl$2, args), params); var constr = newconstr(path, Stdlib__List.map((function (ctyp) { @@ -60593,18 +61877,21 @@ function transl_type(env, policy, styp) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Type_mismatch */6, - _0: exn$2._1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Type_mismatch */6, + _0: exn$2._1 + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } return ctyp({ TAG: /* Ttyp_constr */3, @@ -60641,10 +61928,11 @@ function transl_type(env, policy, styp) { if (ty !== undefined) { var row = repr(ty).desc; if (typeof row === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } switch (row.TAG | 0) { case /* Tconstr */3 : @@ -60654,21 +61942,24 @@ function transl_type(env, policy, styp) { if (static_row(row._0)) { return ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); default: - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } }; }; @@ -60719,37 +62010,43 @@ function transl_type(env, policy, styp) { var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Stdlib.Not_found) { find_class$1(env, styp.ptyp_loc, lid$1.txt); - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41701, - 57 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41701, + 57 + ] + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } } else { - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } var decl$2 = match$1[1]; var path$1 = match$1[0]; if (Stdlib__List.length(stl$3) !== decl$2.type_arity) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Type_arity_mismatch */3, - _0: lid$1.txt, - _1: decl$2.type_arity, - _2: Stdlib__List.length(stl$3) - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Type_arity_mismatch */3, + _0: lid$1.txt, + _1: decl$2.type_arity, + _2: Stdlib__List.length(stl$3) + } + } + }); } var args$1 = Stdlib__List.map((function (param) { return transl_type(env, policy, param); @@ -60762,18 +62059,21 @@ function transl_type(env, policy, styp) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: param[0].ptyp_loc, - _2: env, - _3: { - TAG: /* Type_mismatch */6, - _0: swap_list(exn._1) - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: param[0].ptyp_loc, + _2: env, + _3: { + TAG: /* Type_mismatch */6, + _0: swap_list(exn._1) + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), Stdlib__List.combine(stl$3, args$1), params$1); var ty_args = Stdlib__List.map((function (ctyp) { @@ -60786,31 +62086,35 @@ function transl_type(env, policy, styp) { catch (raw_exn$5){ var exn$5 = Caml_js_exceptions.internalToOCamlException(raw_exn$5); if (exn$5.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Type_mismatch */6, - _0: exn$5._1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Type_mismatch */6, + _0: exn$5._1 + } + } + }); } - throw exn$5; + throw new Error(exn$5.MEL_EXN_ID, { + cause: exn$5 + }); } var row = ty$6.desc; var ty$7; if (typeof row === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41749, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41749, + 10 + ] + } + }); } switch (row.TAG | 0) { case /* Tobject */4 : @@ -60896,15 +62200,16 @@ function transl_type(env, policy, styp) { }); break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41749, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41749, + 10 + ] + } + }); } return ctyp({ TAG: /* Ttyp_class */5, @@ -60926,7 +62231,9 @@ function transl_type(env, policy, styp) { if (exn$6.MEL_EXN_ID === Stdlib.Not_found) { t$1 = instance(undefined, env, find$2(alias, used_variables.contents)[0]); } else { - throw exn$6; + throw new Error(exn$6.MEL_EXN_ID, { + cause: exn$6 + }); } } var ty$8 = transl_type(env, policy, st); @@ -60937,18 +62244,21 @@ function transl_type(env, policy, styp) { var exn$7 = Caml_js_exceptions.internalToOCamlException(raw_exn$7); if (exn$7.MEL_EXN_ID === Unify) { var trace = swap_list(exn$7._1); - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Alias_type_mismatch */7, - _0: trace - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Alias_type_mismatch */7, + _0: trace + } + } + }); } - throw exn$7; + throw new Error(exn$7.MEL_EXN_ID, { + cause: exn$7 + }); } cty = ty$8; } @@ -60971,18 +62281,21 @@ function transl_type(env, policy, styp) { var exn$9 = Caml_js_exceptions.internalToOCamlException(raw_exn$9); if (exn$9.MEL_EXN_ID === Unify) { var trace$1 = swap_list(exn$9._1); - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Alias_type_mismatch */7, - _0: trace$1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Alias_type_mismatch */7, + _0: trace$1 + } + } + }); } - throw exn$9; + throw new Error(exn$9.MEL_EXN_ID, { + cause: exn$9 + }); } if (principal.contents) { end_def(undefined); @@ -61027,7 +62340,9 @@ function transl_type(env, policy, styp) { ctyp_attributes: ty$9.ctyp_attributes }; } else { - throw exn$8; + throw new Error(exn$8.MEL_EXN_ID, { + cause: exn$8 + }); } } return ctyp({ @@ -61068,17 +62383,18 @@ function transl_type(env, policy, styp) { var match = Stdlib__Hashtbl.find(hfields, h); var l$p = match[0]; if (l !== l$p) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Variant_tags */12, - _0: l, - _1: l$p - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Variant_tags */12, + _0: l, + _1: l$p + } + } + }); } var ty = mkfield(l, f); var ty$p = mkfield(l, match[1]); @@ -61097,19 +62413,22 @@ function transl_type(env, policy, styp) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Constructor_mismatch */10, - _0: ty, - _1: ty$p - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Constructor_mismatch */10, + _0: ty, + _1: ty$p + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } catch (raw_exn$1){ @@ -61120,7 +62439,9 @@ function transl_type(env, policy, styp) { f ]); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } }; var add_field = function (param) { @@ -61152,16 +62473,17 @@ function transl_type(env, policy, styp) { } if (exit === 1) { if (Stdlib__List.length(stl) > 1 || c && Caml_obj.caml_notequal(stl, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Present_has_conjunction */8, - _0: l - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Present_has_conjunction */8, + _0: l + } + } + }); } f = tl ? ({ TAG: /* Rpresent */0, @@ -61192,10 +62514,11 @@ function transl_type(env, policy, styp) { ]; try { Stdlib__Hashtbl.iter((function (param, param$1) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); }), hfields); name$2.contents = nm; } @@ -61204,7 +62527,9 @@ function transl_type(env, policy, styp) { if (exn.MEL_EXN_ID === Stdlib.Exit) { name$2.contents = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var match$2 = expand_head(env, cty.ctyp_type); @@ -61217,16 +62542,17 @@ function transl_type(env, policy, styp) { switch (row.TAG | 0) { case /* Tvar */0 : if (nm !== undefined) { - throw { - MEL_EXN_ID: $$Error$6, - _1: sty.ptyp_loc, - _2: env, - _3: { - TAG: /* Unbound_type_constructor_2 */2, - _0: nm[0] - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: sty.ptyp_loc, + _2: env, + _3: { + TAG: /* Unbound_type_constructor_2 */2, + _0: nm[0] + } + } + }); } exit$1 = 1; break; @@ -61243,16 +62569,17 @@ function transl_type(env, policy, styp) { } } if (exit$1 === 1) { - throw { - MEL_EXN_ID: $$Error$6, - _1: sty.ptyp_loc, - _2: env, - _3: { - TAG: /* Not_a_variant */11, - _0: ty - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: sty.ptyp_loc, + _2: env, + _3: { + TAG: /* Not_a_variant */11, + _0: ty + } + } + }); } Stdlib__List.iter((function (param) { var f = param[1]; @@ -61260,15 +62587,16 @@ function transl_type(env, policy, styp) { var f$1; if (present !== undefined && !Stdlib__List.mem(l, present)) { if (typeof f === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41862, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41862, + 24 + ] + } + }); } if (f.TAG === /* Rpresent */0) { var ty = f._0; @@ -61293,15 +62621,16 @@ function transl_type(env, policy, styp) { } }); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 41862, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 41862, + 24 + ] + } + }); } } else { f$1 = f; @@ -61325,16 +62654,17 @@ function transl_type(env, policy, styp) { if (Stdlib__List.mem_assoc(l, fields$2)) { return ; } - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Present_has_no_type */9, - _0: l - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Present_has_no_type */9, + _0: l + } + } + }); }), present); } var row_row_fields = Stdlib__List.rev(fields$2); @@ -61411,17 +62741,18 @@ function transl_type(env, policy, styp) { tl: tyl }; } - throw { - MEL_EXN_ID: $$Error$6, - _1: styp.ptyp_loc, - _2: env, - _3: { - TAG: /* Cannot_quantify */14, - _0: param[0], - _1: v - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: styp.ptyp_loc, + _2: env, + _3: { + TAG: /* Cannot_quantify */14, + _0: param[0], + _1: v + } + } + }); }), /* [] */0, new_univars); var ty$p = newty2(100000000, { TAG: /* Tpoly */10, @@ -61475,11 +62806,12 @@ function transl_type(env, policy, styp) { } }, ty$12); case /* Ptyp_extension */10 : - throw { - MEL_EXN_ID: Error_forward, - _1: error_of_extension(name._0), - Error: new Error() - }; + throw new Error(Error_forward, { + cause: { + MEL_EXN_ID: Error_forward, + _1: error_of_extension(name._0) + } + }); } } @@ -61503,16 +62835,17 @@ function transl_fields(loc, env, policy, seen, o, param) { var match = param.hd; var s = match[0]; if (Stdlib__List.mem(s, seen)) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Repeated_method_label */16, - _0: s - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Repeated_method_label */16, + _0: s + } + } + }); } var ty2 = transl_fields(loc, env, policy, { hd: s, @@ -61609,16 +62942,17 @@ function globalize_used_variables(env, fixed) { var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { if (fixed && is_Tvar(repr(ty))) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Unbound_type_variable */0, - _0: "'" + name - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Unbound_type_variable */0, + _0: "'" + name + } + } + }); } var v2 = new_global_var(validate_name(undefined), undefined); r.contents = { @@ -61632,7 +62966,9 @@ function globalize_used_variables(env, fixed) { type_variables.contents = add$5(name, v2, type_variables.contents); return ; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } }), used_variables.contents); used_variables.contents = /* Empty */0; @@ -61644,18 +62980,21 @@ function globalize_used_variables(env, fixed) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$6, - _1: param[0], - _2: env, - _3: { - TAG: /* Type_mismatch */6, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: param[0], + _2: env, + _3: { + TAG: /* Type_mismatch */6, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), r.contents); }; @@ -62573,57 +63912,61 @@ var Error_forward$1 = /* @__PURE__ */Caml_exceptions.create("Ocaml_typedtree_tes var type_module = { contents: (function (env, md) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42440, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42440, + 22 + ] + } + }); }) }; var type_open = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42446, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42446, + 16 + ] + } + }); }) }; var type_package = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42451, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42451, + 16 + ] + } + }); }) }; var type_object = { contents: (function (env, s) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42455, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42455, + 20 + ] + } + }); }) }; @@ -62979,25 +64322,27 @@ function extract_option_type(env, ty) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42638, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42638, + 9 + ] + } + }); } function extract_concrete_record(env, ty) { var match = extract_concrete_typedecl(env, ty); var match$1 = match[2].type_kind; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$1.TAG === /* Type_record */0) { return [ @@ -63006,10 +64351,11 @@ function extract_concrete_record(env, ty) { match$1._0 ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function extract_concrete_variant(env, ty) { @@ -63025,10 +64371,11 @@ function extract_concrete_variant(env, ty) { /* [] */0 ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } else { if (cstrs.TAG !== /* Type_record */0) { return [ @@ -63037,10 +64384,11 @@ function extract_concrete_variant(env, ty) { cstrs._0 ]; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -63054,17 +64402,20 @@ function extract_label_names(sexp, env, ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42656, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42656, + 4 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -63087,31 +64438,35 @@ function unify_pat_types(loc, env, ty, ty$p) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Pattern_type_clash */3, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Pattern_type_clash */3, + _0: exn._1 + } + } + }); } if (exn.MEL_EXN_ID === Tags) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Variant_tags */12, - _0: exn._1, - _1: exn._2 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Variant_tags */12, + _0: exn._1, + _1: exn._2 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -63122,31 +64477,35 @@ function unify_exp_types(loc, env, ty, expected_ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Expr_type_clash */7, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Expr_type_clash */7, + _0: exn._1 + } + } + }); } if (exn.MEL_EXN_ID === Tags) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: { - TAG: /* Variant_tags */12, - _0: exn._1, - _1: exn._2 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: { + TAG: /* Variant_tags */12, + _0: exn._1, + _1: exn._2 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -63159,15 +64518,16 @@ function get_newtype_level$1(param) { if (y !== undefined) { return y; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42694, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42694, + 12 + ] + } + }); } function unify_pat_types_gadt(loc, env, ty, ty$p) { @@ -63176,15 +64536,16 @@ function unify_pat_types_gadt(loc, env, ty, ty$p) { if (x !== undefined) { newtype_level$2 = x; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42699, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42699, + 14 + ] + } + }); } try { try { @@ -63200,56 +64561,64 @@ function unify_pat_types_gadt(loc, env, ty, ty$p) { var e = Caml_js_exceptions.internalToOCamlException(raw_e); Curry._1(TypePairs.clear, unify_eq_set); if (e.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: e._1, - Error: new Error() - }; + throw new Error(Unify, { + cause: { + MEL_EXN_ID: Unify, + _1: e._1 + } + }); } newtype_level.contents = undefined; - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: { - TAG: /* Pattern_type_clash */3, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: { + TAG: /* Pattern_type_clash */3, + _0: exn._1 + } + } + }); } if (exn.MEL_EXN_ID === Tags) { - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env.contents, - _3: { - TAG: /* Variant_tags */12, - _0: exn._1, - _1: exn._2 - }, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env.contents, + _3: { + TAG: /* Variant_tags */12, + _0: exn._1, + _1: exn._2 + } + } + }); } if (exn.MEL_EXN_ID === Unification_recursive_abbrev) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: { - TAG: /* Recursive_local_constraint */33, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: { + TAG: /* Recursive_local_constraint */33, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -63270,30 +64639,32 @@ function finalize_variant(pat) { var row = match$1.desc; var row$1; if (typeof row === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42725, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42725, + 15 + ] + } + }); } if (row.TAG === /* Tvariant */8) { var row$2 = row._0; match._2.contents = row$2; row$1 = row_repr_aux(/* [] */0, row$2); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42725, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42725, + 15 + ] + } + }); } var match$2 = row_field(match._0, row$1); if (typeof match$2 === "number") { @@ -63328,15 +64699,16 @@ function finalize_variant(pat) { tl: match$3.tl }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42733, - 40 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42733, + 40 + ] + } + }); } } @@ -63371,10 +64743,11 @@ function has_variants(p) { if (tmp.TAG !== /* Tpat_variant */5) { return ; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); }), p); return false; } @@ -63383,7 +64756,9 @@ function has_variants(p) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -63421,16 +64796,17 @@ function enter_variable(is_moduleOpt, is_as_variableOpt, loc, name, ty) { if (Stdlib__List.exists((function (param) { return param[0].name === name.txt; }), pattern_variables.contents)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: empty, - _3: { - TAG: /* Multiply_bound_variable */5, - _0: name.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: empty, + _3: { + TAG: /* Multiply_bound_variable */5, + _0: name.txt + } + } + }); } var id = create(name.txt); pattern_variables.contents = { @@ -63445,13 +64821,14 @@ function enter_variable(is_moduleOpt, is_as_variableOpt, loc, name, ty) { }; if (is_module) { if (!allow_modules.contents) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: empty, - _3: /* Modules_not_allowed */2, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: empty, + _3: /* Modules_not_allowed */2 + } + }); } module_variables.contents = { hd: [ @@ -63506,19 +64883,22 @@ function enter_orpat_variables(loc, env, p1_vs, p2_vs) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Or_pattern_type_clash */4, - _0: x1, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Or_pattern_type_clash */4, + _0: x1, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return { hd: [ @@ -63529,41 +64909,44 @@ function enter_orpat_variables(loc, env, p1_vs, p2_vs) { }; } var min_var = x1.name < x2.name ? x1 : x2; - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Orpat_vars */6, - _0: min_var - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Orpat_vars */6, + _0: min_var + } + } + }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Orpat_vars */6, - _0: x1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Orpat_vars */6, + _0: x1 + } + } + }); } if (!p2_vs) { return /* [] */0; } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Orpat_vars */6, - _0: p2_vs.hd[0] - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Orpat_vars */6, + _0: p2_vs.hd[0] + } + } + }); }; }; return unify_vars(p1_vs$1, p2_vs$1); @@ -63756,16 +65139,17 @@ function build_or_pat(env, loc, lid) { } } if (exit === 1) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_a_variant_type */30, - _0: lid - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_a_variant_type */30, + _0: lid + } + } + }); } var match$1 = Stdlib__List.fold_left((function (param, param$1) { var l = param$1[0]; @@ -63929,16 +65313,17 @@ function build_or_pat(env, loc, lid) { ty$1 ]; } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_a_variant_type */30, - _0: lid - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_a_variant_type */30, + _0: lid + } + } + }); } function expand_path(env, _p) { @@ -63953,7 +65338,9 @@ function expand_path(env, _p) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { decl = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (decl !== undefined) { @@ -63994,27 +65381,34 @@ function wrap_disambiguate(kind, ty, f, x) { if (exn.MEL_EXN_ID === $$Error$7) { var match = exn._3; if (typeof match === "number") { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (match.TAG === /* Wrong_name */13) { - throw { - MEL_EXN_ID: $$Error$7, - _1: exn._1, - _2: exn._2, - _3: { - TAG: /* Wrong_name */13, - _0: kind, - _1: ty, - _2: match._2, - _3: match._3, - _4: match._4 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: exn._1, + _2: exn._2, + _3: { + TAG: /* Wrong_name */13, + _0: kind, + _1: ty, + _2: match._2, + _3: match._3, + _4: match._4 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -64024,28 +65418,30 @@ var type_kind = "record"; function get_type_path$1(env, d) { var match = d.lbl_res.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42965, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42965, + 11 + ] + } + }); } if (match.TAG === /* Tconstr */3) { return match._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42965, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42965, + 11 + ] + } + }); } function lookup_from_type(env, tpath, lid) { @@ -64063,29 +65459,33 @@ function lookup_from_type(env, tpath, lid) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Wrong_name */13, - _0: "", - _1: newvar(undefined, undefined), - _2: type_kind, - _3: tpath, - _4: lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Wrong_name */13, + _0: "", + _1: newvar(undefined, undefined), + _2: type_kind, + _3: tpath, + _4: lid.txt + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Ldot */1 : case /* Lapply */2 : - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -64226,26 +65626,31 @@ function disambiguate(warnOpt, check_lkOpt, scope, lid, env, opath, lbls) { tp ]; }), lbls); - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Name_type_mismatch */14, - _0: type_kind, - _1: lid.txt, - _2: tp, - _3: tpl - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Name_type_mismatch */14, + _0: type_kind, + _1: lid.txt, + _2: tp, + _3: tpl + } + } + }); } } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else if (lbls) { @@ -64495,15 +65900,16 @@ function type_label_a_list(labels, loc, closed, env, type_lbl_a, opath, lid_a_li ]; case /* Ldot */1 : case /* Lapply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 43182, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 43182, + 17 + ] + } + }); } }), lid_a_list); @@ -64564,16 +65970,17 @@ function check_recordpat_labels(loc, lbl_pat_list, closed) { var check_defined = function (param) { var label = param[1]; if (Caml_array.get(defined, label.lbl_pos)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: empty, - _3: { - TAG: /* Label_multiply_defined */10, - _0: label.lbl_name - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: empty, + _3: { + TAG: /* Label_multiply_defined */10, + _0: label.lbl_name + } + } + }); } Caml_array.set(defined, label.lbl_pos, true); }; @@ -64609,28 +66016,30 @@ var type_kind$1 = "variant"; function get_type_path$2(env, d) { var match = d.cstr_res.desc; if (typeof match === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42965, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42965, + 11 + ] + } + }); } if (match.TAG === /* Tconstr */3) { return match._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 42965, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 42965, + 11 + ] + } + }); } function lookup_from_type$1(env, tpath, lid) { @@ -64648,29 +66057,33 @@ function lookup_from_type$1(env, tpath, lid) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Wrong_name */13, - _0: "", - _1: newvar(undefined, undefined), - _2: type_kind$1, - _3: tpath, - _4: lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Wrong_name */13, + _0: "", + _1: newvar(undefined, undefined), + _2: type_kind$1, + _3: tpath, + _4: lid.txt + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Ldot */1 : case /* Lapply */2 : - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } @@ -64811,26 +66224,31 @@ function disambiguate$1(warnOpt, check_lkOpt, scope, lid, env, opath, lbls) { tp ]; }), lbls); - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Name_type_mismatch */14, - _0: type_kind$1, - _1: lid.txt, - _2: tp, - _3: tpl - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Name_type_mismatch */14, + _0: type_kind$1, + _1: lid.txt, + _2: tp, + _3: tpl + } + } + }); } } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else if (lbls) { @@ -64869,15 +66287,16 @@ function unify_head_only(loc, env, ty, constr) { var ty_res = match[1]; var match$1 = repr(ty_res).desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 43255, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 43255, + 9 + ] + } + }); } if (match$1.TAG === /* Tconstr */3) { ty_res.desc = { @@ -64891,15 +66310,16 @@ function unify_head_only(loc, env, ty, constr) { enforce_constraints(env, ty_res); return unify_pat_types(loc, env, ty_res, ty); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 43255, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 43255, + 9 + ] + } + }); } function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) { @@ -65012,21 +66432,23 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) }; return type_pat$1(undefined, undefined)(p$1, expected_ty); } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: /* Invalid_interval */5, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: /* Invalid_interval */5 + } + }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: /* Invalid_interval */5, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: /* Invalid_interval */5 + } + }); case /* Ppat_tuple */4 : var spl = name._0; if (Stdlib__List.length(spl) < 2) { @@ -65077,7 +66499,9 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) if (exn.MEL_EXN_ID === Stdlib.Not_found) { opath = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var match$1 = lid.txt; @@ -65118,17 +66542,18 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) if (!constr.cstr_generalized) { return ; } - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env.contents, - _3: { - TAG: /* Unqualified_gadt_pattern */34, - _0: tpath, - _1: constr.cstr_name - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env.contents, + _3: { + TAG: /* Unqualified_gadt_pattern */34, + _0: tpath, + _1: constr.cstr_name + } + } + }); }; var partial_arg = env.contents; var partial_arg$1 = check_lk; @@ -65138,13 +66563,14 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) mark_constructor(/* Pattern */1, env.contents, last$1(lid.txt), constr); check_deprecated(loc, constr.cstr_attributes, constr.cstr_name); if (no_existentials && Caml_obj.caml_notequal(constr.cstr_existentials, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: /* Unexpected_existential */4, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: /* Unexpected_existential */4 + } + }); } if (constr.cstr_generalized) { unify_head_only(loc, env.contents, expected_ty, constr); @@ -65174,18 +66600,19 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) sargs = /* [] */0; } if (Stdlib__List.length(sargs) !== constr.cstr_arity) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: { - TAG: /* Constructor_arity_mismatch */1, - _0: lid.txt, - _1: constr.cstr_arity, - _2: Stdlib__List.length(sargs) - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: { + TAG: /* Constructor_arity_mismatch */1, + _0: lid.txt, + _1: constr.cstr_arity, + _2: Stdlib__List.length(sargs) + } + } + }); } var match$2 = instance_constructor([ env, @@ -65297,7 +66724,9 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) newvar(undefined, undefined) ]; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } var record_ty = match$3[1]; @@ -65318,19 +66747,22 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: label_lid.loc, - _2: env.contents, - _3: { - TAG: /* Label_mismatch */2, - _0: label_lid.txt, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: label_lid.loc, + _2: env.contents, + _3: { + TAG: /* Label_mismatch */2, + _0: label_lid.txt, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var arg = type_pat$1(undefined, undefined)(param[2], ty_arg); if (Caml_obj.caml_notequal(vars, /* [] */0)) { @@ -65348,16 +66780,17 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) } }; if (Stdlib__List.exists(instantiated, vars)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: label_lid.loc, - _2: env.contents, - _3: { - TAG: /* Polymorphic_label */0, - _0: label_lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: label_lid.loc, + _2: env.contents, + _3: { + TAG: /* Polymorphic_label */0, + _0: label_lid.txt + } + } + }); } } @@ -65454,15 +66887,16 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) }; var match$6 = ty$1.desc; if (typeof match$6 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 43318, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 43318, + 13 + ] + } + }); } if (match$6.TAG === /* Tpoly */10) { begin_def(undefined); @@ -65496,15 +66930,16 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) pat_attributes: /* [] */0 }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 43318, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 43318, + 13 + ] + } + }); } } if (exit$1 === 1) { @@ -65642,19 +67077,21 @@ function type_pat(constrs, labels, no_existentials, mode, env, sp, expected_ty) pat_attributes: /* [] */0 }); case /* Ppat_exception */14 : - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env.contents, - _3: /* Exception_pattern_below_toplevel */8, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env.contents, + _3: /* Exception_pattern_below_toplevel */8 + } + }); case /* Ppat_extension */15 : - throw { - MEL_EXN_ID: Error_forward$1, - _1: error_of_extension(name._0), - Error: new Error() - }; + throw new Error(Error_forward$1, { + cause: { + MEL_EXN_ID: Error_forward$1, + _1: error_of_extension(name._0) + } + }); } } @@ -65673,7 +67110,9 @@ function type_pat$1(allow_existentialsOpt, constrs, labels, levOpt, env, sp, exp } catch (e){ newtype_level$1.contents = undefined; - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } @@ -66202,10 +67641,11 @@ function approx_type(env, _sty) { try { var match = lookup_type$1(args._0.txt, env); if (Stdlib__List.length(ctl) !== match[1].type_arity) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } var tyl = Stdlib__List.map((function (param) { return approx_type(env, param); @@ -66217,7 +67657,9 @@ function approx_type(env, _sty) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return newvar(undefined, undefined); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Ptyp_poly */8 : _sty = args._1; @@ -66306,18 +67748,21 @@ function type_approx(env, _sexp) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: sexp.pexp_loc, - _2: env, - _3: { - TAG: /* Expr_type_clash */7, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: sexp.pexp_loc, + _2: env, + _3: { + TAG: /* Expr_type_clash */7, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return ty1; case /* Pexp_coerce */20 : @@ -66337,18 +67782,21 @@ function type_approx(env, _sexp) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: sexp.pexp_loc, - _2: env, - _3: { - TAG: /* Expr_type_clash */7, - _0: exn$1._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: sexp.pexp_loc, + _2: env, + _3: { + TAG: /* Expr_type_clash */7, + _0: exn$1._1 + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } return ty2; default: @@ -66436,29 +67884,30 @@ function check_univars(env, expans, kind, exp, ty_expected, vars) { _1: vars$p }); var ty_expected$1 = repr(ty_expected); - throw { - MEL_EXN_ID: $$Error$7, - _1: exp.exp_loc, - _2: env, - _3: { - TAG: /* Less_general */31, - _0: kind, - _1: { - hd: [ - ty, - ty - ], - tl: { - hd: [ - ty_expected$1, - ty_expected$1 - ], - tl: /* [] */0 + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: exp.exp_loc, + _2: env, + _3: { + TAG: /* Less_general */31, + _0: kind, + _1: { + hd: [ + ty, + ty + ], + tl: { + hd: [ + ty_expected$1, + ty_expected$1 + ], + tl: /* [] */0 + } + } + } } - } - }, - Error: new Error() - }; + }); } function check_application_result(env, statement, exp) { @@ -66492,10 +67941,11 @@ function generalizable(level, ty) { return ; } if (ty$1.level <= level) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } mark_type_node(ty$1); iter_type_expr(check, ty$1); @@ -66511,7 +67961,9 @@ function generalizable(level, ty) { unmark_type(ty); return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -66556,10 +68008,11 @@ function contains_variant_either(ty) { if (match.TAG === /* Rpresent */0) { return ; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); }), row$1.row_fields); } iter_row(loop, row$1); @@ -66575,7 +68028,9 @@ function contains_variant_either(ty) { unmark_type(ty); return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -66617,10 +68072,11 @@ function contains_polymorphic_variant(p) { switch (match.TAG | 0) { case /* Ppat_variant */6 : case /* Ppat_type */11 : - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); default: return iter_ppat(loop, p); } @@ -66634,7 +68090,9 @@ function contains_polymorphic_variant(p) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -66653,16 +68111,19 @@ function contains_gadt(env, p) { if (!param[0].cstr_generalized) { return ; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); }), cstrs); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -66677,7 +68138,9 @@ function contains_gadt(env, p) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -66783,7 +68246,9 @@ function duplicate_ident_types(loc, caselist, env) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return env; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), env, idents); } @@ -66843,16 +68308,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { var tmp; if (typeof match$1 === "number") { if (match$1 === /* Val_unbound */1) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Masked_instance_variable */29, - _0: lid$1.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Masked_instance_variable */29, + _0: lid$1.txt + } + } + }); } tmp = { TAG: /* Texp_ident */0, @@ -66878,15 +68344,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { break; case /* Ldot */1 : case /* Lapply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44136, - 38 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44136, + 38 + ] + } + }); } tmp = { @@ -67067,15 +68534,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { var l = lid._0; if ($$default !== undefined) { if (!is_optional(l)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44215, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44215, + 6 + ] + } + }); } var default_loc = $$default.pexp_loc; var scases_0 = Curry._3(Ast_helper_Exp.$$case, construct(default_loc, undefined, { @@ -67192,17 +68660,20 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44266, - 65 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44266, + 65 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } _ty_fun = match._2; _seen = { @@ -67276,13 +68747,14 @@ function type_expect_(in_function, env, sexp, ty_expected) { var exn_caselist = match$10[1]; var val_caselist = match$10[0]; if (Caml_obj.caml_equal(val_caselist, /* [] */0) && Caml_obj.caml_notequal(exn_caselist, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: /* No_value_clauses */7, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: /* No_value_clauses */7 + } + }); } var match$11 = type_cases(undefined, env, arg.exp_type, ty_expected, true, loc, val_caselist); var match$12 = type_cases(undefined, env, type_exn, ty_expected, false, loc, exn_caselist); @@ -67369,7 +68841,9 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { opath = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var constrs = find_all_constructors(env, lid$2.loc, lid$2.txt); @@ -67389,18 +68863,19 @@ function type_expect_(in_function, env, sexp, ty_expected) { sargs$1 = /* [] */0; } if (Stdlib__List.length(sargs$1) !== constr.cstr_arity) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Constructor_arity_mismatch */1, - _0: lid$2.txt, - _1: constr.cstr_arity, - _2: Stdlib__List.length(sargs$1) - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Constructor_arity_mismatch */1, + _0: lid$2.txt, + _1: constr.cstr_arity, + _2: Stdlib__List.length(sargs$1) + } + } + }); } var separate = principal.contents || env.local_constraints; if (separate) { @@ -67449,15 +68924,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { match$16.hd ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 45498, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 45498, + 11 + ] + } + }); } var ty_res$1 = match$17[1]; var texp_exp_desc = texp.exp_desc; @@ -67480,16 +68956,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { return type_argument(env, e, param[0], param[1]); }), sargs$1, Stdlib__List.combine(ty_args, match$17[0])); if (constr.cstr_private === /* Private */0) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Private_type */19, - _0: ty_res$1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Private_type */19, + _0: ty_res$1 + } + } + }); } return { exp_desc: { @@ -67514,37 +68991,41 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (sarg$1 !== undefined) { var row = match$18.desc; if (typeof row === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (row.TAG === /* Tvariant */8) { var row0 = match$19.desc; if (typeof row0 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (row0.TAG === /* Tvariant */8) { var row$1 = row_repr_aux(/* [] */0, row._0); var match$20 = row_field_repr_aux(/* [] */0, Stdlib__List.assoc(l$1, row$1.row_fields)); var match$21 = row_field_repr_aux(/* [] */0, Stdlib__List.assoc(l$1, row0._0.row_fields)); if (typeof match$20 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$20.TAG === /* Rpresent */0) { var ty$1 = match$20._0; if (ty$1 !== undefined) { if (typeof match$21 === "number") { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (match$21.TAG === /* Rpresent */0) { var ty0 = match$21._0; @@ -67563,44 +69044,51 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: sexp.pexp_attributes }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } catch (raw_exn$1){ @@ -67645,7 +69133,9 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: sexp.pexp_attributes }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case /* Pexp_record */11 : var opt_sexp = lid._1; @@ -67681,7 +69171,9 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var op = get_path(ty_expected); @@ -67735,16 +69227,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (match) { var lbl1 = param.hd[1]; if (lbl1.lbl_pos === match.hd[1].lbl_pos) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Label_multiply_defined */10, - _0: lbl1.lbl_name - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Label_multiply_defined */10, + _0: lbl1.lbl_name + } + } + }); } _param = param.tl; continue ; @@ -67780,15 +69273,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: opt_exp.exp_attributes }; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44455, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44455, + 15 + ] + } + }); } } else { opt_exp$1 = undefined; @@ -67797,15 +69291,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (lbl_exp_list) { num_fields = lbl_exp_list.hd[1].lbl_all.length; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44458, - 38 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44458, + 38 + ] + } + }); } if (opt_sexp === undefined && Stdlib__List.length(lid_sexp_list) !== num_fields) { var present_indices = Stdlib__List.map((function (param) { @@ -67832,16 +69327,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { }; }; var missing = missing_labels(0, label_names); - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Label_missing */11, - _0: missing - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Label_missing */11, + _0: missing + } + } + }); } if (opt_sexp !== undefined && Stdlib__List.length(lid_sexp_list) === num_fields) { prerr_warning(loc, /* Useless_record_with */11); @@ -67891,16 +69387,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { var label$1 = match$26[1]; unify_exp(env, record$4, ty_record$1); if (label$1.lbl_mut === /* Immutable */0) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Label_not_mutable */12, - _0: lid$4.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Label_not_mutable */12, + _0: lid$4.txt + } + } + }); } return rue({ exp_desc: { @@ -68027,13 +69524,14 @@ function type_expect_(in_function, env, sexp, ty_expected) { val_attributes: /* [] */0 }, env); } else { - throw { - MEL_EXN_ID: $$Error$7, - _1: param.ppat_loc, - _2: env, - _3: /* Invalid_for_loop_index */6, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: param.ppat_loc, + _2: env, + _3: /* Invalid_for_loop_index */6 + } + }); } var body$3 = type_statement(match$28[1], lid._4); return rue({ @@ -68100,19 +69598,22 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Subtype) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_subtype */23, - _0: exn$2._1, - _1: exn$2._2 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_subtype */23, + _0: exn$2._1, + _1: exn$2._2 + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } end_def(undefined); generalize_structure$1(current_level.contents, ty$5); @@ -68176,7 +69677,9 @@ function type_expect_(in_function, env, sexp, ty_expected) { backtrack(snap); tmp$4 = false; } else { - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } tmp$3 = tmp$4; @@ -68197,19 +69700,22 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Subtype) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_subtype */23, - _0: exn$4._1, - _1: exn$4._2 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_subtype */23, + _0: exn$4._1, + _1: exn$4._2 + } + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } } @@ -68222,21 +69728,24 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$5){ var exn$5 = Caml_js_exceptions.internalToOCamlException(raw_exn$5); if (exn$5.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: sarg$2.pexp_loc, - _2: env, - _3: { - TAG: /* Coercion_failure */25, - _0: ty$p$2, - _1: full_expand(env, ty$p$2), - _2: exn$5._1, - _3: match$38[1] - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: sarg$2.pexp_loc, + _2: env, + _3: { + TAG: /* Coercion_failure */25, + _0: ty$p$2, + _1: full_expand(env, ty$p$2), + _2: exn$5._1, + _3: match$38[1] + } + } + }); } - throw exn$5; + throw new Error(exn$5.MEL_EXN_ID, { + cause: exn$5 + }); } } } @@ -68312,18 +69821,21 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$6){ var exn$6 = Caml_js_exceptions.internalToOCamlException(raw_exn$6); if (exn$6.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: e.pexp_loc, - _2: env, - _3: { - TAG: /* Undefined_inherited_method */17, - _0: met - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: e.pexp_loc, + _2: env, + _3: { + TAG: /* Undefined_inherited_method */17, + _0: met + } + } + }); } - throw exn$6; + throw new Error(exn$6.MEL_EXN_ID, { + cause: exn$6 + }); } var match$43 = lookup_value$1({ TAG: /* Lident */0, @@ -68336,15 +69848,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { var desc$3 = match$43[1]; var match$45 = desc$3.val_kind; if (typeof match$45 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44747, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44747, + 18 + ] + } + }); } if (match$45.TAG === /* Val_self */2) { var match$46 = filter_self_method(env, met, /* Private */0, match$45._0, match$45._3); @@ -68415,15 +69928,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { typ$1 ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44747, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44747, + 18 + ] + } + }); } break; default: @@ -68452,15 +69966,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { var match$48 = ty$6.desc; var typ$3; if (typeof match$48 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44773, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44773, + 14 + ] + } + }); } switch (match$48.TAG | 0) { case /* Tvar */0 : @@ -68488,15 +70003,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { } break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44773, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44773, + 14 + ] + } + }); } return rue({ exp_desc: { @@ -68515,19 +70031,22 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$7){ var exn$7 = Caml_js_exceptions.internalToOCamlException(raw_exn$7); if (exn$7.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: e.pexp_loc, - _2: env, - _3: { - TAG: /* Undefined_method */16, - _0: obj.exp_type, - _1: met - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: e.pexp_loc, + _2: env, + _3: { + TAG: /* Undefined_method */16, + _0: obj.exp_type, + _1: met + } + } + }); } - throw exn$7; + throw new Error(exn$7.MEL_EXN_ID, { + cause: exn$7 + }); } break; case /* Pexp_new */22 : @@ -68550,16 +70069,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: sexp.pexp_attributes }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Virtual_class */18, - _0: cl.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Virtual_class */18, + _0: cl.txt + } + } + }); case /* Pexp_setinstvar */23 : var lab = lid._0; try { @@ -68595,50 +70115,55 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: sexp.pexp_attributes }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Instance_variable_not_mutable */22, - _0: true, - _1: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Instance_variable_not_mutable */22, + _0: true, + _1: lab.txt + } + } + }); } exit$4 = 1; } if (exit$4 === 1) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Instance_variable_not_mutable */22, - _0: false, - _1: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Instance_variable_not_mutable */22, + _0: false, + _1: lab.txt + } + } + }); } } catch (raw_exn$8){ var exn$8 = Caml_js_exceptions.internalToOCamlException(raw_exn$8); if (exn$8.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Unbound_instance_variable */21, - _0: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Unbound_instance_variable */21, + _0: lab.txt + } + } + }); } - throw exn$8; + throw new Error(exn$8.MEL_EXN_ID, { + cause: exn$8 + }); } break; case /* Pexp_override */24 : @@ -68648,16 +70173,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { if (Stdlib__List.exists((function (l) { return l.txt === lab.txt; }), l)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Value_multiply_overridden */24, - _0: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Value_multiply_overridden */24, + _0: lab.txt + } + } + }); } return { hd: lab, @@ -68680,28 +70206,32 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$9){ var exn$9 = Caml_js_exceptions.internalToOCamlException(raw_exn$9); if (exn$9.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: /* Outside_class */0, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: /* Outside_class */0 + } + }); } - throw exn$9; + throw new Error(exn$9.MEL_EXN_ID, { + cause: exn$9 + }); } var match$54 = match$53[0][1]; var match$55 = match$54.val_kind; if (typeof match$55 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44857, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44857, + 10 + ] + } + }); } if (match$55.TAG === /* Val_self */2) { var vars = match$55._1; @@ -68721,18 +70251,21 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Unbound_instance_variable */21, - _0: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Unbound_instance_variable */21, + _0: lab.txt + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var modifs = Stdlib__List.map(type_override, lst); @@ -68749,15 +70282,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: sexp.pexp_attributes }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44857, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44857, + 10 + ] + } + }); case /* Pexp_letmodule */25 : var name$2 = lid._0; var ty$9 = newvar(undefined, undefined); @@ -68777,19 +70311,22 @@ function type_expect_(in_function, env, sexp, ty_expected) { catch (raw_exn$10){ var exn$10 = Caml_js_exceptions.internalToOCamlException(raw_exn$10); if (exn$10.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Scoping_let_module */28, - _0: name$2.txt, - _1: body$4.exp_type - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Scoping_let_module */28, + _0: name$2.txt, + _1: body$4.exp_type + } + } + }); } - throw exn$10; + throw new Error(exn$10.MEL_EXN_ID, { + cause: exn$10 + }); } return re({ exp_desc: { @@ -68871,15 +70408,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { var match$59 = expand_head(env, ty$11).desc; var exp$2; if (typeof match$59 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44963, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44963, + 15 + ] + } + }); } switch (match$59.TAG | 0) { case /* Tvar */0 : @@ -68942,15 +70480,16 @@ function type_expect_(in_function, env, sexp, ty_expected) { } break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 44963, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 44963, + 15 + ] + } + }); } return re({ exp_desc: exp$2.exp_desc, @@ -69062,26 +70601,28 @@ function type_expect_(in_function, env, sexp, ty_expected) { var match$64 = match$63.desc; var match$65; if (typeof match$64 === "number") { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_a_packed_module */32, - _0: ty_expected - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_a_packed_module */32, + _0: ty_expected + } + } + }); } switch (match$64.TAG | 0) { case /* Tvar */0 : - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: /* Cannot_infer_signature */3, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: /* Cannot_infer_signature */3 + } + }); case /* Tpackage */11 : if (principal.contents && expand_head(env, ty_expected).level < 100000000) { prerr_warning(loc, { @@ -69096,16 +70637,17 @@ function type_expect_(in_function, env, sexp, ty_expected) { ]; break; default: - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Not_a_packed_module */32, - _0: ty_expected - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Not_a_packed_module */32, + _0: ty_expected + } + } + }); } var nl = match$65[1]; var p = match$65[0]; @@ -69154,11 +70696,12 @@ function type_expect_(in_function, env, sexp, ty_expected) { exp_attributes: exp$7.exp_attributes }; case /* Pexp_extension */33 : - throw { - MEL_EXN_ID: Error_forward$1, - _1: error_of_extension(lid._0), - Error: new Error() - }; + throw new Error(Error_forward$1, { + cause: { + MEL_EXN_ID: Error_forward$1, + _1: error_of_extension(lid._0) + } + }); } } @@ -69188,36 +70731,40 @@ function type_function(in_function, loc, attrs, env, ty_expected, l, caselist) { exit = 1; } else { if (match$2.TAG === /* Tarrow */1) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Abstract_wrong_label */27, - _0: l, - _1: ty - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Abstract_wrong_label */27, + _0: l, + _1: ty + } + } + }); } exit = 1; } if (exit === 1) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc_fun, - _2: env, - _3: { - TAG: /* Too_many_arguments */26, - _0: in_function !== undefined, - _1: ty_fun - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc_fun, + _2: env, + _3: { + TAG: /* Too_many_arguments */26, + _0: in_function !== undefined, + _1: ty_fun + } + } + }); } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var ty_res = match$1[1]; @@ -69231,17 +70778,20 @@ function type_function(in_function, loc, attrs, env, ty_expected, l, caselist) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 45069, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 45069, + 24 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } ty_arg$1 = type_option$1(tv); } else { @@ -69313,7 +70863,9 @@ function type_label_access(env, loc, srecord, lid) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { opath = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var labels = find_all_labels(env, lid.loc, lid.txt); @@ -69328,15 +70880,16 @@ function type_label_access(env, loc, srecord, lid) { } function type_format(loc, str, env) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 45122, - 1 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 45122, + 1 + ] + } + }); } function type_label_exp(create, env, loc, ty_expected, param) { @@ -69364,19 +70917,22 @@ function type_label_exp(create, env, loc, ty_expected, param) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Label_mismatch */2, - _0: lid.txt, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Label_mismatch */2, + _0: lid.txt, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var ty_arg$1 = instance_def(ty_arg); if (separate) { @@ -69385,28 +70941,30 @@ function type_label_exp(create, env, loc, ty_expected, param) { } if (label.lbl_private === /* Private */0) { if (create) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env, - _3: { - TAG: /* Private_type */19, - _0: ty_expected - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env, + _3: { + TAG: /* Private_type */19, + _0: ty_expected + } + } + }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: lid.loc, - _2: env, - _3: { - TAG: /* Private_label */20, - _0: lid.txt, - _1: ty_expected - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: lid.loc, + _2: env, + _3: { + TAG: /* Private_label */20, + _0: lid.txt, + _1: ty_expected + } + } + }); } var snap = Caml_obj.caml_equal(vars, /* [] */0) ? undefined : Caml_option.some(snapshot(undefined)); var arg = type_argument(env, sarg, ty_arg$1, instance(undefined, env, ty_arg$1)); @@ -69418,7 +70976,9 @@ function type_label_exp(create, env, loc, ty_expected, param) { } catch (exn$1){ if (is_nonexpansive(arg)) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } try { may(backtrack, snap); @@ -69435,14 +70995,22 @@ function type_label_exp(create, env, loc, ty_expected, param) { if (e.MEL_EXN_ID === $$Error$7) { var tmp = e._3; if (typeof tmp === "number") { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } if (tmp.TAG === /* Less_general */31) { - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } @@ -69824,34 +71392,36 @@ function type_application(env, funct, sargs) { if (ignore_labels && !is_optional(l)) { if (sargs) { var match$5 = sargs.hd; - throw { - MEL_EXN_ID: $$Error$7, - _1: match$5[1].pexp_loc, - _2: env, - _3: { - TAG: /* Apply_wrong_label */9, - _0: match$5[0], - _1: ty_old - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: match$5[1].pexp_loc, + _2: env, + _3: { + TAG: /* Apply_wrong_label */9, + _0: match$5[0], + _1: ty_old + } + } + }); } if (more_sargs) { var match$6 = more_sargs.hd; var sarg0 = match$6[1]; var l$p = match$6[0]; if (l !== l$p && l$p !== "") { - throw { - MEL_EXN_ID: $$Error$7, - _1: sarg0.pexp_loc, - _2: env, - _3: { - TAG: /* Apply_wrong_label */9, - _0: l$p, - _1: match - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: sarg0.pexp_loc, + _2: env, + _3: { + TAG: /* Apply_wrong_label */9, + _0: l$p, + _1: match + } + } + }); } match$4 = [ /* [] */0, @@ -69863,15 +71433,16 @@ function type_application(env, funct, sargs) { }(ty,ty0,sarg0)) ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 45373, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 45373, + 16 + ] + } + }); } } else { try { @@ -69912,7 +71483,9 @@ function type_application(env, funct, sargs) { match$9[3] ]; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var sarg0$3 = match$7[1]; @@ -69966,7 +71539,9 @@ function type_application(env, funct, sargs) { }), undefined) ]; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } @@ -70005,17 +71580,18 @@ function type_application(env, funct, sargs) { if (sargs) { if (ignore_labels) { var match$10 = sargs.hd; - throw { - MEL_EXN_ID: $$Error$7, - _1: match$10[1].pexp_loc, - _2: env, - _3: { - TAG: /* Apply_wrong_label */9, - _0: match$10[0], - _1: ty_old - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: match$10[1].pexp_loc, + _2: env, + _3: { + TAG: /* Apply_wrong_label */9, + _0: match$10[0], + _1: ty_old + } + } + }); } exit$1 = 2; } else { @@ -70121,39 +71697,42 @@ function type_application(env, funct, sargs) { } else { if (match$13.TAG === /* Tarrow */1) { if (classic.contents || !has_label(l1, ty_fun$4)) { - throw { - MEL_EXN_ID: $$Error$7, - _1: sarg1.pexp_loc, - _2: env, - _3: { - TAG: /* Apply_wrong_label */9, - _0: l1, - _1: ty_res - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: sarg1.pexp_loc, + _2: env, + _3: { + TAG: /* Apply_wrong_label */9, + _0: l1, + _1: ty_res + } + } + }); } - throw { - MEL_EXN_ID: $$Error$7, - _1: funct.exp_loc, - _2: env, - _3: /* Incoherent_label_order */1, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: funct.exp_loc, + _2: env, + _3: /* Incoherent_label_order */1 + } + }); } exit$3 = 2; } if (exit$3 === 2) { - throw { - MEL_EXN_ID: $$Error$7, - _1: funct.exp_loc, - _2: env, - _3: { - TAG: /* Apply_non_function */8, - _0: expand_head(env, funct.exp_type) - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: funct.exp_loc, + _2: env, + _3: { + TAG: /* Apply_non_function */8, + _0: expand_head(env, funct.exp_type) + } + } + }); } } @@ -70482,18 +72061,21 @@ function type_cases(in_function, env, ty_arg, ty_res, partial_flag, loc, caselis if (exn.MEL_EXN_ID === Empty || exn.MEL_EXN_ID === Stdlib.Not_found || exn.MEL_EXN_ID === NoGuard) { exit = 1; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (exit === 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 40982, - 48 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 40982, + 48 + ] + } + }); } } @@ -70721,7 +72303,9 @@ function type_let(checkOpt, check_strictOpt, env, rec_flag, spat_sexp_list, scop if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Stdlib__Hashtbl.add(value_declarations, key, callback); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), pat_bound_idents(pat)); return [ @@ -72035,15 +73619,16 @@ register_error_of_exn(function (param) { return type_path_expansion(tp0, param, param$1); }), tp0$p); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 37069, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 37069, + 12 + ] + } + }); })); case /* Invalid_format */15 : return Curry._1(Stdlib__Format.fprintf(param)(/* Format */{ @@ -72898,28 +74483,30 @@ function set_fixed_row(env, loc, p, decl) { if (t !== undefined) { tm = expand_head(env, t); } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46327, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46327, + 14 + ] + } + }); } var row = tm.desc; var rv; if (typeof row === "number") { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Bad_fixed_type */18, - _0: "is not an object or variant" - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Bad_fixed_type */18, + _0: "is not an object or variant" + } + } + }); } switch (row.TAG | 0) { case /* Tobject */4 : @@ -72941,26 +74528,28 @@ function set_fixed_row(env, loc, p, decl) { rv = static_row(row$1) ? newty2(100000000, /* Tnil */0) : row$1.row_more; break; default: - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Bad_fixed_type */18, - _0: "is not an object or variant" - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Bad_fixed_type */18, + _0: "is not an object or variant" + } + } + }); } if (!is_Tvar(rv)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Bad_fixed_type */18, - _0: "has no row variable" - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Bad_fixed_type */18, + _0: "has no row variable" + } + } + }); } rv.desc = { TAG: /* Tconstr */3, @@ -73011,17 +74600,19 @@ function bal$10(l, v, r) { if (lr) { return create$11(create$11(ll, lv, lr.l), lr.v, create$11(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -73041,17 +74632,19 @@ function bal$10(l, v, r) { if (rl) { return create$11(create$11(l, v, rl.l), rl.v, create$11(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$12(x, t) { @@ -73113,14 +74706,17 @@ function make_params(env, params) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Already_bound) { - throw { - MEL_EXN_ID: $$Error$8, - _1: sty.ptyp_loc, - _2: /* Repeated_parameter */0, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: sty.ptyp_loc, + _2: /* Repeated_parameter */0 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return Stdlib__List.map(make_param, params); @@ -73144,16 +74740,17 @@ function make_constructor(env, type_path, type_params, sargs, sret_type) { exit = 1; } if (exit === 1) { - throw { - MEL_EXN_ID: $$Error$8, - _1: sret_type.ptyp_loc, - _2: { - TAG: /* Constraint_failed */5, - _0: ret_type, - _1: newconstr(type_path, type_params) - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: sret_type.ptyp_loc, + _2: { + TAG: /* Constraint_failed */5, + _0: ret_type, + _1: newconstr(type_path, type_params) + } + } + }); } widen(z); return [ @@ -73231,40 +74828,45 @@ function check_constraints_rec(env, loc, visited, _ty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46574, - 28 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46574, + 28 + ] + } + }); } if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Unavailable_type_constructor */17, - _0: path - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Unavailable_type_constructor */17, + _0: path + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (!matches(env, ty$1, ty$p)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Constraint_failed */5, - _0: ty$1, - _1: ty$p - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Constraint_failed */5, + _0: ty$1, + _1: ty$p + } + } + }); } return Stdlib__List.iter((function (param) { return check_constraints_rec(env, loc, visited, param); @@ -73320,17 +74922,19 @@ function bal$11(l, x, d, r) { if (lr) { return create$12(create$12(ll, lv, ld, lr.l), lr.v, lr.d, create$12(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -73352,17 +74956,19 @@ function bal$11(l, x, d, r) { if (rl) { return create$12(create$12(l, x, d, rl.l), rl.v, rl.d, create$12(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add$13(x, data, m) { @@ -73420,10 +75026,11 @@ function find$6(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -73438,16 +75045,17 @@ function check_coherence(env, loc, id, decl) { } var match$1 = repr(ty).desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Definition_mismatch */4, - _0: ty, - _1: /* [] */0 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Definition_mismatch */4, + _0: ty, + _1: /* [] */0 + } + } + }); } if (match$1.TAG === /* Tconstr */3) { var args = match$1._1; @@ -73466,43 +75074,48 @@ function check_coherence(env, loc, id, decl) { if (!Caml_obj.caml_notequal(err, /* [] */0)) { return ; } - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Definition_mismatch */4, - _0: ty, - _1: err - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Definition_mismatch */4, + _0: ty, + _1: err + } + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Unavailable_type_constructor */17, - _0: path - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Unavailable_type_constructor */17, + _0: path + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } else { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Definition_mismatch */4, - _0: ty, - _1: /* [] */0 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Definition_mismatch */4, + _0: ty, + _1: /* [] */0 + } + } + }); } } @@ -73517,26 +75130,28 @@ function check_well_founded(env, loc, path, to_check, ty) { var tmp; tmp = typeof match === "number" || match.TAG !== /* Tconstr */3 ? false : same(match._0, path); if (tmp) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Recursive_abbrev */2, - _0: name(undefined, path) - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Recursive_abbrev */2, + _0: name(undefined, path) + } + } + }); } - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Cycle_in_def */3, - _0: name(undefined, path), - _1: ty0 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Cycle_in_def */3, + _0: name(undefined, path), + _1: ty0 + } + } + }); } var match$1; try { @@ -73557,7 +75172,9 @@ function check_well_founded(env, loc, path, to_check, ty) { exp_nodes ]; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var exp_nodes$1 = match$1[1]; @@ -73569,10 +75186,11 @@ function check_well_founded(env, loc, path, to_check, ty) { visited.contents = Curry._3(add$4, ty$1, exp_nodes$1, visited.contents); var match$2 = ty$1.desc; if (typeof match$2 === "number") { - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } if (match$2.TAG === /* Tconstr */3) { if (!Curry._1(is_empty$2, exp_nodes$1) || Curry._1(to_check, match$2._0)) { @@ -73580,15 +75198,17 @@ function check_well_founded(env, loc, path, to_check, ty) { var ty0$1 = Curry._1(is_empty$2, exp_nodes$1) ? ty$1 : ty0; return check(ty0$1, Curry._2(add$3, ty$1, exp_nodes$1), ty$p); } - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } - throw { - MEL_EXN_ID: Cannot_expand, - Error: new Error() - }; + throw new Error(Cannot_expand, { + cause: { + MEL_EXN_ID: Cannot_expand + } + }); } catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); @@ -73619,7 +75239,9 @@ function check_well_founded(env, loc, path, to_check, ty) { if (exn$1.MEL_EXN_ID === Unify) { return backtrack(snap); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } }; wrap_trace_gadt_instances(env, (function (param) { @@ -73683,17 +75305,18 @@ function check_recursion(env, loc, path, decl, to_check) { var path$p = match._0; if (same(path, path$p)) { if (!equal$5(env, false, args, args$p)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Parameters_differ */8, - _0: cpath, - _1: ty$1, - _2: newconstr(path, args) - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Parameters_differ */8, + _0: cpath, + _1: ty$1, + _2: newconstr(path, args) + } + } + }); } } else if (Curry._1(to_check, path$p) && !Stdlib__List.mem(path$p, prev_exp)) { @@ -73709,18 +75332,21 @@ function check_recursion(env, loc, path, decl, to_check) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Constraint_failed */5, - _0: ty$1, - _1: newconstr(path$p, params0) - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Constraint_failed */5, + _0: ty$1, + _1: newconstr(path$p, params0) + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } check_regular(path$p, args, { hd: path$p, @@ -73730,7 +75356,9 @@ function check_recursion(env, loc, path, decl, to_check) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -73764,7 +75392,9 @@ function get_variance(ty, visited) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Types_Variance.$$null; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -73828,7 +75458,9 @@ function compute_variance(env, visited, vari, ty) { return compute_variance_rec(Types_Variance.may_inv, param); }), tl$1); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case /* Tfield */5 : compute_variance_rec(vari$1, tl._2); @@ -73941,25 +75573,26 @@ function compute_variance_type(env, check, param, decl, tyl) { if (!(is_Tvar(ty) && (co && !c || cn && !n || !ij && i))) { return ; } - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Bad_variance */16, - _0: pos.contents, - _1: [ - co, - cn, - ij - ], - _2: [ - c, - n, - i - ] - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Bad_variance */16, + _0: pos.contents, + _1: [ + co, + cn, + ij + ], + _2: [ + c, + n, + i + ] + } + } + }); }), params, required); var args = newty2(100000000, { TAG: /* Ttuple */2, @@ -74023,25 +75656,26 @@ function compute_variance_type(env, check, param, decl, tyl) { var code = match$1[3] ? ( c2 || n2 ? -1 : -3 ) : -2; - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Bad_variance */16, - _0: code, - _1: [ - c1, - n1, - false - ], - _2: [ - c2, - n2, - false - ] - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Bad_variance */16, + _0: code, + _1: [ + c1, + n1, + false + ], + _2: [ + c2, + n2, + false + ] + } + } + }); }; Stdlib__List.iter((function (param) { check$1(param[1]); @@ -74119,15 +75753,16 @@ function compute_variance_gadt(env, check, rloc, decl, param) { var match = repr(ret_type_opt); var match$1 = match.desc; if (typeof match$1 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47023, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47023, + 13 + ] + } + }); } if (match$1.TAG === /* Tconstr */3) { var tyl = Stdlib__List.map(repr, match$1._1); @@ -74140,12 +75775,13 @@ function compute_variance_gadt(env, check, rloc, decl, param) { var fv2$1 = fv2.tl; var fv1 = param[0]; if ((param$1[0] || param$1[1]) && constrained(env, Stdlib.$at(fv1, fv2$1), ty)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: /* Varying_anonymous */4, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: /* Varying_anonymous */4 + } + }); } return [ { @@ -74155,15 +75791,16 @@ function compute_variance_gadt(env, check, rloc, decl, param) { fv2$1 ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47012, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47012, + 37 + ] + } + }); }), [ /* [] */0, fvl @@ -74180,15 +75817,16 @@ function compute_variance_gadt(env, check, rloc, decl, param) { type_attributes: decl.type_attributes }, add_false(tl)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47023, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47023, + 13 + ] + } + }); } function compute_variance_extension(env, check, decl, ext, rloc) { @@ -74272,15 +75910,16 @@ function compute_variance_decl(env, check, decl, rloc) { } }), varl); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47062, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47062, + 15 + ] + } + }); } function is_sharp(id) { @@ -74471,7 +76110,9 @@ function check_duplicates(sdecl_list) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Stdlib__Hashtbl.add(constrs, pcd.pcd_name.txt, sdecl.ptype_name.txt); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), cl._0); } else { @@ -74492,7 +76133,9 @@ function check_duplicates(sdecl_list) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Stdlib__Hashtbl.add(labels, cname.txt, sdecl.ptype_name.txt); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), cl._0); } @@ -74664,27 +76307,29 @@ function transl_type_decl(env, rec_flag, sdecl_list) { Stdlib__List.iter((function (param) { var name = param.pcd_name.txt; if (Curry._2(mem$6, name, all_constrs.contents)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: name_sdecl.ptype_loc, - _2: { - TAG: /* Duplicate_constructor */0, - _0: name - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: name_sdecl.ptype_loc, + _2: { + TAG: /* Duplicate_constructor */0, + _0: name + } + } + }); } all_constrs.contents = Curry._2(add$12, name, all_constrs.contents); }), scstrs$1); if (Stdlib__List.length(Stdlib__List.filter((function (cd) { return Caml_obj.caml_notequal(cd.pcd_args, /* [] */0); }), scstrs$1)) > 246) { - throw { - MEL_EXN_ID: $$Error$8, - _1: name_sdecl.ptype_loc, - _2: /* Too_many_constructors */1, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: name_sdecl.ptype_loc, + _2: /* Too_many_constructors */1 + } + }); } var make_cstr = function (scstr) { var name = create(scstr.pcd_name.txt); @@ -74743,15 +76388,16 @@ function transl_type_decl(env, rec_flag, sdecl_list) { Stdlib__List.iter((function (param) { var name = param.pld_name.txt; if (Curry._2(mem$6, name, all_labels.contents)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: name_sdecl.ptype_loc, - _2: { - TAG: /* Duplicate_label */1, - _0: name - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: name_sdecl.ptype_loc, + _2: { + TAG: /* Duplicate_label */1, + _0: name + } + } + }); } all_labels.contents = Curry._2(add$12, name, all_labels.contents); }), lbls); @@ -74847,18 +76493,21 @@ function transl_type_decl(env, rec_flag, sdecl_list) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$8, - _1: param[2], - _2: { - TAG: /* Inconsistent_constraint */6, - _0: temp_env, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: param[2], + _2: { + TAG: /* Inconsistent_constraint */6, + _0: temp_env, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), cstrs); end_def(undefined); @@ -74873,30 +76522,34 @@ function transl_type_decl(env, rec_flag, sdecl_list) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46515, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46515, + 26 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } set_fixed_row(temp_env, name_sdecl.ptype_loc, match$3[0], decl); } if (man !== undefined && cyclic_abbrev(temp_env, id, man)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: name_sdecl.ptype_loc, - _2: { - TAG: /* Recursive_abbrev */2, - _0: name_sdecl.ptype_name.txt - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: name_sdecl.ptype_loc, + _2: { + TAG: /* Recursive_abbrev */2, + _0: name_sdecl.ptype_name.txt + } + } + }); } return { typ_id: id, @@ -74944,18 +76597,21 @@ function transl_type_decl(env, rec_flag, sdecl_list) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Type_clash */7, - _0: newenv, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Type_clash */7, + _0: newenv, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), id_list, sdecl_list$1); } @@ -75018,16 +76674,17 @@ function transl_type_decl(env, rec_flag, sdecl_list) { if (ty === undefined) { return ; } - throw { - MEL_EXN_ID: $$Error$8, - _1: sdecl.ptype_loc, - _2: { - TAG: /* Unbound_type_var */9, - _0: ty, - _1: decl - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: sdecl.ptype_loc, + _2: { + TAG: /* Unbound_type_var */9, + _0: ty, + _1: decl + } + } + }); }), sdecl_list$1, tdecls); Stdlib__List.iter2((function (param, param$1) { var decl = param$1[1]; @@ -75040,28 +76697,30 @@ function transl_type_decl(env, rec_flag, sdecl_list) { } else if (l.TAG === /* Type_record */0) { var find_pl = function (param) { if (typeof param === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46623, - 59 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46623, + 59 + ] + } + }); } if (param.TAG === /* Ptype_record */1) { return param._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46623, - 59 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46623, + 59 + ] + } + }); }; var pl = find_pl(param.ptype_kind); var get_loc = function (name, _param) { @@ -75075,15 +76734,16 @@ function transl_type_decl(env, rec_flag, sdecl_list) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46627, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46627, + 16 + ] + } + }); }; }; Stdlib__List.iter((function (param) { @@ -75092,28 +76752,30 @@ function transl_type_decl(env, rec_flag, sdecl_list) { } else { var find_pl$1 = function (param) { if (typeof param === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46596, - 58 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46596, + 58 + ] + } + }); } if (param.TAG === /* Ptype_variant */0) { return param._0; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46596, - 58 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46596, + 58 + ] + } + }); }; var pl$1 = find_pl$1(param.ptype_kind); var foldf = function (acc, x) { @@ -75129,17 +76791,20 @@ function transl_type_decl(env, rec_flag, sdecl_list) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46609, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46609, + 30 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var sret_type = match.pcd_res; Stdlib__List.iter2((function (sty, ty) { @@ -75160,15 +76825,16 @@ function transl_type_decl(env, rec_flag, sdecl_list) { if (sty !== undefined) { sty$1 = sty; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 46642, - 63 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 46642, + 63 + ] + } + }); } return check_constraints_rec(newenv, sty$1.ptyp_loc, visited, ty); }), sdecl_list$1, decls); @@ -75256,19 +76922,22 @@ function transl_extension_constructor(env, check_open, type_path, type_params, t catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$8, - _1: lid$1.loc, - _2: { - TAG: /* Rebind_wrong_type */13, - _0: lid$1.txt, - _1: env, - _2: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: lid$1.loc, + _2: { + TAG: /* Rebind_wrong_type */13, + _0: lid$1.txt, + _1: env, + _2: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (!cdescr.cstr_generalized) { var vars = free_variables$1(undefined, newty2(100000000, { @@ -75297,15 +76966,16 @@ function transl_extension_constructor(env, check_open, type_path, type_params, t var match$4 = cdescr.cstr_res.desc; var match$5; if (typeof match$4 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47376, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47376, + 17 + ] + } + }); } if (match$4.TAG === /* Tconstr */3) { var p = match$4._0; @@ -75315,15 +76985,16 @@ function transl_extension_constructor(env, check_open, type_path, type_params, t decl.type_params ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47376, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47376, + 17 + ] + } + }); } var cstr_type_params = match$5[1]; var cstr_type_path = match$5[0]; @@ -75352,44 +77023,47 @@ function transl_extension_constructor(env, check_open, type_path, type_params, t tl: type_params }; if (!equal$5(env, true, cstr_types, ext_types)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: lid$1.loc, - _2: { - TAG: /* Rebind_mismatch */14, - _0: lid$1.txt, - _1: cstr_type_path, - _2: type_path - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: lid$1.loc, + _2: { + TAG: /* Rebind_mismatch */14, + _0: lid$1.txt, + _1: cstr_type_path, + _2: type_path + } + } + }); } var match$6 = cdescr.cstr_private; if (!match$6 && priv) { - throw { - MEL_EXN_ID: $$Error$8, - _1: lid$1.loc, - _2: { - TAG: /* Rebind_private */15, - _0: lid$1.txt - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: lid$1.loc, + _2: { + TAG: /* Rebind_private */15, + _0: lid$1.txt + } + } + }); } var match$7 = cdescr.cstr_tag; var path; switch (match$7.TAG | 0) { case /* Cstr_constant */0 : case /* Cstr_block */1 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 47401, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 47401, + 17 + ] + } + }); case /* Cstr_extension */2 : path = match$7._0; break; @@ -75445,35 +77119,39 @@ function transl_type_extension(check_open, env, loc, styext) { return false; } }), styext.ptyext_constructors); - throw { - MEL_EXN_ID: $$Error$8, - _1: match$2.pext_loc, - _2: { - TAG: /* Not_open_type */10, - _0: type_path - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: match$2.pext_loc, + _2: { + TAG: /* Not_open_type */10, + _0: type_path + } + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } } else { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Not_extensible_type */11, - _0: type_path - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Not_extensible_type */11, + _0: type_path + } + } + }); } var type_variance = Stdlib__List.map((function (v) { var match = Curry._1(Types_Variance.get_upper, v); @@ -75505,16 +77183,17 @@ function transl_type_extension(check_open, env, loc, styext) { }) ); if (Caml_obj.caml_notequal(err, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Extension_mismatch */12, - _0: type_path, - _1: err - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Extension_mismatch */12, + _0: type_path, + _1: err + } + } + }); } var ttype_params = make_params(env, styext.ptyext_params); var type_params = Stdlib__List.map((function (param) { @@ -75539,16 +77218,17 @@ function transl_type_extension(check_open, env, loc, styext) { if (ty === undefined) { return ; } - throw { - MEL_EXN_ID: $$Error$8, - _1: ext.ext_loc, - _2: { - TAG: /* Unbound_type_var_ext */19, - _0: ty, - _1: ext.ext_type - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: ext.ext_loc, + _2: { + TAG: /* Unbound_type_var_ext */19, + _0: ty, + _1: ext.ext_type + } + } + }); }), constructors); Stdlib__List.iter((function (ext) { compute_variance_extension(env, true, type_decl, ext.ext_type, [ @@ -75585,16 +77265,17 @@ function transl_exception(env, sext) { may(generalize, ext.ext_type.ext_ret_type); var ty = closed_extension_constructor(ext.ext_type); if (ty !== undefined) { - throw { - MEL_EXN_ID: $$Error$8, - _1: ext.ext_loc, - _2: { - TAG: /* Unbound_type_var_ext */19, - _0: ty, - _1: ext.ext_type - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: ext.ext_loc, + _2: { + TAG: /* Unbound_type_var_ext */19, + _0: ty, + _1: ext.ext_type + } + } + }); } var newenv = add_extension(true, ext.ext_id, ext.ext_type, env); return [ @@ -75659,20 +77340,22 @@ function transl_value_decl(env, loc, valdecl) { var prim = parse_declaration(arity$1, decl); var prim_native_name = prim.prim_native_name; if (arity$1 === 0 && !(prim_native_name.length > 3 && prim_native_name[0] === "B" && prim_native_name[1] === "S" && prim_native_name[2] === ":") && (prim.prim_name.length === 0 || Caml_string.get(prim.prim_name, 0) !== /* '%' */37 && Caml_string.get(prim.prim_name, 0) !== /* '#' */35)) { - throw { - MEL_EXN_ID: $$Error$8, - _1: valdecl.pval_type.ptyp_loc, - _2: /* Null_arity_external */2, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: valdecl.pval_type.ptyp_loc, + _2: /* Null_arity_external */2 + } + }); } if (native_code.contents && prim.prim_arity > 5 && prim_native_name === "") { - throw { - MEL_EXN_ID: $$Error$8, - _1: valdecl.pval_type.ptyp_loc, - _2: /* Missing_native_external */3, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: valdecl.pval_type.ptyp_loc, + _2: /* Missing_native_external */3 + } + }); } v = { val_type: ty, @@ -75749,18 +77432,21 @@ function transl_with_constraint(env, id, row_path, orig_decl, sdecl) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$8, - _1: loc, - _2: { - TAG: /* Inconsistent_constraint */6, - _0: env, - _1: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: loc, + _2: { + TAG: /* Inconsistent_constraint */6, + _0: env, + _1: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), sdecl.ptype_cstrs); var no_row = !is_fixed_type(sdecl); @@ -75808,16 +77494,17 @@ function transl_with_constraint(env, id, row_path, orig_decl, sdecl) { } var ty = closed_type_decl(decl); if (ty !== undefined) { - throw { - MEL_EXN_ID: $$Error$8, - _1: sdecl.ptype_loc, - _2: { - TAG: /* Unbound_type_var */9, - _0: ty, - _1: decl - }, - Error: new Error() - }; + throw new Error($$Error$8, { + cause: { + MEL_EXN_ID: $$Error$8, + _1: sdecl.ptype_loc, + _2: { + TAG: /* Unbound_type_var */9, + _0: ty, + _1: decl + } + } + }); } var decl$1 = name_recursion(sdecl, id, decl); var decl_type_params = decl$1.type_params; @@ -75999,7 +77686,9 @@ function explain_unbound(ppf, tv, tl, typ, kwd, lab) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -77618,17 +79307,18 @@ function enter_val(cl_num, vars, inh, lab, mut, virt, ty, val_env, met_env, par_ var match$1 = Curry._2(Meths.find, lab, vars.contents); var virt$p = match$1[2]; if (match$1[1] !== mut) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Mutability_mismatch */22, - _0: lab, - _1: mut - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Mutability_mismatch */22, + _0: lab, + _1: mut + } + } + }); } unify$2(val_env, instance(undefined, val_env, ty), instance(undefined, val_env, match$1[3])); match = [ @@ -77639,18 +79329,19 @@ function enter_val(cl_num, vars, inh, lab, mut, virt, ty, val_env, met_env, par_ catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Field_type_mismatch */1, - _0: "instance variable", - _1: lab, - _2: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Field_type_mismatch */1, + _0: "instance variable", + _1: lab, + _2: exn._1 + } + } + }); } if (exn.MEL_EXN_ID === Stdlib.Not_found) { match = [ @@ -77658,7 +79349,9 @@ function enter_val(cl_num, vars, inh, lab, mut, virt, ty, val_env, met_env, par_ virt ]; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var id = match[0]; @@ -77716,18 +79409,19 @@ function inheritance(self_type, env, ovf, concr_meths, warn_vals, loc, parent) { exit = 1; } else { if (match$3.TAG === /* Tfield */5) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: env, - _3: { - TAG: /* Field_type_mismatch */1, - _0: "method", - _1: match$3._0, - _2: match$2.tl - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: env, + _3: { + TAG: /* Field_type_mismatch */1, + _0: "method", + _1: match$3._0, + _2: match$2.tl + } + } + }); } exit = 1; } @@ -77744,19 +79438,22 @@ function inheritance(self_type, env, ovf, concr_meths, warn_vals, loc, parent) { exit = 1; } if (exit === 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 48280, - 12 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 48280, + 12 + ] + } + }); } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var over_meths = Curry._2(inter$1, cl_sig$1.csig_concr, concr_meths); @@ -77795,17 +79492,18 @@ function inheritance(self_type, env, ovf, concr_meths, warn_vals, loc, parent) { } } else if (Curry._1(is_empty$1, over_meths) && Curry._1(is_empty$1, over_vals)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: env, - _3: { - TAG: /* No_overriding */23, - _0: "", - _1: "" - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: env, + _3: { + TAG: /* No_overriding */23, + _0: "", + _1: "" + } + } + }); } } @@ -77818,16 +79516,17 @@ function inheritance(self_type, env, ovf, concr_meths, warn_vals, loc, parent) { ]; case /* Cty_constr */0 : case /* Cty_arrow */2 : - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: env, - _3: { - TAG: /* Structure_expected */2, - _0: parent - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: env, + _3: { + TAG: /* Structure_expected */2, + _0: parent + } + } + }); } } @@ -77843,20 +79542,23 @@ function virtual_method(val_env, meths, self_type, lab, priv, sty, loc) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Field_type_mismatch */1, - _0: "method", - _1: lab, - _2: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Field_type_mismatch */1, + _0: "method", + _1: lab, + _2: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return cty; } @@ -77875,20 +79577,23 @@ function declare_method(val_env, meths, self_type, lab, priv, sty, loc) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Field_type_mismatch */1, - _0: "method", - _1: lab, - _2: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Field_type_mismatch */1, + _0: "method", + _1: lab, + _2: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var sty$1 = force_poly(sty); @@ -77932,18 +79637,21 @@ function type_constraint(val_env, sty, sty$p, loc) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Unconsistent_constraint */0, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Unconsistent_constraint */0, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return [ cty, @@ -77974,7 +79682,9 @@ function add_val(env, loc, lab, param, val_sig) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { virt$1 = virt; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } return Curry._3(Meths.add, lab, [ @@ -78009,18 +79719,21 @@ function class_signature$1(env, param) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: sty.ptyp_loc, - _2: env, - _3: { - TAG: /* Pattern_type_clash */5, - _0: self_type - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: sty.ptyp_loc, + _2: env, + _3: { + TAG: /* Pattern_type_clash */5, + _0: self_type + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } warning_enter_scope(undefined); var match = Stdlib__List.fold_left((function (param, param$1) { @@ -78165,11 +79878,12 @@ function class_signature$1(env, param) { inher ]; case /* Pctf_extension */5 : - throw { - MEL_EXN_ID: Error_forward$2, - _1: error_of_extension(sparent._0), - Error: new Error() - }; + throw new Error(Error_forward$2, { + cause: { + MEL_EXN_ID: Error_forward$2, + _1: error_of_extension(sparent._0) + } + }); } }), [ @@ -78214,32 +79928,34 @@ function class_type$3(env, scty) { var decl = match[1]; var path = match[0]; if (same(decl.clty_path, unbound_class)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: scty.pcty_loc, - _2: env, - _3: { - TAG: /* Unbound_class_type_2 */7, - _0: lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: scty.pcty_loc, + _2: env, + _3: { + TAG: /* Unbound_class_type_2 */7, + _0: lid.txt + } + } + }); } var match$1 = instance_class(decl.clty_params, decl.clty_type); var params = match$1[0]; if (Stdlib__List.length(params) !== Stdlib__List.length(styl)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: scty.pcty_loc, - _2: env, - _3: { - TAG: /* Parameter_arity_mismatch */11, - _0: lid.txt, - _1: Stdlib__List.length(params), - _2: Stdlib__List.length(styl) - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: scty.pcty_loc, + _2: env, + _3: { + TAG: /* Parameter_arity_mismatch */11, + _0: lid.txt, + _1: Stdlib__List.length(params), + _2: Stdlib__List.length(styl) + } + } + }); } var ctys = Stdlib__List.map2((function (sty, ty) { var cty$p = transl_simple_type(env, false, sty); @@ -78250,18 +79966,21 @@ function class_type$3(env, scty) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: sty.ptyp_loc, - _2: env, - _3: { - TAG: /* Parameter_mismatch */12, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: sty.ptyp_loc, + _2: env, + _3: { + TAG: /* Parameter_mismatch */12, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return cty$p; }), styl, params); @@ -78307,11 +80026,12 @@ function class_type$3(env, scty) { _2: clty }, typ$2); case /* Pcty_extension */3 : - throw { - MEL_EXN_ID: Error_forward$2, - _1: error_of_extension(pcsig._0), - Error: new Error() - }; + throw new Error(Error_forward$2, { + cause: { + MEL_EXN_ID: Error_forward$2, + _1: error_of_extension(pcsig._0) + } + }); } } @@ -78367,18 +80087,21 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: spat.ppat_loc, - _2: val_env$1, - _3: { - TAG: /* Pattern_type_clash */5, - _0: public_self - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: spat.ppat_loc, + _2: val_env$1, + _3: { + TAG: /* Pattern_type_clash */5, + _0: public_self + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var get_methods = function (ty) { return flatten_fields(object_fields(expand_head(val_env$1, ty)))[0]; @@ -78390,15 +80113,16 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { return unify$2(val_env$1, param[2], filter_method(val_env$1, param[0], k, self_type)); } catch (exn){ - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 48779, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 48779, + 18 + ] + } + }); } }), get_methods(public_self)); } @@ -78581,17 +80305,18 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { } var ovf$1 = styp._0; if (Curry._2(mem$2, lab.txt, local_vals)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Duplicate */24, - _0: "instance variable", - _1: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Duplicate */24, + _0: "instance variable", + _1: lab.txt + } + } + }); } if (Curry._2(mem$2, lab.txt, warn_vals)) { if (ovf$1 === /* Fresh */1) { @@ -78605,17 +80330,18 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { } } else if (ovf$1 === /* Override */0) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* No_overriding */23, - _0: "instance variable", - _1: lab.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* No_overriding */23, + _0: "instance variable", + _1: lab.txt + } + } + }); } if (principal.contents) { begin_def(undefined); @@ -78630,22 +80356,29 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { var match$7 = exn._1; if (match$7) { if (match$7.tl) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Make_nongen_seltype */17, - _0: match$7.hd[0] - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Make_nongen_seltype */17, + _0: match$7.hd[0] + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (principal.contents) { end_def(undefined); @@ -78725,17 +80458,18 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { var expr$2; expr$2 = match$10.TAG === /* Pexp_poly */28 ? expr$1 : Curry._4(Ast_helper_Exp.poly, expr$1.pexp_loc, undefined, expr$1, undefined); if (Curry._2(mem$2, lab$1.txt, local_meths)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Duplicate */24, - _0: "method", - _1: lab$1.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Duplicate */24, + _0: "method", + _1: lab$1.txt + } + } + }); } if (Curry._2(mem$2, lab$1.txt, concr_meths)) { if (ovf$2 === /* Fresh */1) { @@ -78749,17 +80483,18 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { } } else if (ovf$2 === /* Override */0) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* No_overriding */23, - _0: "method", - _1: lab$1.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* No_overriding */23, + _0: "method", + _1: lab$1.txt + } + } + }); } var match$11 = filter_self_method(val_env, lab$1.txt, priv, meths, self_type); var ty$1 = match$11[1]; @@ -78776,15 +80511,16 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { } var match$13 = repr(ty$1).desc; if (typeof match$13 === "number") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 48681, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 48681, + 17 + ] + } + }); } switch (match$13.TAG | 0) { case /* Tvar */0 : @@ -78802,45 +80538,50 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { unify$2(val_env, ty2, match$14[1]); break; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 48681, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 48681, + 17 + ] + } + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 48683, - 13 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 48683, + 13 + ] + } + }); } } catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env, - _3: { - TAG: /* Field_type_mismatch */1, - _0: "method", - _1: lab$1.txt, - _2: exn$1._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env, + _3: { + TAG: /* Field_type_mismatch */1, + _0: "method", + _1: lab$1.txt, + _2: exn$1._1 + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var meth_expr = make_method(self_loc, cl_num, expr$2); var vars_local = vars.contents; @@ -78980,11 +80721,12 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { local_vals ]; case /* Pcf_extension */6 : - throw { - MEL_EXN_ID: Error_forward$2, - _1: error_of_extension(expr._0), - Error: new Error() - }; + throw new Error(Error_forward$2, { + cause: { + MEL_EXN_ID: Error_forward$2, + _1: error_of_extension(expr._0) + } + }); } }), [ @@ -79038,19 +80780,20 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { } }), sign_csig_vars, /* [] */0); if (Caml_obj.caml_notequal(mets, /* [] */0) || Caml_obj.caml_notequal(vals, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env$1, - _3: { - TAG: /* Virtual_class */10, - _0: true, - _1: $$final, - _2: mets, - _3: vals - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env$1, + _3: { + TAG: /* Virtual_class */10, + _0: true, + _1: $$final, + _2: mets, + _3: vals + } + } + }); } var self_methods = Stdlib__List.fold_right((function (param, rem) { var kind = param[1]; @@ -79088,18 +80831,21 @@ function class_structure(cl_num, $$final, val_env, met_env, loc, param) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: val_env$1, - _3: { - TAG: /* Final_self_clash */21, - _0: exn$1._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: val_env$1, + _3: { + TAG: /* Final_self_clash */21, + _0: exn$1._1 + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } if (principal.contents) { @@ -79163,16 +80909,17 @@ function class_expr(cl_num, val_env, met_env, _scl) { var decl = match[1]; var path = match[0]; if (same(decl.cty_path, unbound_class)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: scl.pcl_loc, - _2: val_env, - _3: { - TAG: /* Unbound_class_2 */6, - _0: lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: scl.pcl_loc, + _2: val_env, + _3: { + TAG: /* Unbound_class_2 */6, + _0: lid.txt + } + } + }); } var tyl = Stdlib__List.map((function (sty) { return transl_simple_type(val_env, false, sty); @@ -79182,18 +80929,19 @@ function class_expr(cl_num, val_env, met_env, _scl) { var params = match$1[0]; var clty$p = abbreviate_class_type(path, params, clty); if (Stdlib__List.length(params) !== Stdlib__List.length(tyl)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: scl.pcl_loc, - _2: val_env, - _3: { - TAG: /* Parameter_arity_mismatch */11, - _0: lid.txt, - _1: Stdlib__List.length(params), - _2: Stdlib__List.length(tyl) - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: scl.pcl_loc, + _2: val_env, + _3: { + TAG: /* Parameter_arity_mismatch */11, + _0: lid.txt, + _1: Stdlib__List.length(params), + _2: Stdlib__List.length(tyl) + } + } + }); } Stdlib__List.iter2((function (cty$p, ty) { var ty$p = cty$p.ctyp_type; @@ -79203,18 +80951,21 @@ function class_expr(cl_num, val_env, met_env, _scl) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cty$p.ctyp_loc, - _2: val_env, - _3: { - TAG: /* Parameter_mismatch */12, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cty$p.ctyp_loc, + _2: val_env, + _3: { + TAG: /* Parameter_mismatch */12, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), tyl, params); var cl = rc({ @@ -79496,32 +81247,34 @@ function class_expr(cl_num, val_env, met_env, _scl) { if (ignore_labels && !is_optional(l)) { if (sargs) { var match$1 = sargs.hd; - throw { - MEL_EXN_ID: $$Error$9, - _1: match$1[1].pexp_loc, - _2: val_env, - _3: { - TAG: /* Apply_wrong_label */4, - _0: match$1[0] - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: match$1[1].pexp_loc, + _2: val_env, + _3: { + TAG: /* Apply_wrong_label */4, + _0: match$1[0] + } + } + }); } if (more_sargs) { var match$2 = more_sargs.hd; var sarg0 = match$2[1]; var l$p = match$2[0]; if (l !== l$p && l$p !== "") { - throw { - MEL_EXN_ID: $$Error$9, - _1: sarg0.pexp_loc, - _2: val_env, - _3: { - TAG: /* Apply_wrong_label */4, - _0: l$p - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: sarg0.pexp_loc, + _2: val_env, + _3: { + TAG: /* Apply_wrong_label */4, + _0: l$p + } + } + }); } match = [ /* [] */0, @@ -79529,15 +81282,16 @@ function class_expr(cl_num, val_env, met_env, _scl) { type_argument(val_env, sarg0, ty, ty0) ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 49036, - 20 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 49036, + 20 + ] + } + }); } } else { try { @@ -79562,7 +81316,9 @@ function class_expr(cl_num, val_env, met_env, _scl) { match$5[3] ]; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var sarg0$1 = match$3[1]; @@ -79597,7 +81353,9 @@ function class_expr(cl_num, val_env, met_env, _scl) { is_optional(l) && (Stdlib__List.mem_assoc("", sargs) || Stdlib__List.mem_assoc("", more_sargs)) ? option_none(ty0, none) : undefined ]; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } } @@ -79646,27 +81404,29 @@ function class_expr(cl_num, val_env, met_env, _scl) { } if (Caml_obj.caml_notequal(omitted, /* [] */0)) { var match$7 = match$6.hd; - throw { - MEL_EXN_ID: $$Error$9, - _1: match$7[1].pexp_loc, - _2: val_env, - _3: { - TAG: /* Apply_wrong_label */4, - _0: match$7[0] - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: match$7[1].pexp_loc, + _2: val_env, + _3: { + TAG: /* Apply_wrong_label */4, + _0: match$7[0] + } + } + }); } - throw { - MEL_EXN_ID: $$Error$9, - _1: cl$2.cl_loc, - _2: val_env, - _3: { - TAG: /* Cannot_apply */3, - _0: cl$2.cl_type - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl$2.cl_loc, + _2: val_env, + _3: { + TAG: /* Cannot_apply */3, + _0: cl$2.cl_type + } + } + }); }; } }(cl$2,ignore_labels)); @@ -79696,22 +81456,29 @@ function class_expr(cl_num, val_env, met_env, _scl) { var match$8 = exn._1; if (match$8) { if (match$8.tl) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw { - MEL_EXN_ID: $$Error$9, - _1: scl.pcl_loc, - _2: val_env, - _3: { - TAG: /* Make_nongen_seltype */17, - _0: match$8.hd[0] - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: scl.pcl_loc, + _2: val_env, + _3: { + TAG: /* Make_nongen_seltype */17, + _0: match$8.hd[0] + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var val_env$1 = match$7[1]; var defs = match$7[0]; @@ -79806,16 +81573,17 @@ function class_expr(cl_num, val_env, met_env, _scl) { limited_generalize$1(row_variable(repr(signature_of_class_type(clty$1.cltyp_type).csig_self)), clty$1.cltyp_type); var error = class_types(val_env, cl$4.cl_type, clty$1.cltyp_type); if (error) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl$4.cl_loc, - _2: val_env, - _3: { - TAG: /* Class_match_failure */14, - _0: error - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl$4.cl_loc, + _2: val_env, + _3: { + TAG: /* Class_match_failure */14, + _0: error + } + } + }); } var match$10 = extract_constraints(clty$1.cltyp_type); return rc({ @@ -79833,11 +81601,12 @@ function class_expr(cl_num, val_env, met_env, _scl) { cl_attributes: scl.pcl_attributes }); case /* Pcl_extension */6 : - throw { - MEL_EXN_ID: Error_forward$2, - _1: error_of_extension(cl_str._0), - Error: new Error() - }; + throw new Error(Error_forward$2, { + cause: { + MEL_EXN_ID: Error_forward$2, + _1: error_of_extension(cl_str._0) + } + }); } }; @@ -80056,15 +81825,18 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Already_bound) { - throw { - MEL_EXN_ID: $$Error$9, - _1: sty.ptyp_loc, - _2: env, - _3: /* Repeated_parameter */0, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: sty.ptyp_loc, + _2: env, + _3: /* Repeated_parameter */0 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var ci_params = Stdlib__List.map(make_param, cl.pci_params); @@ -80092,7 +81864,9 @@ function type_classes(define_class, approx, kind, env, cls) { } catch (exn){ self_coercion.contents = /* [] */0; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var typ = match[1]; end_def(undefined); @@ -80129,23 +81903,26 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn$1.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env, - _3: { - TAG: /* Bad_parameters */13, - _0: obj_id, - _1: constr, - _2: newconstr({ - TAG: /* Pident */0, - _0: obj_id - }, obj_params$p) - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env, + _3: { + TAG: /* Bad_parameters */13, + _0: obj_id, + _1: constr, + _2: newconstr({ + TAG: /* Pident */0, + _0: obj_id + }, obj_params$p) + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } try { unify$2(env, ty, constr); @@ -80153,20 +81930,23 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn$1){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$2.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env, - _3: { - TAG: /* Abbrev_type_clash */8, - _0: constr, - _1: ty, - _2: expand_head(env, constr) - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env, + _3: { + TAG: /* Abbrev_type_clash */8, + _0: constr, + _1: ty, + _2: expand_head(env, constr) + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } var match$3 = instance_class(params, typ); var cl_params$p = match$3[0]; @@ -80181,26 +81961,29 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn$2){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$3.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env, - _3: { - TAG: /* Bad_parameters */13, - _0: cl_id, - _1: newconstr({ - TAG: /* Pident */0, - _0: cl_id - }, cl_params), - _2: newconstr({ - TAG: /* Pident */0, - _0: cl_id - }, cl_params$p) - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env, + _3: { + TAG: /* Bad_parameters */13, + _0: cl_id, + _1: newconstr({ + TAG: /* Pident */0, + _0: cl_id + }, cl_params), + _2: newconstr({ + TAG: /* Pident */0, + _0: cl_id + }, cl_params$p) + } + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } try { unify$2(env, ty$1, cl_ty); @@ -80212,20 +81995,23 @@ function type_classes(define_class, approx, kind, env, cls) { TAG: /* Pident */0, _0: cl_id }, params); - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env, - _3: { - TAG: /* Abbrev_type_clash */8, - _0: constr$1, - _1: ty$1, - _2: cl_ty - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env, + _3: { + TAG: /* Abbrev_type_clash */8, + _0: constr$1, + _1: ty$1, + _2: cl_ty + } + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } try { unify$2(env, constructor_type(constr, obj_type), instance(undefined, env, constr_type)); @@ -80233,19 +82019,22 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn$4){ var exn$5 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$5.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env, - _3: { - TAG: /* Constructor_type_mismatch */9, - _0: cl.pci_name.txt, - _1: exn$5._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env, + _3: { + TAG: /* Constructor_type_mismatch */9, + _0: cl.pci_name.txt, + _1: exn$5._1 + } + } + }); } - throw exn$5; + throw new Error(exn$5.MEL_EXN_ID, { + cause: exn$5 + }); } var cty_variance = Stdlib__List.map((function (param) { return Types_Variance.full; @@ -80294,19 +82083,20 @@ function type_classes(define_class, approx, kind, env, cls) { } }), sign.csig_vars, /* [] */0); if (Caml_obj.caml_notequal(mets, /* [] */0) || Caml_obj.caml_notequal(vals, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env$1, - _3: { - TAG: /* Virtual_class */10, - _0: define_class, - _1: false, - _2: mets, - _3: vals - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env$1, + _3: { + TAG: /* Virtual_class */10, + _0: define_class, + _1: false, + _2: mets, + _3: vals + } + } + }); } } @@ -80430,20 +82220,23 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env$1, - _3: { - TAG: /* Non_collapsable_conjunction */20, - _0: id, - _1: clty, - _2: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env$1, + _3: { + TAG: /* Non_collapsable_conjunction */20, + _0: id, + _1: clty, + _2: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } Stdlib__List.iter(generalize, clty.cty_params); generalize_class_type(generalize, clty.cty_type); @@ -80453,17 +82246,18 @@ function type_classes(define_class, approx, kind, env, cls) { Stdlib__List.iter(generalize, cl_abbr.type_params); may(generalize, cl_abbr.type_manifest); if (!closed_class$1(clty)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env$1, - _3: { - TAG: /* Non_generalizable_class */18, - _0: id, - _1: clty - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env$1, + _3: { + TAG: /* Non_generalizable_class */18, + _0: id, + _1: clty + } + } + }); } var reason = closed_class(clty.cty_params, signature_of_class_type(clty.cty_type)); if (reason !== undefined) { @@ -80472,17 +82266,18 @@ function type_classes(define_class, approx, kind, env, cls) { }) : (function (ppf) { cltype_declaration$1(id, ppf, cltydef); }); - throw { - MEL_EXN_ID: $$Error$9, - _1: cl.pci_loc, - _2: env$1, - _3: { - TAG: /* Unbound_type_var */16, - _0: printer, - _1: reason - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: cl.pci_loc, + _2: env$1, + _3: { + TAG: /* Unbound_type_var */16, + _0: printer, + _1: reason + } + } + }); } return [ id, @@ -80541,26 +82336,28 @@ function type_classes(define_class, approx, kind, env, cls) { match$4[1] ]; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 49581, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 49581, + 15 + ] + } + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 49581, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 49581, + 15 + ] + } + }); } var obj_ty = match$2[1]; var cl_ty = match$2[0]; @@ -80570,31 +82367,35 @@ function type_classes(define_class, approx, kind, env, cls) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Subtype) { - throw { - MEL_EXN_ID: $$Error$7, - _1: loc, - _2: env$2, - _3: { - TAG: /* Not_subtype */23, - _0: exn._1, - _1: exn._2 - }, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: loc, + _2: env$2, + _3: { + TAG: /* Not_subtype */23, + _0: exn._1, + _1: exn._2 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } if (!opened_object(cl_ty)) { - throw { - MEL_EXN_ID: $$Error$9, - _1: loc, - _2: env$2, - _3: { - TAG: /* Cannot_coerce_self */19, - _0: obj_ty - }, - Error: new Error() - }; + throw new Error($$Error$9, { + cause: { + MEL_EXN_ID: $$Error$9, + _1: loc, + _2: env$2, + _3: { + TAG: /* Cannot_coerce_self */19, + _0: obj_ty + } + } + }); } } @@ -80687,15 +82488,16 @@ function unify_parents_struct(env, ty, st) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 49658, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 49658, + 15 + ] + } + }); } case /* Tcl_structure */1 : return unify_parents_struct(env, ty, st._0); @@ -82201,15 +84003,16 @@ function path_concat(head, p) { _2: p._2 }; case /* Papply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 50016, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 50016, + 16 + ] + } + }); } } @@ -82219,13 +84022,14 @@ function extract_sig(env, loc, mty) { if (sg.TAG === /* Mty_signature */1) { return sg._0; } - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: env, - _3: /* Signature_expected */0, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: env, + _3: /* Signature_expected */0 + } + }); } function extract_sig_open(env, loc, mty) { @@ -82233,16 +84037,17 @@ function extract_sig_open(env, loc, mty) { if (sg.TAG === /* Mty_signature */1) { return sg._0; } - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: env, - _3: { - TAG: /* Structure_expected */3, - _0: mty - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: env, + _3: { + TAG: /* Structure_expected */3, + _0: mty + } + } + }); } function type_open_(toplevel, ovf, env, loc, lid) { @@ -82278,15 +84083,16 @@ function type_open$1(toplevel, env, sod) { var type_module_type_of_fwd = { contents: (function (env, m) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 50061, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 50061, + 22 + ] + } + }); }) }; @@ -82723,16 +84529,17 @@ function merge_constraint(initial_env, loc, sg, constr) { } ]; } - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: env, - _3: { - TAG: /* With_no_component */4, - _0: lid.txt - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: env, + _3: { + TAG: /* With_no_component */4, + _0: lid.txt + } + } + }); }; }; try { @@ -82753,15 +84560,16 @@ function merge_constraint(initial_env, loc, sg, constr) { if (id !== undefined) { id$1 = id; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 50208, - 38 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 50208, + 38 + ] + } + }); } var lid$1; try { @@ -82769,10 +84577,11 @@ function merge_constraint(initial_env, loc, sg, constr) { if (match$1 !== undefined) { var match$2 = match$1.ptyp_desc; if (typeof match$2 === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (match$2.TAG === /* Ptyp_constr */3) { var stl = match$2._1; @@ -82780,71 +84589,82 @@ function merge_constraint(initial_env, loc, sg, constr) { Stdlib__List.iter2((function (x, param) { var sx = x.ptyp_desc; if (typeof sx === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (sx.TAG === /* Ptyp_var */0) { var sy = param[0].ptyp_desc; if (typeof sy === "number") { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } if (sy.TAG === /* Ptyp_var */0) { if (sx._0 === sy._0) { return ; } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } }), stl, sdecl.ptype_params); lid$1 = match$2._0; } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Exit) { - throw { - MEL_EXN_ID: $$Error$10, - _1: sdecl.ptype_loc, - _2: initial_env, - _3: /* With_need_typeconstr */2, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: sdecl.ptype_loc, + _2: initial_env, + _3: /* With_need_typeconstr */2 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var match$3; try { @@ -82853,17 +84673,20 @@ function merge_constraint(initial_env, loc, sg, constr) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 50225, - 68 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 50225, + 68 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var sub = add_type(id$1, match$3[0], identity); sg$2 = signature$2(sub, sg$1); @@ -82874,15 +84697,16 @@ function merge_constraint(initial_env, loc, sg, constr) { if (id$2 !== undefined) { id$3 = id$2; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 50231, - 38 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 50231, + 38 + ] + } + }); } var path = lookup_module$1(undefined, initial_env, loc, constr._1.txt); var sub$1 = add_module(id$3, path, identity); @@ -82901,19 +84725,22 @@ function merge_constraint(initial_env, loc, sg, constr) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: initial_env, - _3: { - TAG: /* With_mismatch */5, - _0: lid.txt, - _1: exn$2._1 - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: initial_env, + _3: { + TAG: /* With_mismatch */5, + _0: lid.txt, + _1: exn$2._1 + } + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -83015,11 +84842,12 @@ function approx_modtype(env, _smty) { case /* Pmty_typeof */4 : return Curry._2(type_module_type_of_fwd.contents, env, lid._0)[1]; case /* Pmty_extension */5 : - throw { - MEL_EXN_ID: Error_forward$3, - _1: error_of_extension(lid._0), - Error: new Error() - }; + throw new Error(Error_forward$3, { + cause: { + MEL_EXN_ID: Error_forward$3, + _1: error_of_extension(lid._0) + } + }); case /* Pmty_alias */6 : var path = lookup_module$1(undefined, env, smty.pmty_loc, lid._0.txt); return { @@ -83230,17 +85058,19 @@ function bal$12(l, v, r) { if (lr) { return create$13(create$13(ll, lv, lr.l), lr.v, create$13(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -83260,17 +85090,19 @@ function bal$12(l, v, r) { if (rl) { return create$13(create$13(l, v, rl.l), rl.v, create$13(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add$14(x, t) { @@ -83322,17 +85154,18 @@ function mem$7(x, _param) { function check(cl, loc, set_ref, name) { if (Curry._2(mem$7, name, set_ref.contents)) { - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: empty, - _3: { - TAG: /* Repeated_name */6, - _0: cl, - _1: name - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: empty, + _3: { + TAG: /* Repeated_name */6, + _0: cl, + _1: name + } + } + }); } set_ref.contents = Curry._2(add$14, name, set_ref.contents); } @@ -83581,11 +85414,12 @@ function transl_modtype$1(env, smty) { _0: match$2[0] }, match$2[1], env, loc, smty.pmty_attributes); case /* Pmty_extension */5 : - throw { - MEL_EXN_ID: Error_forward$3, - _1: error_of_extension(lid._0), - Error: new Error() - }; + throw new Error(Error_forward$3, { + cause: { + MEL_EXN_ID: Error_forward$3, + _1: error_of_extension(lid._0) + } + }); case /* Pmty_alias */6 : var lid$2 = lid._0; var path$1 = transl_module_alias(loc, env, lid$2.txt); @@ -83999,11 +85833,12 @@ function transl_signature(env, sg) { match$21[2] ]; case /* Psig_extension */12 : - throw { - MEL_EXN_ID: Error_forward$3, - _1: error_of_extension(sdesc._0), - Error: new Error() - }; + throw new Error(Error_forward$3, { + cause: { + MEL_EXN_ID: Error_forward$3, + _1: error_of_extension(sdesc._0) + } + }); } }; @@ -84226,18 +86061,20 @@ function path_of_module(_mexp) { _1: path_of_module(match._1) }; } - throw { - MEL_EXN_ID: Not_a_path, - Error: new Error() - }; + throw new Error(Not_a_path, { + cause: { + MEL_EXN_ID: Not_a_path + } + }); case /* Tmod_constraint */4 : _mexp = match._0; continue ; default: - throw { - MEL_EXN_ID: Not_a_path, - Error: new Error() - }; + throw new Error(Not_a_path, { + cause: { + MEL_EXN_ID: Not_a_path + } + }); } }; } @@ -84251,7 +86088,9 @@ function path_of_module$1(mexp) { if (exn.MEL_EXN_ID === Not_a_path) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -84383,18 +86222,21 @@ function check_recmodule_inclusion(env, bindings) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$10, - _1: modl.mod_loc, - _2: env$1, - _3: { - TAG: /* Not_included */1, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: modl.mod_loc, + _2: env$1, + _3: { + TAG: /* Not_included */1, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var modl$p_mod_desc = { TAG: /* Tmod_constraint */4, @@ -84542,13 +86384,14 @@ function modtype_of_package(env, loc, p, nl, tl) { _0: p }; } - throw { - MEL_EXN_ID: $$Error$10, - _1: loc, - _2: env, - _3: /* Signature_expected */0, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: loc, + _2: env, + _3: /* Signature_expected */0 + } + }); } } @@ -84559,15 +86402,18 @@ function modtype_of_package(env, loc, p, nl, tl) { TAG: /* Unbound_modtype */22, _0: lid_of_path(undefined, p) }; - throw { - MEL_EXN_ID: $$Error$6, - _1: loc, - _2: env, - _3: error, - Error: new Error() - }; + throw new Error($$Error$6, { + cause: { + MEL_EXN_ID: $$Error$6, + _1: loc, + _2: env, + _3: error + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -84589,7 +86435,9 @@ function package_subtype$1(env, p1, nl1, tl1, p2, nl2, tl2) { if (exn.MEL_EXN_ID === $$Error$5) { return false; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -84603,18 +86451,21 @@ function wrap_constraint(env, arg, mty, explicit) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$10, - _1: arg.mod_loc, - _2: env, - _3: { - TAG: /* Not_included */1, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: arg.mod_loc, + _2: env, + _3: { + TAG: /* Not_included */1, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } return { mod_desc: { @@ -84805,22 +86656,24 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { TAG: /* Pmod_structure */1, _0: /* [] */0 })) { - throw { - MEL_EXN_ID: $$Error$10, - _1: sfunct.pmod_loc, - _2: env, - _3: /* Apply_generative */4, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: sfunct.pmod_loc, + _2: env, + _3: /* Apply_generative */4 + } + }); } if (funct_body && contains_type$1(env, funct.mod_type)) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: /* Not_allowed_in_functor_body */1, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: /* Not_allowed_in_functor_body */1 + } + }); } } @@ -84831,18 +86684,21 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === $$Error$5) { - throw { - MEL_EXN_ID: $$Error$10, - _1: sarg.pmod_loc, - _2: env, - _3: { - TAG: /* Not_included */1, - _0: exn._1 - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: sarg.pmod_loc, + _2: env, + _3: { + TAG: /* Not_included */1, + _0: exn._1 + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var mty_appl; if (path$1 !== undefined) { @@ -84856,18 +86712,21 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: { - TAG: /* Cannot_eliminate_dependency */2, - _0: mty_functor - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: { + TAG: /* Cannot_eliminate_dependency */2, + _0: mty_functor + } + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } var node_mod_desc$2 = { @@ -84891,16 +86750,17 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { }); return node$3; } - throw { - MEL_EXN_ID: $$Error$10, - _1: sfunct.pmod_loc, - _2: env, - _3: { - TAG: /* Cannot_apply */0, - _0: funct.mod_type - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: sfunct.pmod_loc, + _2: env, + _3: { + TAG: /* Cannot_apply */0, + _0: funct.mod_type + } + } + }); case /* Pmod_constraint */4 : var arg$1 = type_module$1(alias, true, funct_body, anchor, env, lid._0); var mty$3 = transl_modtype$1(env, lid._1); @@ -84942,28 +86802,30 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { } else { switch (match$4.TAG | 0) { case /* Tvar */0 : - throw { - MEL_EXN_ID: $$Error$7, - _1: smod.pmod_loc, - _2: env, - _3: /* Cannot_infer_signature */3, - Error: new Error() - }; + throw new Error($$Error$7, { + cause: { + MEL_EXN_ID: $$Error$7, + _1: smod.pmod_loc, + _2: env, + _3: /* Cannot_infer_signature */3 + } + }); case /* Tpackage */11 : var tl = match$4._2; if (Stdlib__List.exists((function (t) { return Caml_obj.caml_notequal(free_variables$1(undefined, t), /* [] */0); }), tl)) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: { - TAG: /* Incomplete_packed_module */13, - _0: exp.exp_type - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: { + TAG: /* Incomplete_packed_module */13, + _0: exp.exp_type + } + } + }); } if (principal.contents && !generalizable(99999999, exp.exp_type)) { prerr_warning(smod.pmod_loc, { @@ -84978,25 +86840,27 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { } } if (exit$1 === 1) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: { - TAG: /* Not_a_packed_module */12, - _0: exp.exp_type - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: { + TAG: /* Not_a_packed_module */12, + _0: exp.exp_type + } + } + }); } if (funct_body && contains_type$1(env, mty$4)) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: /* Not_allowed_in_functor_body */1, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: /* Not_allowed_in_functor_body */1 + } + }); } var node_mod_desc$4 = { TAG: /* Tmod_unpack */5, @@ -85018,11 +86882,12 @@ function type_module$1(aliasOpt, sttn, funct_body, anchor, env, smod) { }); return node$5; case /* Pmod_extension */6 : - throw { - MEL_EXN_ID: Error_forward$3, - _1: error_of_extension(lid._0), - Error: new Error() - }; + throw new Error(Error_forward$3, { + cause: { + MEL_EXN_ID: Error_forward$3, + _1: error_of_extension(lid._0) + } + }); } } @@ -85228,13 +87093,14 @@ function type_structure(toplevelOpt, funct_body, anchor, env, sstr, scope) { mb.pmb_loc ]; } - throw { - MEL_EXN_ID: $$Error$10, - _1: mb.pmb_expr.pmod_loc, - _2: env, - _3: /* Recursive_module_require_explicit_type */3, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: mb.pmb_expr.pmod_loc, + _2: env, + _3: /* Recursive_module_require_explicit_type */3 + } + }); }), desc._0); Stdlib__List.iter((function (param) { check_name("module", module_names, param[0]); @@ -85519,11 +87385,12 @@ function type_structure(toplevelOpt, funct_body, anchor, env, sstr, scope) { env ]; case /* Pstr_extension */14 : - throw { - MEL_EXN_ID: Error_forward$3, - _1: error_of_extension(desc._0), - Error: new Error() - }; + throw new Error(Error_forward$3, { + cause: { + MEL_EXN_ID: Error_forward$3, + _1: error_of_extension(desc._0) + } + }); } }; @@ -85672,16 +87539,17 @@ function type_module_type_of(env, smod) { var mty = tmty.mod_type; var mty$1 = remove_aliases$1(env, mty); if (!closed_modtype(mty$1)) { - throw { - MEL_EXN_ID: $$Error$10, - _1: smod.pmod_loc, - _2: env, - _3: { - TAG: /* Non_generalizable_module */9, - _0: mty$1 - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: smod.pmod_loc, + _2: env, + _3: { + TAG: /* Non_generalizable_module */9, + _0: mty$1 + } + } + }); } return [ tmty, @@ -85733,15 +87601,16 @@ function type_package$1(env, m, p, nl, tl) { _2: -1 }; case /* Lapply */2 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 51527, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 51527, + 11 + ] + } + }); } }; @@ -85773,19 +87642,22 @@ function type_package$1(env, m, p, nl, tl) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: $$Error$10, - _1: m.pmod_loc, - _2: env$1, - _3: { - TAG: /* Scoping_pack */14, - _0: n, - _1: ty - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: m.pmod_loc, + _2: env$1, + _3: { + TAG: /* Scoping_pack */14, + _0: n, + _1: ty + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }), nl, tl$p); return [ @@ -85850,18 +87722,21 @@ function type_implementation_more(sourcefile, outputprefix, modulename, initial_ catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: $$Error$10, - _1: in_file(sourcefile), - _2: empty, - _3: { - TAG: /* Interface_not_compiled */11, - _0: sourceintf - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: in_file(sourcefile), + _2: empty, + _3: { + TAG: /* Interface_not_compiled */11, + _0: sourceintf + } + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var dclsig = read_signature(modulename, intf_file); var coercion = compunit(initial_env, sourcefile, sg, intf_file, dclsig); @@ -85886,32 +87761,34 @@ function type_implementation_more(sourcefile, outputprefix, modulename, initial_ if (closed_schema(exp.exp_type)) { return ; } - throw { - MEL_EXN_ID: $$Error$10, - _1: exp.exp_loc, - _2: finalenv, - _3: { - TAG: /* Non_generalizable */7, - _0: exp.exp_type - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: exp.exp_loc, + _2: finalenv, + _3: { + TAG: /* Non_generalizable */7, + _0: exp.exp_type + } + } + }); }), match._1); case /* Tstr_module */6 : var md = match._0.mb_expr; if (closed_modtype(md.mod_type)) { return ; } - throw { - MEL_EXN_ID: $$Error$10, - _1: md.mod_loc, - _2: finalenv, - _3: { - TAG: /* Non_generalizable_module */9, - _0: md.mod_type - }, - Error: new Error() - }; + throw new Error($$Error$10, { + cause: { + MEL_EXN_ID: $$Error$10, + _1: md.mod_loc, + _2: finalenv, + _3: { + TAG: /* Non_generalizable_module */9, + _0: md.mod_type + } + } + }); default: return ; } @@ -85938,7 +87815,9 @@ function type_implementation_more(sourcefile, outputprefix, modulename, initial_ TAG: /* Partial_implementation */3, _0: Stdlib__Array.of_list(saved_types.contents) }, sourcefile, initial_env, undefined); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } diff --git a/jscomp/test/dist/jscomp/test/offset.js b/jscomp/test/dist/jscomp/test/offset.js index 0cdfaffd4f..e337946a43 100644 --- a/jscomp/test/dist/jscomp/test/offset.js +++ b/jscomp/test/dist/jscomp/test/offset.js @@ -46,17 +46,19 @@ function bal(l, v, r) { if (lr) { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -76,17 +78,19 @@ function bal(l, v, r) { if (rl) { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add(x, t) { @@ -175,10 +179,11 @@ function min_elt(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -207,10 +212,11 @@ function max_elt(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -237,11 +243,12 @@ function remove_min_elt(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function concat(t1, t2) { @@ -723,10 +730,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -757,10 +765,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -822,10 +831,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1040,15 +1050,16 @@ function of_list(l) { match$4[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/set.ml", - 571, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/set.ml", + 571, + 18 + ] + } + }); }; return sub(Stdlib__List.length(l$1), l$1)[0]; } else { diff --git a/jscomp/test/dist/jscomp/test/parser_api.js b/jscomp/test/dist/jscomp/test/parser_api.js index b92e202987..73b10b7bbd 100644 --- a/jscomp/test/dist/jscomp/test/parser_api.js +++ b/jscomp/test/dist/jscomp/test/parser_api.js @@ -45,7 +45,9 @@ catch (raw_exn){ if (exn.MEL_EXN_ID === Stdlib.Not_found) { standard_library = standard_library_default; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -777,10 +779,11 @@ var Fatal_error = /* @__PURE__ */Caml_exceptions.create("Parser_api.Misc.Fatal_e function fatal_error(msg) { Stdlib.prerr_string(">> Fatal error: "); console.error(msg); - throw { - MEL_EXN_ID: Fatal_error, - Error: new Error() - }; + throw new Error(Fatal_error, { + cause: { + MEL_EXN_ID: Fatal_error + } + }); } function try_finally(work, cleanup) { @@ -790,7 +793,9 @@ function try_finally(work, cleanup) { } catch (e){ Curry._1(cleanup, undefined); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } Curry._1(cleanup, undefined); return result; @@ -886,15 +891,16 @@ function split_last(param) { match[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "misc.ml", - 54, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "misc.ml", + 54, + 10 + ] + } + }); } function samelist(pred, _l1, _l2) { @@ -947,19 +953,21 @@ function find_in_path(path, name) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } if (Caml_external_polyfill.resolve("caml_sys_file_exists")(name)) { return name; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function find_in_path_rel(path, name) { @@ -989,10 +997,11 @@ function find_in_path_rel(path, name) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1014,10 +1023,11 @@ function find_in_path_uncap(path, name) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1030,7 +1040,9 @@ function remove_file(filename) { if (exn.MEL_EXN_ID === Stdlib.Sys_error) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1074,10 +1086,11 @@ function copy_file_chunk(ic, oc, len) { } var r = Stdlib.input(ic, buff, 0, n < 4096 ? n : 4096); if (r === 0) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); } Stdlib.output(oc, buff, 0, r); _n = n - r | 0; @@ -1141,7 +1154,9 @@ function chop_extension_if_any(fname) { if (exn.MEL_EXN_ID === Stdlib.Invalid_argument) { return fname; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1162,7 +1177,9 @@ function chop_extensions(file) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return file; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -1176,10 +1193,11 @@ function search_substring(pat, str, start) { return i; } if ((i + j | 0) >= str.length) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } if (Caml_string.get(str, i + j | 0) === Caml_string.get(pat, j)) { _j = j + 1 | 0; @@ -1209,7 +1227,9 @@ function replace_substring(before, after, str) { tl: acc }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var prefix = Stdlib__String.sub(str, curr, next - curr | 0); _curr = next + before.length | 0; @@ -1421,7 +1441,9 @@ function split(s, c) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { pos2 = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (pos2 === undefined) { @@ -1576,21 +1598,23 @@ function style_of_tag(param) { case "warning" : return cur_styles.contents.warning; default: - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } } else { - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "misc.ml", - 428, - 19 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "misc.ml", + 428, + 19 + ] + } + }); } } @@ -1616,7 +1640,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_mark_close_stag = function (param) { @@ -1636,7 +1662,9 @@ function set_color_tag_handling(ppf) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Curry._1(partial_arg$1, param); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; var functions$p_print_open_stag = functions.print_open_stag; @@ -2038,15 +2066,16 @@ function letter(param) { tl: /* [] */0 }; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 176, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 176, + 9 + ] + } + }); } } @@ -2120,11 +2149,12 @@ function parse_opt(error, active, flags, s) { var match$1 = get_num(0, i$1 + 2 | 0); var n2 = match$1[1]; if (n2 < n1) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } return [ match$1[0], @@ -2142,22 +2172,24 @@ function parse_opt(error, active, flags, s) { if (c >= 65) { if (c >= 97) { if (c >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(clear, letter(Caml_string.get(s, i))); _i = i + 1 | 0; continue ; } if (c >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(set, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); _i = i + 1 | 0; @@ -2167,72 +2199,79 @@ function parse_opt(error, active, flags, s) { if (c >= 64) { return loop_letter_num(set_all, i + 1 | 0); } - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } if (c >= 43) { switch (c) { case 43 : return loop_letter_num(set, i + 1 | 0); case 44 : - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); case 45 : return loop_letter_num(clear, i + 1 | 0); } } else { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } }; }; var loop_letter_num = function (myset, i) { if (i >= s.length) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match = Caml_string.get(s, i); if (match >= 65) { if (match >= 97) { if (match >= 123) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Caml_string.get(s, i))); return loop(i + 1 | 0); } if (match >= 91) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } Stdlib__List.iter(myset, letter(Stdlib__Char.lowercase_ascii(Caml_string.get(s, i)))); return loop(i + 1 | 0); } if (match > 57 || match < 48) { - throw { - MEL_EXN_ID: Stdlib__Arg.Bad, - _1: "Ill-formed list of warnings", - Error: new Error() - }; + throw new Error(Stdlib__Arg.Bad, { + cause: { + MEL_EXN_ID: Stdlib__Arg.Bad, + _1: "Ill-formed list of warnings" + } + }); } var match$1 = get_range(i); for(var n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n){ @@ -2330,15 +2369,16 @@ function message(param) { return "the method " + (lab + " is overridden."); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 283, - 26 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 283, + 26 + ] + } + }); case /* Partial_match */3 : var s$1 = param._0; if (s$1 === "") { @@ -2367,15 +2407,16 @@ function message(param) { return "the instance variable " + (lab$1 + " is overridden.\nThe behaviour changed in ocaml 3.10 (previous behaviour was hiding.)"); } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 303, - 37 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 303, + 37 + ] + } + }); case /* Implicit_public_methods */6 : return "the following private methods were made public implicitly:\n " + (Stdlib__String.concat(" ", param._0) + "."); case /* Undeclared_virtual_method */7 : @@ -2498,15 +2539,16 @@ function message(param) { if (param._2) { return "this record of type " + (ty + (" contains fields that are \nnot visible in the current scope: " + (Stdlib__String.concat(" ", slist) + ".\nThey will not be selected if the type becomes unknown."))); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 365, - 39 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 365, + 39 + ] + } + }); break; case /* Ambiguous_name */24 : var slist$1 = param._0; @@ -2516,15 +2558,16 @@ function message(param) { if (param._2) { return "these field labels belong to several types: " + (Stdlib__String.concat(" ", param._1) + "\nThe first one was selected. Please disambiguate if this is wrong."); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "warnings.ml", - 374, - 36 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "warnings.ml", + 374, + 36 + ] + } + }); break; case /* Disambiguated_name */25 : return "this use of " + (param._0 + " required disambiguation."); @@ -2727,7 +2770,9 @@ function check_fatal(param) { _1: e_1 }; nerrors.contents = 0; - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } function help_warnings(param) { @@ -3261,10 +3306,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Stdlib__Format.pp_print_flush(ppf, undefined); var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var lines = num_loc_lines.contents; for(var i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i){ @@ -3274,10 +3320,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { } if (lines >= (num_lines - 2 | 0)) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } Caml_io.caml_ml_flush(Stdlib.stdout); Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); @@ -3314,10 +3361,11 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { function highlight_dumb(ppf, lb, loc) { var pos0 = -lb.lex_abs_pos | 0; if (pos0 < 0) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } var end_pos = (lb.lex_buffer_len - pos0 | 0) - 1 | 0; var line_start = 0; @@ -3452,7 +3500,9 @@ function highlight_locations(ppf, locs) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { norepeat = false; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (norepeat) { @@ -3468,7 +3518,9 @@ function highlight_locations(ppf, locs) { if (exn$1.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } else { status.contents = Caml_external_polyfill.resolve("caml_terminfo_setup")(Stdlib.stdout); @@ -3488,7 +3540,9 @@ function highlight_locations(ppf, locs) { if (exn$2.MEL_EXN_ID === Stdlib.Exit) { return false; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } }; @@ -4067,7 +4121,9 @@ function report_exception(ppf, exn) { _1: "@[%a@]@." }), report_error, err); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } catch (raw_exn){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -4076,7 +4132,9 @@ function report_exception(ppf, exn) { _n = n - 1 | 0; continue ; } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } }; } @@ -4097,16 +4155,17 @@ function raise_errorf(locOpt, subOpt, if_highlightOpt) { var partial_arg = print_phanton_error_prefix; return function (param) { return pp_ksprintf(partial_arg, (function (msg) { - throw { - MEL_EXN_ID: $$Error, - _1: { - loc: loc, - msg: msg, - sub: sub, - if_highlight: if_highlight - }, - Error: new Error() - }; + throw new Error($$Error, { + cause: { + MEL_EXN_ID: $$Error, + _1: { + loc: loc, + msg: msg, + sub: sub, + if_highlight: if_highlight + } + } + }); }), param); }; } @@ -4212,7 +4271,9 @@ function split_at_dots(s, pos) { tl: /* [] */0 }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4498,7 +4559,9 @@ function get_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4511,7 +4574,9 @@ function mark_pre_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4535,7 +4600,9 @@ function get_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4548,7 +4615,9 @@ function mark_post_docs(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4562,7 +4631,9 @@ function get_info(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4584,7 +4655,9 @@ function get_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4606,7 +4679,9 @@ function get_pre_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4628,7 +4703,9 @@ function get_post_extra_text(pos) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return /* [] */0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4797,7 +4874,9 @@ function with_default_loc(l, f) { } catch (exn){ default_loc.contents = old; - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -6752,15 +6831,16 @@ function location_of_error(param) { } function ill_formed_ast(loc, s) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Ill_formed_ast */6, - _0: loc, - _1: s - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Ill_formed_ast */6, + _0: loc, + _1: s + } + } + }); } var Syntaxerr = { @@ -7088,15 +7168,16 @@ function mkexp_constraint(e, param) { _2: t2 }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/parser.mly", - 153, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/parser.mly", + 153, + 18 + ] + } + }); } function array_function(str, name) { @@ -7114,41 +7195,44 @@ function array_function(str, name) { } function unclosed(opening_name, opening_num, closing_name, closing_num) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Unclosed */0, - _0: rhs_loc(opening_num), - _1: opening_name, - _2: rhs_loc(closing_num), - _3: closing_name - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Unclosed */0, + _0: rhs_loc(opening_num), + _1: opening_name, + _2: rhs_loc(closing_num), + _3: closing_name + } + } + }); } function expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Expecting */1, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Expecting */1, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function not_expecting(pos, nonterm) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: rhs_loc(pos), - _1: nonterm - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: rhs_loc(pos), + _1: nonterm + } + } + }); } function bigarray_function(str, name) { @@ -7210,15 +7294,16 @@ function check_variable(vl, loc, v) { if (!Stdlib__List.mem(v, vl)) { return ; } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Variable_in_scope */4, - _0: loc, - _1: v - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Variable_in_scope */4, + _0: loc, + _1: v + } + } + }); } function varify_constructors(var_names, t) { @@ -7626,11 +7711,12 @@ var yytransl_block = [ var yyact = [ (function (param) { - throw { - MEL_EXN_ID: "Failure", - _1: "parser", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "parser" + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -7651,10 +7737,11 @@ var yyact = [ return Stdlib__Parsing.peek_val(__caml_parser_env, 1); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); @@ -8041,15 +8128,16 @@ var yyact = [ } if (exit === 1) { if (Caml_obj.caml_notequal(lbs.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lbs.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lbs.lbs_loc, + _1: "attributes" + } + } + }); } var bindings$1 = Stdlib__List.map((function (lb) { return mk$17(lb.lb_loc, lb.lb_attributes, CamlinternalLazy.force(lb.lb_docs), CamlinternalLazy.force(lb.lb_text), lb.lb_pattern, lb.lb_expression); @@ -8655,39 +8743,42 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); if (_1.lbs_extension !== undefined) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "extension" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "extension" + } + } + }); } if (Caml_obj.caml_notequal(_1.lbs_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: _1.lbs_loc, - _1: "attributes" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: _1.lbs_loc, + _1: "attributes" + } + } + }); } return mkclass({ TAG: /* Pcl_let */4, @@ -8868,10 +8959,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -8944,10 +9036,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -8967,10 +9060,11 @@ var yyact = [ var _4 = Stdlib__Parsing.peek_val(__caml_parser_env, 2); var _6 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); if (_1 === /* Override */0) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); } return [ { @@ -9509,15 +9603,16 @@ var yyact = [ var _3 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); var bindings = Stdlib__List.map((function (lb) { if (Caml_obj.caml_notequal(lb.lb_attributes, /* [] */0)) { - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Not_expecting */2, - _0: lb.lb_loc, - _1: "item attribute" - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Not_expecting */2, + _0: lb.lb_loc, + _1: "item attribute" + } + } + }); } return mk$17(lb.lb_loc, undefined, undefined, undefined, lb.lb_pattern, lb.lb_expression); }), _1.lbs_bindings); @@ -9629,10 +9724,11 @@ var yyact = [ (function (__caml_parser_env) { Stdlib__Parsing.peek_val(__caml_parser_env, 3); Stdlib__Parsing.peek_val(__caml_parser_env, 2); - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -11195,16 +11291,18 @@ var yyact = [ ]; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Escape_error, - Error: new Error() - }; + throw new Error(Escape_error, { + cause: { + MEL_EXN_ID: Escape_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -12340,17 +12438,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { return Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -12359,17 +12459,19 @@ var yyact = [ var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 1); if (_2) { if (_2.tl) { - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); } return _2.hd; } - throw { - MEL_EXN_ID: Stdlib__Parsing.Parse_error, - Error: new Error() - }; + throw new Error(Stdlib__Parsing.Parse_error, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.Parse_error + } + }); }), (function (__caml_parser_env) { var _2 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -13151,14 +13253,15 @@ var yyact = [ _1: _3 }; } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Applicative_path */3, - _0: symbol_rloc(undefined) - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Applicative_path */3, + _0: symbol_rloc(undefined) + } + } + }); }), (function (__caml_parser_env) { var _1 = Stdlib__Parsing.peek_val(__caml_parser_env, 0); @@ -13669,53 +13772,60 @@ var yyact = [ }; }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }), (function (__caml_parser_env) { - throw { - MEL_EXN_ID: Stdlib__Parsing.YYexit, - _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0), - Error: new Error() - }; + throw new Error(Stdlib__Parsing.YYexit, { + cause: { + MEL_EXN_ID: Stdlib__Parsing.YYexit, + _1: Stdlib__Parsing.peek_val(__caml_parser_env, 0) + } + }); }) ]; @@ -13815,16 +13925,17 @@ function assert_same_type(lexbuf, x, y) { var lhs = type_of_directive(x); var rhs = type_of_directive(y); if (lhs !== rhs) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: lhs, - _1: rhs - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: lhs, + _1: rhs + }, + _2: curr(lexbuf) + } + }); } return y; } @@ -13876,7 +13987,9 @@ catch (raw_exn$1){ if (exn$2.MEL_EXN_ID === Stdlib.Not_found) { tmp = ""; } else { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -13952,15 +14065,16 @@ function semantic_version_parse(str, start, last_index) { function semver(loc, lhs, str) { var last_index = str.length - 1 | 0; if (last_index < 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: loc + } + }); } var v = str.charCodeAt(0); var match; @@ -13979,15 +14093,16 @@ function semver(loc, lhs, str) { switch (v) { case 60 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: loc + } + }); } match = str[1] === "=" ? [ "Le", @@ -14002,15 +14117,16 @@ function semver(loc, lhs, str) { break; case 62 : if (last_index === 0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_semver */6, - _0: str - }, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_semver */6, + _0: str + }, + _2: loc + } + }); } match = str[1] === "=" ? [ "Ge", @@ -14177,7 +14293,9 @@ function query(loc, str) { _0: false }; } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } if (exit === 2) { try { @@ -14211,7 +14329,9 @@ function query(loc, str) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (typeof v === "number") { @@ -14275,12 +14395,13 @@ function value_of_token(loc, t) { _0: true }; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } else { switch (t.TAG | 0) { @@ -14302,12 +14423,13 @@ function value_of_token(loc, t) { case /* UIDENT */17 : return query(loc, t._0); default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } } } @@ -14328,12 +14450,13 @@ function directive_parse(token_with_comments, lexbuf) { if (typeof t === "number") { switch (t) { case /* EOF */25 : - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); case /* EOL */100 : _param = undefined; continue ; @@ -14354,15 +14477,16 @@ function directive_parse(token_with_comments, lexbuf) { }; var push = function (e) { if (look_ahead.contents !== undefined) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 312, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 312, + 4 + ] + } + }); } look_ahead.contents = e; }; @@ -14404,30 +14528,32 @@ function directive_parse(token_with_comments, lexbuf) { exit$2 = 3; } if (exit$2 === 3) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } } if (exit$1 === 2) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_string */3, - _1: type_of_directive(lhs) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_string */3, + _1: type_of_directive(lhs) + }, + _2: curr(lexbuf) + } + }); } break; case "<=" : @@ -14471,15 +14597,16 @@ function directive_parse(token_with_comments, lexbuf) { exit$3 = 2; } if (exit$3 === 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 331, - 17 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 331, + 17 + ] + } + }); } var curr_loc$1 = curr(lexbuf); var rhs$1 = value_of_token(curr_loc$1, token(undefined)); @@ -14536,36 +14663,39 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 81) { return v; } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_paren_in_conditional */1, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_paren_in_conditional */1, + _2: curr(lexbuf) + } + }); case /* TRUE */91 : return true; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } else { switch (curr_token.TAG | 0) { case /* FLOAT */1 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_float */1 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_float */1 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_float */1, _0: Caml_format.caml_float_of_string(curr_token._0) @@ -14586,22 +14716,24 @@ function directive_parse(token_with_comments, lexbuf) { case "undefined" : break; default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } var t = token(undefined); var loc = curr(lexbuf); if (typeof t === "number") { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); } if (t.TAG === /* UIDENT */17) { var s = t._0; @@ -14615,25 +14747,27 @@ function directive_parse(token_with_comments, lexbuf) { return true; } } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: loc + } + }); break; case /* STRING */16 : return token_op(calc, (function (e) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: /* Dir_type_string */3 - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: /* Dir_type_string */3 + }, + _2: curr_loc + } + }); }), { TAG: /* Dir_string */3, _0: curr_token._0[0] @@ -14646,24 +14780,26 @@ function directive_parse(token_with_comments, lexbuf) { return value_v._0; } var ty = type_of_directive(value_v); - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Conditional_expr_expected_type */7, - _0: /* Dir_type_bool */0, - _1: ty - }, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Conditional_expr_expected_type */7, + _0: /* Dir_type_bool */0, + _1: ty + }, + _2: curr_loc + } + }); }), value_v); default: - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_token_in_conditional */4, - _2: curr_loc, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_token_in_conditional */4, + _2: curr_loc + } + }); } } }; @@ -14672,12 +14808,13 @@ function directive_parse(token_with_comments, lexbuf) { if (match === 88) { return v; } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Expect_hash_then_in_conditional */5, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Expect_hash_then_in_conditional */5, + _2: curr(lexbuf) + } + }); } function is_elif(i) { @@ -15175,15 +15312,16 @@ function char_for_decimal_code(lexbuf, i) { if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { return /* 'x' */120; } - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_escape */1, - _0: Stdlib__Lexing.lexeme(lexbuf) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_escape */1, + _0: Stdlib__Lexing.lexeme(lexbuf) + }, + _2: curr(lexbuf) + } + }); } function char_for_hexadecimal_code(lexbuf, i) { @@ -15211,15 +15349,16 @@ function cvt_int64_literal(s) { } function cvt_nativeint_literal(s) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 622, - 30 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 622, + 30 + ] + } + }); } function remove_underscores(s) { @@ -15253,15 +15392,16 @@ function get_label_name(lexbuf) { var s = Stdlib__Lexing.lexeme(lexbuf); var name = Stdlib__String.sub(s, 1, s.length - 2 | 0); if (Stdlib__Hashtbl.mem(keyword_table, name)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Keyword_as_label */4, - _0: name - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Keyword_as_label */4, + _0: name + }, + _2: curr(lexbuf) + } + }); } return name; } @@ -15543,15 +15683,16 @@ function token(lexbuf) { switch (__ocaml_lex_state$1) { case 0 : if (!escaped_newlines.contents) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); } update_loc(lexbuf, undefined, 1, false, 0); return token(lexbuf); @@ -15607,7 +15748,9 @@ function token(lexbuf) { _0: s }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } case 11 : prerr_warning(curr(lexbuf), { @@ -15642,17 +15785,20 @@ function token(lexbuf) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int" + }, + _2: curr(lexbuf) + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } case 15 : return { @@ -15669,17 +15815,20 @@ function token(lexbuf) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int32" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int32" + }, + _2: curr(lexbuf) + } + }); } - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } case 17 : try { @@ -15691,17 +15840,20 @@ function token(lexbuf) { catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "int64" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "int64" + }, + _2: curr(lexbuf) + } + }); } - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } case 18 : try { @@ -15713,17 +15865,20 @@ function token(lexbuf) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID === Stdlib.Failure) { - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Literal_overflow */5, - _0: "nativeint" - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Literal_overflow */5, + _0: "nativeint" + }, + _2: curr(lexbuf) + } + }); } - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } case 19 : reset_string_buffer(undefined); @@ -15786,15 +15941,16 @@ function token(lexbuf) { case 26 : var l = Stdlib__Lexing.lexeme(lexbuf); var esc = Stdlib__String.sub(l, 1, l.length - 1 | 0); - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_escape */1, - _0: esc - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_escape */1, + _0: esc + }, + _2: curr(lexbuf) + } + }); case 27 : var match = with_comment_buffer(comment, lexbuf); return { @@ -16003,29 +16159,32 @@ function token(lexbuf) { return /* EOF */25; } if (if_then_else.contents === /* Dir_if_true */0) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); case 91 : - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Illegal_character */0, - _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) - }, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Illegal_character */0, + _0: Stdlib__Lexing.lexeme_char(lexbuf, 0) + }, + _2: curr(lexbuf) + } + }); default: Curry._1(lexbuf.refill_buff, lexbuf); ___ocaml_lex_state = __ocaml_lex_state$1; @@ -16074,12 +16233,13 @@ function string(lexbuf) { return string(lexbuf); case 7 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 8 : store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); return string(lexbuf); @@ -16120,15 +16280,16 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { comment_start_loc.contents = /* [] */0; return curr(lexbuf); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 992, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 992, + 16 + ] + } + }); case 2 : string_start_loc.contents = curr(lexbuf); store_string_char(/* '"' */34); @@ -16142,36 +16303,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$1 = exn._1; if (typeof match$1 === "number") { if (match$1) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var match$2 = comment_start_loc.contents; if (match$2) { var start = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start, - _1: exn._2 - }, - _2: match$2.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start, + _1: exn._2 + }, + _2: match$2.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1006, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1006, + 18 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } is_in_string.contents = false; store_string_char(/* '"' */34); @@ -16192,36 +16361,44 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { var match$3 = exn$1._1; if (typeof match$3 === "number") { if (match$3) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } var match$4 = comment_start_loc.contents; if (match$4) { var start$1 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_string_in_comment */3, - _0: start$1, - _1: exn$1._2 - }, - _2: match$4.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_string_in_comment */3, + _0: start$1, + _1: exn$1._2 + }, + _2: match$4.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1026, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1026, + 18 + ] + } + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } is_in_string.contents = false; store_string_char(/* '|' */124); @@ -16239,25 +16416,27 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { if (match$5) { var start$2 = Stdlib__List.hd(Stdlib__List.rev(comment_start_loc.contents)); comment_start_loc.contents = /* [] */0; - throw { - MEL_EXN_ID: $$Error$2, - _1: { - TAG: /* Unterminated_comment */2, - _0: start$2 - }, - _2: match$5.hd, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: { + TAG: /* Unterminated_comment */2, + _0: start$2 + }, + _2: match$5.hd + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "parsing/lexer.mll", - 1056, - 16 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "parsing/lexer.mll", + 1056, + 16 + ] + } + }); case 11 : update_loc(lexbuf, undefined, 1, false, 0); store_string(Stdlib__Lexing.lexeme(lexbuf)); @@ -16292,12 +16471,13 @@ function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { continue ; case 1 : is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + } + }); case 2 : var edelim = Stdlib__Lexing.lexeme(lexbuf); var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); @@ -16360,22 +16540,24 @@ function interpret_directive(lexbuf, cont, look_ahead) { switch (match) { case /* ELSE */23 : if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } break; case /* END */24 : if (if_then_else$1 >= 2) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } if_then_else.contents = /* Dir_out */2; return Curry._1(cont, lexbuf); @@ -16389,12 +16571,13 @@ function interpret_directive(lexbuf, cont, look_ahead) { while(true) { var token = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_if */2, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_if */2, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token, /* SHARP */84) && at_bol(lexbuf)) { var token$1 = token_with_comments(lexbuf); @@ -16409,12 +16592,13 @@ function interpret_directive(lexbuf, cont, look_ahead) { } } if (token$1 === 37) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -16430,12 +16614,13 @@ function interpret_directive(lexbuf, cont, look_ahead) { }; } } - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); default: return Curry._1(look_ahead, match); } @@ -16447,12 +16632,13 @@ function interpret_directive(lexbuf, cont, look_ahead) { return Curry._1(look_ahead, match); } if (if_then_else$1) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } @@ -16464,12 +16650,13 @@ function interpret_directive(lexbuf, cont, look_ahead) { var else_seen = _else_seen; var token$2 = token_with_comments(lexbuf); if (Caml_obj.caml_equal(token$2, /* EOF */25)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_else */3, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_else */3, + _2: curr(lexbuf) + } + }); } if (Caml_obj.caml_equal(token$2, /* SHARP */84) && at_bol(lexbuf)) { var token$3 = token_with_comments(lexbuf); @@ -16480,33 +16667,36 @@ function interpret_directive(lexbuf, cont, look_ahead) { return Curry._1(cont, lexbuf); } if (else_seen) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } _else_seen = true; continue ; } if (token$3 === 37) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } } if (else_seen && is_elif(token$3)) { - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unexpected_directive */6, - _2: curr(lexbuf), - Error: new Error() - }; + throw new Error($$Error$2, { + cause: { + MEL_EXN_ID: $$Error$2, + _1: /* Unexpected_directive */6, + _2: curr(lexbuf) + } + }); } continue ; } @@ -16765,7 +16955,9 @@ function skip_phrase(lexbuf) { if (tmp === /* Unterminated_string */0) { continue ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } else { switch (tmp.TAG | 0) { case /* Illegal_character */0 : @@ -16773,11 +16965,15 @@ function skip_phrase(lexbuf) { case /* Unterminated_string_in_comment */3 : continue ; default: - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } }; @@ -16805,26 +17001,40 @@ function wrap(parsing_fun, lexbuf) { if (err.MEL_EXN_ID === $$Error$2) { var tmp = err._1; if (typeof tmp === "number") { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (tmp.TAG === /* Illegal_character */0) { if (input_name.contents === "//toplevel//") { skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } else { if (err.MEL_EXN_ID === $$Error$1) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } if (err.MEL_EXN_ID !== Stdlib__Parsing.Parse_error && err.MEL_EXN_ID !== Escape_error) { - throw err; + throw new Error(err.MEL_EXN_ID, { + cause: err + }); } } @@ -16832,14 +17042,15 @@ function wrap(parsing_fun, lexbuf) { if (input_name.contents === "//toplevel//") { maybe_skip_phrase(lexbuf); } - throw { - MEL_EXN_ID: $$Error$1, - _1: { - TAG: /* Other */5, - _0: loc - }, - Error: new Error() - }; + throw new Error($$Error$1, { + cause: { + MEL_EXN_ID: $$Error$1, + _1: { + TAG: /* Other */5, + _0: loc + } + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/pq_test.js b/jscomp/test/dist/jscomp/test/pq_test.js index ddf19035d9..739150682e 100644 --- a/jscomp/test/dist/jscomp/test/pq_test.js +++ b/jscomp/test/dist/jscomp/test/pq_test.js @@ -63,10 +63,11 @@ function remove_top(param) { }; } } - throw { - MEL_EXN_ID: Queue_is_empty, - Error: new Error() - }; + throw new Error(Queue_is_empty, { + cause: { + MEL_EXN_ID: Queue_is_empty + } + }); } function extract(queue) { @@ -77,10 +78,11 @@ function extract(queue) { remove_top(queue) ]; } - throw { - MEL_EXN_ID: Queue_is_empty, - Error: new Error() - }; + throw new Error(Queue_is_empty, { + cause: { + MEL_EXN_ID: Queue_is_empty + } + }); } var PrioQueue = { diff --git a/jscomp/test/dist/jscomp/test/promise_catch_test.js b/jscomp/test/dist/jscomp/test/promise_catch_test.js index f7be50f658..8d527dbd72 100644 --- a/jscomp/test/dist/jscomp/test/promise_catch_test.js +++ b/jscomp/test/dist/jscomp/test/promise_catch_test.js @@ -42,15 +42,16 @@ function handler(e) { console.log("hi"); return Promise.resolve(0); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/promise_catch_test.ml", - 21, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/promise_catch_test.ml", + 21, + 9 + ] + } + }); } function myHandler(match) { @@ -85,15 +86,16 @@ catch (raw_e){ } if (exit === 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/promise_catch_test.ml", - 38, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/promise_catch_test.ml", + 38, + 9 + ] + } + }); } Mt.from_pair_suites("Promise_catch_test", suites.contents); diff --git a/jscomp/test/dist/jscomp/test/qcc.js b/jscomp/test/dist/jscomp/test/qcc.js index 76e77a020a..6c72d8b40f 100644 --- a/jscomp/test/dist/jscomp/test/qcc.js +++ b/jscomp/test/dist/jscomp/test/qcc.js @@ -42,15 +42,16 @@ function bufferize(f) { }), (function (x) { if (buf.contents !== undefined) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 17, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 17, + 4 + ] + } + }); } buf.contents = Caml_option.some(x); }) @@ -100,15 +101,16 @@ function addsym(s) { function symstr(n) { if (n >= syms.contents) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 40, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 40, + 4 + ] + } + }); } return Caml_array.get(symtab, n); } @@ -196,7 +198,9 @@ function next(param) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { c = undefined; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (c === undefined) { @@ -246,11 +250,12 @@ function next(param) { var ch = getq(undefined); var qt = Curry._1(getch, undefined); if (qt !== /* '\'' */39) { - throw { - MEL_EXN_ID: "Failure", - _1: "syntax error", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "syntax error" + } + }); } return { TAG: /* ILit */1, @@ -370,15 +375,16 @@ function get32(l) { function patch(rel, loc, n) { if (n >= 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 157, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 157, + 2 + ] + } + }); } if (loc === 0) { return ; @@ -964,11 +970,12 @@ function unary(stk) { 2 ]; } else { - throw { - MEL_EXN_ID: "Failure", - _1: "[cast] expected", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "[cast] expected" + } + }); } for(var _k = 1 ,_k_finish = match[1]; _k <= _k_finish; ++_k){ Curry._1(next$1, undefined); @@ -1015,11 +1022,12 @@ function unary(stk) { }, _1: "unknown operator %s" }), o); - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); } out(Stdlib__List.assoc(o, unops)); if (o === "!") { @@ -1038,15 +1046,16 @@ function unary(stk) { if (Stdlib__List.mem_assoc(i$1, stk)) { var l = Stdlib__List.assoc(i$1, stk); if (l <= -256) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 295, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 295, + 6 + ] + } + }); } out(4754245); out(l & 255); @@ -1251,11 +1260,12 @@ function decl(g, _n, _stk) { if (g) { var glo = Caml_array.get(globs, s$1); if (glo.va >= 0) { - throw { - MEL_EXN_ID: "Failure", - _1: "symbol defined twice", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "symbol defined twice" + } + }); } var va = (gpos.contents + 232 | 0) + 4194304 | 0; Caml_array.set(globs, s$1, { @@ -1287,11 +1297,12 @@ function decl(g, _n, _stk) { _n = n$p; continue ; } - throw { - MEL_EXN_ID: "Failure", - _1: "[var] expected in [decl]", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "[var] expected in [decl]" + } + }); }; } }(top)); @@ -1324,15 +1335,16 @@ function decl(g, _n, _stk) { Curry._1(unnext, t); if (!g && n !== 0) { if ((n << 3) >= 256) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 436, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 436, + 6 + ] + } + }); } out(4752364); out((n << 3)); @@ -1452,15 +1464,16 @@ function stmt(brk, stk) { var brkl = brk[0]; var n = align.contents - brk[1] | 0; if (n < 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 515, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 515, + 4 + ] + } + }); } if (n !== 0) { out(4752324); @@ -1525,11 +1538,12 @@ function top(_param) { var f$1 = f._0; var g = Caml_array.get(globs, f$1); if (g.va >= 0) { - throw { - MEL_EXN_ID: "Failure", - _1: "symbol defined twice", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "symbol defined twice" + } + }); } Caml_array.set(globs, f$1, { loc: g.loc, @@ -1546,18 +1560,20 @@ function top(_param) { if (i._0 === ")") { return stk; } - throw { - MEL_EXN_ID: "Failure", - _1: "[var] or ) expected", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "[var] or ) expected" + } + }); case /* ILit */1 : case /* SLit */2 : - throw { - MEL_EXN_ID: "Failure", - _1: "[var] or ) expected", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "[var] or ) expected" + } + }); case /* Sym */3 : var r = Stdlib__List.hd(regs); push(r); @@ -1642,11 +1658,12 @@ function top(_param) { _param = undefined; continue ; } - throw { - MEL_EXN_ID: "Failure", - _1: "[decl] or [fun] expected", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "[decl] or [fun] expected" + } + }); }; } @@ -1869,15 +1886,16 @@ function elfgen(outf) { elfphdr(1, 0, tend + off | 0, 2097152); elfphdr(2, dyn + off | 0, tend - dyn | 0, 8); if (opos.contents !== 232) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/qcc.ml", - 698, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/qcc.ml", + 698, + 2 + ] + } + }); } patch(false, 24, va(entry)); Stdlib.output_bytes(outf, Stdlib__Bytes.sub(obuf, 0, tend + off | 0)); diff --git a/jscomp/test/dist/jscomp/test/raw_hash_tbl_bench.js b/jscomp/test/dist/jscomp/test/raw_hash_tbl_bench.js index 3e676da498..2721de4ced 100644 --- a/jscomp/test/dist/jscomp/test/raw_hash_tbl_bench.js +++ b/jscomp/test/dist/jscomp/test/raw_hash_tbl_bench.js @@ -10,15 +10,16 @@ function bench(param) { } for(var i$1 = 0; i$1 <= 1000000; ++i$1){ if (!Stdlib__Hashtbl.mem(table, i$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/raw_hash_tbl_bench.ml", - 9, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/raw_hash_tbl_bench.ml", + 9, + 4 + ] + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/rbset.js b/jscomp/test/dist/jscomp/test/rbset.js index 366a76d1ff..db9c51e777 100644 --- a/jscomp/test/dist/jscomp/test/rbset.js +++ b/jscomp/test/dist/jscomp/test/rbset.js @@ -253,15 +253,16 @@ function unbalanced_left(param) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rbset.ml", - 57, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rbset.ml", + 57, + 9 + ] + } + }); } function unbalanced_right(param) { @@ -318,15 +319,16 @@ function unbalanced_right(param) { } } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rbset.ml", - 63, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rbset.ml", + 63, + 9 + ] + } + }); } function lbalance(x1, x2, x3) { @@ -553,15 +555,16 @@ function remove_min(param) { false ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rbset.ml", - 115, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rbset.ml", + 115, + 4 + ] + } + }); } var match$1 = remove_min(param._1); var y = match$1[1]; @@ -588,15 +591,16 @@ function remove_min(param) { match$2[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rbset.ml", - 115, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rbset.ml", + 115, + 4 + ] + } + }); } function remove_aux(x, n) { diff --git a/jscomp/test/dist/jscomp/test/re_or_res/reactDOMRe.js b/jscomp/test/dist/jscomp/test/re_or_res/reactDOMRe.js index f6430e5183..445a0ba249 100644 --- a/jscomp/test/dist/jscomp/test/re_or_res/reactDOMRe.js +++ b/jscomp/test/dist/jscomp/test/re_or_res/reactDOMRe.js @@ -70,11 +70,12 @@ function hydrateToElementWithClassName(reactElement, className) { function hydrateToElementWithId(reactElement, id) { var element = document.getElementById(id); if (element == null) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "ReactDOMRe.hydrateToElementWithId : no element of id " + (id + " found in the HTML."), - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "ReactDOMRe.hydrateToElementWithId : no element of id " + (id + " found in the HTML.") + } + }); } ReactDom.hydrate(reactElement, element); } diff --git a/jscomp/test/dist/jscomp/test/re_or_res/reactjs_ppx_custom.js b/jscomp/test/dist/jscomp/test/re_or_res/reactjs_ppx_custom.js index 433b2a5c41..99630400e6 100644 --- a/jscomp/test/dist/jscomp/test/re_or_res/reactjs_ppx_custom.js +++ b/jscomp/test/dist/jscomp/test/re_or_res/reactjs_ppx_custom.js @@ -4,15 +4,16 @@ var JsxRuntime = require("react/jsx-runtime"); function Reactjs_ppx_custom$Internal$header(Props) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/re_or_res/reactjs_ppx_custom.re", - 4, - 21 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/re_or_res/reactjs_ppx_custom.re", + 4, + 21 + ] + } + }); } var Internal = { diff --git a/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js b/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js index 6baf04f102..601c9dbbdf 100644 --- a/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js +++ b/jscomp/test/dist/jscomp/test/re_or_res/reasonReact.js @@ -49,11 +49,12 @@ function convertPropsIfTheyreFromJs(props, jsPropsToReason, debugName) { _0: jsPropsToReason(props) }; } - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "A JS component called the Reason component " + (debugName + " which didn't implement the JS->Reason React props conversion."), - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "A JS component called the Reason component " + (debugName + " which didn't implement the JS->Reason React props conversion.") + } + }); } function createClass(debugName) { diff --git a/jscomp/test/dist/jscomp/test/rec_module_test.js b/jscomp/test/dist/jscomp/test/rec_module_test.js index 8310807659..dc72ead1db 100644 --- a/jscomp/test/dist/jscomp/test/rec_module_test.js +++ b/jscomp/test/dist/jscomp/test/rec_module_test.js @@ -131,17 +131,19 @@ function bal(l, v, r) { if (lr) { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -161,17 +163,19 @@ function bal(l, v, r) { if (rl) { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add(x, t) { @@ -260,10 +264,11 @@ function min_elt(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -292,10 +297,11 @@ function max_elt(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -322,11 +328,12 @@ function remove_min_elt(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function concat(t1, t2) { @@ -808,10 +815,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -842,10 +850,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -907,10 +916,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1125,15 +1135,16 @@ function of_list(l) { match$4[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/set.ml", - 571, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/set.ml", + 571, + 18 + ] + } + }); }; return sub(Stdlib__List.length(l$1), l$1)[0]; } else { diff --git a/jscomp/test/dist/jscomp/test/rec_value_test.js b/jscomp/test/dist/jscomp/test/rec_value_test.js index cb439b2f99..7c94e5f60b 100644 --- a/jscomp/test/dist/jscomp/test/rec_value_test.js +++ b/jscomp/test/dist/jscomp/test/rec_value_test.js @@ -80,15 +80,16 @@ var h = { var v = { contents: (function (param) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 36, - 24 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 36, + 24 + ] + } + }); }) }; @@ -245,54 +246,58 @@ var rec_variant_a = { function phd(l) { if (typeof l === "string") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 107, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 107, + 9 + ] + } + }); } if (l.NAME === "Cons") { return l.VAL[0]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 107, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 107, + 9 + ] + } + }); } function ptl(l) { if (typeof l === "string") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 112, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 112, + 9 + ] + } + }); } if (l.NAME === "Cons") { return l.VAL[1]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 112, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 112, + 9 + ] + } + }); } var y00 = {}; @@ -354,26 +359,28 @@ var suites_1 = { if (match) { tmp = match.hd; } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 142, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 142, + 2 + ] + } + }); } } else { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 142, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 142, + 2 + ] + } + }); } return { TAG: /* Eq */0, @@ -509,15 +516,16 @@ var suites_1 = { _1: rec_variant_a }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 166, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 166, + 11 + ] + } + }); }) ], tl: { @@ -531,15 +539,16 @@ var suites_1 = { _1: rec_variant_b }; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/rec_value_test.ml", - 171, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/rec_value_test.ml", + 171, + 11 + ] + } + }); }) ], tl: /* [] */0 diff --git a/jscomp/test/dist/jscomp/test/recursive_module.js b/jscomp/test/dist/jscomp/test/recursive_module.js index e94a34c493..1e088d812b 100644 --- a/jscomp/test/dist/jscomp/test/recursive_module.js +++ b/jscomp/test/dist/jscomp/test/recursive_module.js @@ -116,7 +116,9 @@ catch (raw_exn){ if (exn.MEL_EXN_ID === Stdlib__Lazy.Undefined) { tmp = -1; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -196,7 +198,9 @@ catch (raw_exn$1){ if (exn$1.MEL_EXN_ID === Stdlib.Undefined_recursive_module) { tmp$1 = 4; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } diff --git a/jscomp/test/dist/jscomp/test/recursive_records_test.js b/jscomp/test/dist/jscomp/test/recursive_records_test.js index 7b2309a37b..4da10953f1 100644 --- a/jscomp/test/dist/jscomp/test/recursive_records_test.js +++ b/jscomp/test/dist/jscomp/test/recursive_records_test.js @@ -67,15 +67,16 @@ function tl_exn(x) { if (x) { return x.next; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/recursive_records_test.ml", - 52, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/recursive_records_test.ml", + 52, + 11 + ] + } + }); } eq("File \"jscomp/test/recursive_records_test.ml\", line 56, characters 6-13", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9); diff --git a/jscomp/test/dist/jscomp/test/return_check.js b/jscomp/test/dist/jscomp/test/return_check.js index 3c98621c43..1cdede5450 100644 --- a/jscomp/test/dist/jscomp/test/return_check.js +++ b/jscomp/test/dist/jscomp/test/return_check.js @@ -18,15 +18,16 @@ function f_undefined(xs, i) { if (k !== undefined) { return k; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/return_check.ml", - 30, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/return_check.ml", + 30, + 14 + ] + } + }); } function f_escaped_not(xs, i) { @@ -59,15 +60,16 @@ function f_null(xs, i) { if (k !== null) { return k; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/return_check.ml", - 58, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/return_check.ml", + 58, + 14 + ] + } + }); } function f_null_undefined(xs, i) { @@ -75,15 +77,16 @@ function f_null_undefined(xs, i) { if (!(k == null)) { return k; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/return_check.ml", - 67, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/return_check.ml", + 67, + 14 + ] + } + }); } exports.test = test; diff --git a/jscomp/test/dist/jscomp/test/scanf_io.js b/jscomp/test/dist/jscomp/test/scanf_io.js index 068292e3a2..71a532ff2d 100644 --- a/jscomp/test/dist/jscomp/test/scanf_io.js +++ b/jscomp/test/dist/jscomp/test/scanf_io.js @@ -123,11 +123,12 @@ function get_lines(fname) { }, _1: "in file %s, %s" }), fname, exn._1); - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); } if (exn.MEL_EXN_ID === Stdlib.End_of_file) { var s$1 = Curry._1(Stdlib__Printf.sprintf(/* Format */{ @@ -146,13 +147,16 @@ function get_lines(fname) { }, _1: "in file %s, unexpected end of file" }), fname); - throw { - MEL_EXN_ID: "Failure", - _1: s$1, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s$1 + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -190,7 +194,9 @@ function add_digest_ib(ob, ib) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/scanf_reference_error_regression_test.js b/jscomp/test/dist/jscomp/test/scanf_reference_error_regression_test.js index bf8d35bed0..3b2e459a34 100644 --- a/jscomp/test/dist/jscomp/test/scanf_reference_error_regression_test.js +++ b/jscomp/test/dist/jscomp/test/scanf_reference_error_regression_test.js @@ -78,11 +78,12 @@ function scan_rest(ib, accu) { }, _1: "scan_int_list" }); - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); } })); })); diff --git a/jscomp/test/dist/jscomp/test/set_gen.js b/jscomp/test/dist/jscomp/test/set_gen.js index 6c2933a162..9539c66fe1 100644 --- a/jscomp/test/dist/jscomp/test/set_gen.js +++ b/jscomp/test/dist/jscomp/test/set_gen.js @@ -43,10 +43,11 @@ function min_elt(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -60,10 +61,11 @@ function max_elt(_param) { _param = param._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -206,17 +208,19 @@ function check_height_and_diff(param) { var hl = check_height_and_diff(param._0); var hr = check_height_and_diff(param._2); if (h !== (max_int_2(hl, hr) + 1 | 0)) { - throw { - MEL_EXN_ID: Height_invariant_broken, - Error: new Error() - }; + throw new Error(Height_invariant_broken, { + cause: { + MEL_EXN_ID: Height_invariant_broken + } + }); } var diff = Stdlib.abs(hl - hr | 0); if (diff > 2) { - throw { - MEL_EXN_ID: Height_diff_borken, - Error: new Error() - }; + throw new Error(Height_diff_borken, { + cause: { + MEL_EXN_ID: Height_diff_borken + } + }); } return h; } @@ -250,25 +254,27 @@ function internal_bal(l, v, r) { if (lr) { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/set_gen.ml", - 235, - 19 - ], - Error: new Error() - }; - } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/set_gen.ml", - 225, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/set_gen.ml", + 235, + 19 + ] + } + }); + } + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/set_gen.ml", + 225, + 15 + ] + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -288,25 +294,27 @@ function internal_bal(l, v, r) { if (rl) { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/set_gen.ml", - 251, - 19 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/set_gen.ml", + 251, + 19 + ] + } + }); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/set_gen.ml", - 245, - 15 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/set_gen.ml", + 245, + 15 + ] + } + }); } function remove_min_elt(param) { @@ -318,11 +326,12 @@ function remove_min_elt(param) { return param._2; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function singleton(x) { @@ -522,15 +531,16 @@ function of_sorted_list(l) { match$4[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/set_gen.ml", - 361, - 14 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/set_gen.ml", + 361, + 14 + ] + } + }); }; return sub(Stdlib__List.length(l), l)[0]; } diff --git a/jscomp/test/dist/jscomp/test/sexp.js b/jscomp/test/dist/jscomp/test/sexp.js index 14a9c02ca7..8e8dd2d386 100644 --- a/jscomp/test/dist/jscomp/test/sexp.js +++ b/jscomp/test/dist/jscomp/test/sexp.js @@ -486,11 +486,12 @@ function get_exn(e) { if (e !== undefined) { return Caml_option.valFromOption(e); } - throw { - MEL_EXN_ID: "Failure", - _1: "CCSexp.Traverse.get_exn", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "CCSexp.Traverse.get_exn" + } + }); } var of_unit = { diff --git a/jscomp/test/dist/jscomp/test/sexpm.js b/jscomp/test/dist/jscomp/test/sexpm.js index 5ed1db55dc..01d59121e2 100644 --- a/jscomp/test/dist/jscomp/test/sexpm.js +++ b/jscomp/test/dist/jscomp/test/sexpm.js @@ -45,16 +45,18 @@ function _must_escape(s) { if (c !== 92) { exit = 1; } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else if (c >= 11) { if (c >= 32) { @@ -71,10 +73,11 @@ function _must_escape(s) { case 34 : case 40 : case 41 : - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } else { @@ -82,18 +85,20 @@ function _must_escape(s) { } } else { if (c >= 9) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } exit = 1; } if (exit === 1 && c > 127) { - throw { - MEL_EXN_ID: Stdlib.Exit, - Error: new Error() - }; + throw new Error(Stdlib.Exit, { + cause: { + MEL_EXN_ID: Stdlib.Exit + } + }); } } @@ -104,7 +109,9 @@ function _must_escape(s) { if (exn.MEL_EXN_ID === Stdlib.Exit) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -370,7 +377,9 @@ function to_file_seq(filename, seq) { catch (e){ Caml_io.caml_ml_flush(oc); Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); - throw e; + throw new Error(e.MEL_EXN_ID, { + cause: e + }); } } @@ -428,15 +437,16 @@ function _refill(t, k_succ, k_fail) { function _get(t) { if (t.i >= t.len) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 152, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 152, + 4 + ] + } + }); } var c = Caml_bytes.get(t.buf, t.i); t.i = t.i + 1 | 0; @@ -542,15 +552,16 @@ function expr_starting_with(c, k, t) { if (c >= 32) { switch (c) { case 32 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 183, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 183, + 27 + ] + } + }); case 34 : return quoted(k, t); case 33 : @@ -576,15 +587,16 @@ function expr_starting_with(c, k, t) { } } else if (c >= 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 183, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 183, + 27 + ] + } + }); } Stdlib__Buffer.add_char(t.atom, c); return atom(k, t); @@ -1040,15 +1052,16 @@ function MakeDecode(funarg) { }; var _get = function (t) { if (t.i >= t.len) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 152, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 152, + 4 + ] + } + }); } var c = Caml_bytes.get(t.buf, t.i); t.i = t.i + 1 | 0; @@ -1150,15 +1163,16 @@ function MakeDecode(funarg) { if (c >= 32) { switch (c) { case 32 : - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 183, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 183, + 27 + ] + } + }); case 34 : return quoted(k, t); case 33 : @@ -1184,15 +1198,16 @@ function MakeDecode(funarg) { } } else if (c >= 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/sexpm.ml", - 183, - 27 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/sexpm.ml", + 183, + 27 + ] + } + }); } Stdlib__Buffer.add_char(t.atom, c); return atom(k, t); diff --git a/jscomp/test/dist/jscomp/test/stack_comp_test.js b/jscomp/test/dist/jscomp/test/stack_comp_test.js index 4f0c56b6bb..323e186e34 100644 --- a/jscomp/test/dist/jscomp/test/stack_comp_test.js +++ b/jscomp/test/dist/jscomp/test/stack_comp_test.js @@ -72,7 +72,9 @@ function does_raise(f, s) { if (exn.MEL_EXN_ID === Stdlib__Stack.Empty) { return true; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js b/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js index a6408b79ef..2fc3c960f2 100644 --- a/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js +++ b/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js @@ -335,15 +335,16 @@ function uchar_map_of_spec(spec) { if ((uchar.contents - 1 | 0) === match[1]) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 69, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 69, + 4 + ] + } + }); }; Stdlib__List.iter(add_range, spec); return map; @@ -377,82 +378,89 @@ function test_utf(utf, utf_len, get_utf, set_utf, utf_is_valid) { var utf_len$1 = Curry._1(utf_len, u); var buf = Caml_bytes.caml_create_bytes(utf_len$1); if (Curry._3(set_utf, buf, 0, u) !== utf_len$1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 97, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 97, + 4 + ] + } + }); } if (!Caml_bytes.caml_bytes_equal(buf, Caml_array.get(utf, u))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 98, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 98, + 4 + ] + } + }); } if (!Caml_bytes.caml_bytes_equal(buf, Caml_array.get(utf, u))) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 99, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 99, + 4 + ] + } + }); } var dec = Curry._2(get_utf, buf, 0); if ((dec >>> 27) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 101, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 101, + 4 + ] + } + }); } if (((dec >>> 24) & 7) !== utf_len$1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 102, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 102, + 4 + ] + } + }); } if ((dec & 16777215) !== u) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 103, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 103, + 4 + ] + } + }); } if (!Curry._1(utf_is_valid, buf)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 104, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 104, + 4 + ] + } + }); } }; @@ -476,21 +484,24 @@ function raises(f) { if (exn.MEL_EXN_ID === Stdlib.Invalid_argument) { tmp = true; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } if (tmp) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 124, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 124, + 4 + ] + } + }); } raises(function (param) { @@ -520,39 +531,42 @@ raises(function (param) { var b = Stdlib__Bytes.make(1, /* '\171' */171); if (!(Stdlib__Bytes.set_utf_8_uchar(b, 0, Stdlib__Uchar.max) === 0 && Caml_bytes.get(b, 0) === /* '\171' */171)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 141, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 141, + 2 + ] + } + }); } if (!(Stdlib__Bytes.set_utf_16be_uchar(b, 0, Stdlib__Uchar.max) === 0 && Caml_bytes.get(b, 0) === /* '\171' */171)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 142, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 142, + 2 + ] + } + }); } if (!(Stdlib__Bytes.set_utf_16le_uchar(b, 0, Stdlib__Uchar.max) === 0 && Caml_bytes.get(b, 0) === /* '\171' */171)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 143, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 143, + 2 + ] + } + }); } var b$1 = [ @@ -565,15 +579,16 @@ Caml_bytes.set(b$1, 0, 195); Caml_bytes.set(b$1, 1, 0); if (Stdlib__Bytes.is_valid_utf_8(b$1)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 151, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 151, + 2 + ] + } + }); } var b$2 = Stdlib__Bytes.of_string("\xc0\xaf\xe0\x80\xbf\xf0\x81\x82A"); @@ -586,72 +601,78 @@ for(var i = 0 ,i_finish = b$2.length; i < i_finish; ++i){ var dec = Stdlib__Bytes.get_utf_8_uchar(b$2, i); if (ok(i)) { if ((dec >>> 27) === 1 !== true) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 166, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 166, + 6 + ] + } + }); } if (((dec >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 167, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 167, + 6 + ] + } + }); } if ((dec & 16777215) !== Stdlib__Uchar.of_int(65)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 168, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 168, + 6 + ] + } + }); } } else { if ((dec >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 162, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 162, + 6 + ] + } + }); } if (((dec >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 163, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 163, + 6 + ] + } + }); } if ((dec & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 164, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 164, + 6 + ] + } + }); } } @@ -667,72 +688,78 @@ for(var i$1 = 0 ,i_finish$1 = b$3.length; i$1 < i_finish$1; ++i$1){ var dec$1 = Stdlib__Bytes.get_utf_8_uchar(b$3, i$1); if (ok$1(i$1)) { if ((dec$1 >>> 27) === 1 !== true) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 179, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 179, + 6 + ] + } + }); } if (((dec$1 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 180, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 180, + 6 + ] + } + }); } if ((dec$1 & 16777215) !== Stdlib__Uchar.of_int(65)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 181, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 181, + 6 + ] + } + }); } } else { if ((dec$1 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 175, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 175, + 6 + ] + } + }); } if (((dec$1 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 176, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 176, + 6 + ] + } + }); } if ((dec$1 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 177, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 177, + 6 + ] + } + }); } } @@ -752,72 +779,78 @@ for(var i$2 = 0 ,i_finish$2 = b$4.length; i$2 < i_finish$2; ++i$2){ var dec$2 = Stdlib__Bytes.get_utf_8_uchar(b$4, i$2); if (ok$2(i$2)) { if ((dec$2 >>> 27) === 1 !== true) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 192, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 192, + 6 + ] + } + }); } if (((dec$2 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 193, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 193, + 6 + ] + } + }); } if ((dec$2 & 16777215) !== Caml_bytes.get(b$4, i$2)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 194, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 194, + 6 + ] + } + }); } } else { if ((dec$2 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 188, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 188, + 6 + ] + } + }); } if (((dec$2 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 189, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 189, + 6 + ] + } + }); } if ((dec$2 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 190, - 6 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 190, + 6 + ] + } + }); } } @@ -828,179 +861,193 @@ var b$5 = Stdlib__Bytes.of_string("\xe1\x80\xe2\xf0\x91\x92\xf1\xbfA"); var d0 = Stdlib__Bytes.get_utf_8_uchar(b$5, 0); if ((d0 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 199, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 199, + 2 + ] + } + }); } if (((d0 >>> 24) & 7) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 200, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 200, + 2 + ] + } + }); } if ((d0 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 201, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 201, + 2 + ] + } + }); } var d2 = Stdlib__Bytes.get_utf_8_uchar(b$5, 2); if ((d2 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 203, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 203, + 2 + ] + } + }); } if (((d2 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 204, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 204, + 2 + ] + } + }); } if ((d2 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 205, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 205, + 2 + ] + } + }); } var d3 = Stdlib__Bytes.get_utf_8_uchar(b$5, 3); if ((d3 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 207, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 207, + 2 + ] + } + }); } if (((d3 >>> 24) & 7) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 208, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 208, + 2 + ] + } + }); } if ((d3 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 209, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 209, + 2 + ] + } + }); } var d6 = Stdlib__Bytes.get_utf_8_uchar(b$5, 6); if ((d6 >>> 27) === 1 !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 211, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 211, + 2 + ] + } + }); } if (((d6 >>> 24) & 7) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 212, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 212, + 2 + ] + } + }); } if ((d6 & 16777215) !== Stdlib__Uchar.rep) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 213, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 213, + 2 + ] + } + }); } var d8 = Stdlib__Bytes.get_utf_8_uchar(b$5, 8); if (((d8 >>> 24) & 7) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 215, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 215, + 2 + ] + } + }); } if ((d8 & 16777215) !== Stdlib__Uchar.of_int(65)) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stdlib_bytes_utf8_test.ml", - 216, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stdlib_bytes_utf8_test.ml", + 216, + 2 + ] + } + }); } Stdlib__Printf.printf(/* Format */{ diff --git a/jscomp/test/dist/jscomp/test/string_set.js b/jscomp/test/dist/jscomp/test/string_set.js index e94cf4c2c3..eddfc00e59 100644 --- a/jscomp/test/dist/jscomp/test/string_set.js +++ b/jscomp/test/dist/jscomp/test/string_set.js @@ -229,10 +229,11 @@ function find(x, _tree) { _tree = c < 0 ? tree._0 : tree._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/string_test.js b/jscomp/test/dist/jscomp/test/string_test.js index d30bb42a9f..0062fed092 100644 --- a/jscomp/test/dist/jscomp/test/string_test.js +++ b/jscomp/test/dist/jscomp/test/string_test.js @@ -79,7 +79,9 @@ function rev_split_by_char(c, s) { tl: l }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }; return loop(0, /* [] */0); @@ -108,7 +110,9 @@ function xsplit(delim, s) { tl: l }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var l_0 = Stdlib__String.sub(s, i$p + 1 | 0, (i - i$p | 0) - 1 | 0); var l$1 = { diff --git a/jscomp/test/dist/jscomp/test/stringmatch_test.js b/jscomp/test/dist/jscomp/test/stringmatch_test.js index eeadaca02b..f918cc6cd1 100644 --- a/jscomp/test/dist/jscomp/test/stringmatch_test.js +++ b/jscomp/test/dist/jscomp/test/stringmatch_test.js @@ -11,39 +11,42 @@ function tst01(s) { } if (tst01("") !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 20, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 20, + 2 + ] + } + }); } if (tst01("\0\0\0\x03") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 21, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 21, + 2 + ] + } + }); } if (tst01("\0\0\0\0\0\0\0\x07") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 22, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 22, + 2 + ] + } + }); } function tst02(s) { @@ -52,26 +55,28 @@ function tst02(s) { if (len >= 0) { return 1; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 30, - 23 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 30, + 23 + ] + } + }); } if (len === 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 32, - 22 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 32, + 22 + ] + } + }); } if (s === "A") { return 2; @@ -81,63 +86,68 @@ function tst02(s) { } if (tst02("") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 37, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 37, + 2 + ] + } + }); } if (tst02("A") !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 38, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 38, + 2 + ] + } + }); } if (tst02("B") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 39, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 39, + 2 + ] + } + }); } if (tst02("\0\0\0\0\0\0\0\x07") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 40, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 40, + 2 + ] + } + }); } if (tst02("\0\0\0\x03") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 41, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 41, + 2 + ] + } + }); } function tst03(s) { @@ -196,579 +206,627 @@ function tst03(s) { } if (tst03("get_const") !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 123, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 123, + 2 + ] + } + }); } if (tst03("set_congt") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 124, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 124, + 2 + ] + } + }); } if (tst03("get_var") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 125, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 125, + 2 + ] + } + }); } if (tst03("gat_ver") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 126, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 126, + 2 + ] + } + }); } if (tst03("get_env") !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 127, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 127, + 2 + ] + } + }); } if (tst03("get_env") !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 128, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 128, + 2 + ] + } + }); } if (tst03("get_meth") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 129, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 129, + 2 + ] + } + }); } if (tst03("met_geth") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 130, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 130, + 2 + ] + } + }); } if (tst03("set_var") !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 131, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 131, + 2 + ] + } + }); } if (tst03("sev_tar") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 132, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 132, + 2 + ] + } + }); } if (tst03("app_const") !== 5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 133, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 133, + 2 + ] + } + }); } if (tst03("ppa_const") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 134, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 134, + 2 + ] + } + }); } if (tst03("app_var") !== 6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 135, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 135, + 2 + ] + } + }); } if (tst03("app_var") !== 6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 136, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 136, + 2 + ] + } + }); } if (tst03("app_env") !== 7) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 137, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 137, + 2 + ] + } + }); } if (tst03("epp_anv") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 138, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 138, + 2 + ] + } + }); } if (tst03("app_meth") !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 139, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 139, + 2 + ] + } + }); } if (tst03("atp_meph") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 140, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 140, + 2 + ] + } + }); } if (tst03("app_const_const") !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 141, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 141, + 2 + ] + } + }); } if (tst03("app_const_const") !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 142, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 142, + 2 + ] + } + }); } if (tst03("app_const_var") !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 143, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 143, + 2 + ] + } + }); } if (tst03("atp_consp_var") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 144, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 144, + 2 + ] + } + }); } if (tst03("app_const_env") !== 11) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 145, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 145, + 2 + ] + } + }); } if (tst03("app_constne_v") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 146, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 146, + 2 + ] + } + }); } if (tst03("app_const_meth") !== 12) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 147, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 147, + 2 + ] + } + }); } if (tst03("spp_conat_meth") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 148, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 148, + 2 + ] + } + }); } if (tst03("app_var_const") !== 13) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 149, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 149, + 2 + ] + } + }); } if (tst03("app_va_rconst") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 150, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 150, + 2 + ] + } + }); } if (tst03("app_env_const") !== 14) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 151, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 151, + 2 + ] + } + }); } if (tst03("app_env_const") !== 14) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 152, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 152, + 2 + ] + } + }); } if (tst03("app_meth_const") !== 15) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 153, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 153, + 2 + ] + } + }); } if (tst03("app_teth_consm") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 154, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 154, + 2 + ] + } + }); } if (tst03("meth_app_const") !== 16) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 155, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 155, + 2 + ] + } + }); } if (tst03("math_epp_const") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 156, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 156, + 2 + ] + } + }); } if (tst03("meth_app_var") !== 17) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 157, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 157, + 2 + ] + } + }); } if (tst03("meth_app_var") !== 17) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 158, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 158, + 2 + ] + } + }); } if (tst03("meth_app_env") !== 18) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 159, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 159, + 2 + ] + } + }); } if (tst03("eeth_app_mnv") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 160, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 160, + 2 + ] + } + }); } if (tst03("meth_app_meth") !== 19) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 161, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 161, + 2 + ] + } + }); } if (tst03("meth_apt_meph") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 162, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 162, + 2 + ] + } + }); } if (tst03("send_const") !== 20) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 163, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 163, + 2 + ] + } + }); } if (tst03("tend_conss") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 164, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 164, + 2 + ] + } + }); } if (tst03("send_var") !== 21) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 165, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 165, + 2 + ] + } + }); } if (tst03("serd_van") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 166, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 166, + 2 + ] + } + }); } if (tst03("send_env") !== 22) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 167, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 167, + 2 + ] + } + }); } if (tst03("sen_denv") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 168, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 168, + 2 + ] + } + }); } if (tst03("send_meth") !== 23) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 169, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 169, + 2 + ] + } + }); } if (tst03("tend_mesh") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 170, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 170, + 2 + ] + } + }); } function tst04(s) { @@ -803,231 +861,250 @@ function tst04(s) { } if (tst04("AAAAAAAA") !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 204, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 204, + 2 + ] + } + }); } if (tst04("AAAAAAAAAAAAAAAA") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 205, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 205, + 2 + ] + } + }); } if (tst04("AAAAAAAAAAAAAAAAAAAAAAAA") !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 206, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 206, + 2 + ] + } + }); } if (tst04("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 207, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 207, + 2 + ] + } + }); } if (tst04("BBBBBBBB") !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 208, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 208, + 2 + ] + } + }); } if (tst04("BBBBBBBBBBBBBBBB") !== 5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 209, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 209, + 2 + ] + } + }); } if (tst04("BBBBBBBBBBBBBBBBBBBBBBBB") !== 6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 210, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 210, + 2 + ] + } + }); } if (tst04("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB") !== 7) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 211, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 211, + 2 + ] + } + }); } if (tst04("CCCCCCCC") !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 212, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 212, + 2 + ] + } + }); } if (tst04("CCCCCCCCCCCCCCCC") !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 213, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 213, + 2 + ] + } + }); } if (tst04("CCCCCCCCCCCCCCCCCCCCCCCC") !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 214, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 214, + 2 + ] + } + }); } if (tst04("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC") !== 11) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 215, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 215, + 2 + ] + } + }); } if (tst04("") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 216, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 216, + 2 + ] + } + }); } if (tst04("DDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 217, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 217, + 2 + ] + } + }); } if (tst04("DDDDDDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 218, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 218, + 2 + ] + } + }); } if (tst04("AAADDDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 219, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 219, + 2 + ] + } + }); } if (tst04("AAAAAAADDDDDDDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 220, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 220, + 2 + ] + } + }); } if (tst04("AAAAAAADDDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 221, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 221, + 2 + ] + } + }); } if (tst04("AAAAAAAAAAAAAAADDDD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 222, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 222, + 2 + ] + } + }); } function tst05(s) { @@ -1064,267 +1141,289 @@ function tst05(s) { } if (tst05("AAA") !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 258, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 258, + 2 + ] + } + }); } if (tst05("AAAA") !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 259, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 259, + 2 + ] + } + }); } if (tst05("AAAAA") !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 260, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 260, + 2 + ] + } + }); } if (tst05("AAAAAA") !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 261, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 261, + 2 + ] + } + }); } if (tst05("AAAAAAA") !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 262, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 262, + 2 + ] + } + }); } if (tst05("AAAAAAAAAAAA") !== 5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 263, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 263, + 2 + ] + } + }); } if (tst05("AAAAAAAAAAAAAAAA") !== 6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 264, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 264, + 2 + ] + } + }); } if (tst05("AAAAAAAAAAAAAAAAAAAA") !== 7) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 265, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 265, + 2 + ] + } + }); } if (tst05("BBB") !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 266, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 266, + 2 + ] + } + }); } if (tst05("BBBB") !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 267, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 267, + 2 + ] + } + }); } if (tst05("BBBBB") !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 268, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 268, + 2 + ] + } + }); } if (tst05("BBBBBB") !== 11) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 269, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 269, + 2 + ] + } + }); } if (tst05("BBBBBBB") !== 12) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 270, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 270, + 2 + ] + } + }); } if (tst05("") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 271, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 271, + 2 + ] + } + }); } if (tst05("AAD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 272, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 272, + 2 + ] + } + }); } if (tst05("AAAD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 273, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 273, + 2 + ] + } + }); } if (tst05("AAAAAAD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 274, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 274, + 2 + ] + } + }); } if (tst05("AAAAAAAD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 275, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 275, + 2 + ] + } + }); } if (tst05("BBD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 276, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 276, + 2 + ] + } + }); } if (tst05("BBBD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 277, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 277, + 2 + ] + } + }); } if (tst05("BBBBBBD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 278, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 278, + 2 + ] + } + }); } if (tst05("BBBBBBBD") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 279, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 279, + 2 + ] + } + }); } var s00 = "and"; @@ -1887,2223 +1986,2408 @@ function tst06(s) { } if (tst06(s00) !== 0) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 565, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 565, + 2 + ] + } + }); } if (tst06(t00) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 566, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 566, + 2 + ] + } + }); } if (tst06(s01) !== 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 567, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 567, + 2 + ] + } + }); } if (tst06(t01) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 568, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 568, + 2 + ] + } + }); } if (tst06(s02) !== 2) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 569, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 569, + 2 + ] + } + }); } if (tst06(t02) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 570, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 570, + 2 + ] + } + }); } if (tst06(s03) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 571, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 571, + 2 + ] + } + }); } if (tst06(t03) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 572, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 572, + 2 + ] + } + }); } if (tst06(s04) !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 573, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 573, + 2 + ] + } + }); } if (tst06(t04) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 574, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 574, + 2 + ] + } + }); } if (tst06(s05) !== 5) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 575, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 575, + 2 + ] + } + }); } if (tst06(t05) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 576, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 576, + 2 + ] + } + }); } if (tst06(s06) !== 6) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 577, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 577, + 2 + ] + } + }); } if (tst06(t06) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 578, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 578, + 2 + ] + } + }); } if (tst06(s07) !== 7) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 579, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 579, + 2 + ] + } + }); } if (tst06(t07) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 580, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 580, + 2 + ] + } + }); } if (tst06(s08) !== 8) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 581, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 581, + 2 + ] + } + }); } if (tst06(t08) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 582, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 582, + 2 + ] + } + }); } if (tst06(s09) !== 9) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 583, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 583, + 2 + ] + } + }); } if (tst06(t09) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 584, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 584, + 2 + ] + } + }); } if (tst06(s10) !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 585, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 585, + 2 + ] + } + }); } if (tst06(t10) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 586, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 586, + 2 + ] + } + }); } if (tst06(s11) !== 11) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 587, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 587, + 2 + ] + } + }); } if (tst06(t11) !== 11) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 588, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 588, + 2 + ] + } + }); } if (tst06(s12) !== 12) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 589, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 589, + 2 + ] + } + }); } if (tst06(t12) !== 12) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 590, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 590, + 2 + ] + } + }); } if (tst06(s13) !== 13) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 591, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 591, + 2 + ] + } + }); } if (tst06(t13) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 592, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 592, + 2 + ] + } + }); } if (tst06(s14) !== 14) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 593, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 593, + 2 + ] + } + }); } if (tst06(t14) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 594, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 594, + 2 + ] + } + }); } if (tst06(s15) !== 15) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 595, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 595, + 2 + ] + } + }); } if (tst06(t15) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 596, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 596, + 2 + ] + } + }); } if (tst06(s16) !== 16) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 597, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 597, + 2 + ] + } + }); } if (tst06(t16) !== 16) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 598, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 598, + 2 + ] + } + }); } if (tst06(s17) !== 17) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 599, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 599, + 2 + ] + } + }); } if (tst06(t17) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 600, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 600, + 2 + ] + } + }); } if (tst06(s18) !== 18) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 601, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 601, + 2 + ] + } + }); } if (tst06(t18) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 602, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 602, + 2 + ] + } + }); } if (tst06(s19) !== 19) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 603, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 603, + 2 + ] + } + }); } if (tst06(t19) !== 19) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 604, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 604, + 2 + ] + } + }); } if (tst06(s20) !== 20) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 605, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 605, + 2 + ] + } + }); } if (tst06(t20) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 606, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 606, + 2 + ] + } + }); } if (tst06(s21) !== 21) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 607, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 607, + 2 + ] + } + }); } if (tst06(t21) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 608, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 608, + 2 + ] + } + }); } if (tst06(s22) !== 22) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 609, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 609, + 2 + ] + } + }); } if (tst06(t22) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 610, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 610, + 2 + ] + } + }); } if (tst06(s23) !== 23) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 611, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 611, + 2 + ] + } + }); } if (tst06(t23) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 612, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 612, + 2 + ] + } + }); } if (tst06(s24) !== 24) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 613, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 613, + 2 + ] + } + }); } if (tst06(t24) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 614, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 614, + 2 + ] + } + }); } if (tst06(s25) !== 25) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 615, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 615, + 2 + ] + } + }); } if (tst06(t25) !== 25) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 616, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 616, + 2 + ] + } + }); } if (tst06(s26) !== 26) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 617, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 617, + 2 + ] + } + }); } if (tst06(t26) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 618, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 618, + 2 + ] + } + }); } if (tst06(s27) !== 27) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 619, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 619, + 2 + ] + } + }); } if (tst06(t27) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 620, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 620, + 2 + ] + } + }); } if (tst06(s28) !== 28) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 621, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 621, + 2 + ] + } + }); } if (tst06(t28) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 622, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 622, + 2 + ] + } + }); } if (tst06(s29) !== 29) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 623, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 623, + 2 + ] + } + }); } if (tst06(t29) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 624, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 624, + 2 + ] + } + }); } if (tst06(s30) !== 30) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 625, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 625, + 2 + ] + } + }); } if (tst06(t30) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 626, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 626, + 2 + ] + } + }); } if (tst06(s31) !== 31) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 627, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 627, + 2 + ] + } + }); } if (tst06(t31) !== 31) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 628, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 628, + 2 + ] + } + }); } if (tst06(s32) !== 32) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 629, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 629, + 2 + ] + } + }); } if (tst06(t32) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 630, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 630, + 2 + ] + } + }); } if (tst06(s33) !== 33) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 631, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 631, + 2 + ] + } + }); } if (tst06(t33) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 632, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 632, + 2 + ] + } + }); } if (tst06(s34) !== 34) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 633, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 633, + 2 + ] + } + }); } if (tst06(t34) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 634, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 634, + 2 + ] + } + }); } if (tst06(s35) !== 35) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 635, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 635, + 2 + ] + } + }); } if (tst06(t35) !== 35) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 636, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 636, + 2 + ] + } + }); } if (tst06(s36) !== 36) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 637, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 637, + 2 + ] + } + }); } if (tst06(t36) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 638, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 638, + 2 + ] + } + }); } if (tst06(s37) !== 37) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 639, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 639, + 2 + ] + } + }); } if (tst06(t37) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 640, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 640, + 2 + ] + } + }); } if (tst06(s38) !== 38) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 641, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 641, + 2 + ] + } + }); } if (tst06(t38) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 642, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 642, + 2 + ] + } + }); } if (tst06(s39) !== 39) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 643, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 643, + 2 + ] + } + }); } if (tst06(t39) !== 39) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 644, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 644, + 2 + ] + } + }); } if (tst06(s40) !== 40) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 645, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 645, + 2 + ] + } + }); } if (tst06(t40) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 646, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 646, + 2 + ] + } + }); } if (tst06(s41) !== 41) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 647, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 647, + 2 + ] + } + }); } if (tst06(t41) !== 41) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 648, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 648, + 2 + ] + } + }); } if (tst06(s42) !== 42) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 649, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 649, + 2 + ] + } + }); } if (tst06(t42) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 650, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 650, + 2 + ] + } + }); } if (tst06(s43) !== 43) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 651, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 651, + 2 + ] + } + }); } if (tst06(t43) !== 43) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 652, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 652, + 2 + ] + } + }); } if (tst06(s44) !== 44) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 653, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 653, + 2 + ] + } + }); } if (tst06(t44) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 654, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 654, + 2 + ] + } + }); } if (tst06(s45) !== 45) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 655, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 655, + 2 + ] + } + }); } if (tst06(t45) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 656, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 656, + 2 + ] + } + }); } if (tst06(s46) !== 46) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 657, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 657, + 2 + ] + } + }); } if (tst06(t46) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 658, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 658, + 2 + ] + } + }); } if (tst06(s47) !== 47) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 659, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 659, + 2 + ] + } + }); } if (tst06(t47) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 660, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 660, + 2 + ] + } + }); } if (tst06(s48) !== 48) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 661, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 661, + 2 + ] + } + }); } if (tst06(t48) !== 48) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 662, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 662, + 2 + ] + } + }); } if (tst06(s49) !== 49) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 663, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 663, + 2 + ] + } + }); } if (tst06(t49) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 664, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 664, + 2 + ] + } + }); } if (tst06(s50) !== 50) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 665, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 665, + 2 + ] + } + }); } if (tst06(t50) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 666, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 666, + 2 + ] + } + }); } if (tst06(s51) !== 51) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 667, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 667, + 2 + ] + } + }); } if (tst06(t51) !== 51) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 668, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 668, + 2 + ] + } + }); } if (tst06(s52) !== 52) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 669, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 669, + 2 + ] + } + }); } if (tst06(t52) !== 52) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 670, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 670, + 2 + ] + } + }); } if (tst06(s53) !== 53) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 671, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 671, + 2 + ] + } + }); } if (tst06(t53) !== 53) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 672, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 672, + 2 + ] + } + }); } if (tst06(s54) !== 54) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 673, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 673, + 2 + ] + } + }); } if (tst06(t54) !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 674, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 674, + 2 + ] + } + }); } if (tst06(s55) !== 55) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 675, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 675, + 2 + ] + } + }); } if (tst06(t55) !== 55) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 676, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 676, + 2 + ] + } + }); } if (tst06(s56) !== 56) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 677, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 677, + 2 + ] + } + }); } if (tst06(t56) !== 56) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 678, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 678, + 2 + ] + } + }); } if (tst06(s57) !== 57) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 679, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 679, + 2 + ] + } + }); } if (tst06(t57) !== 57) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 680, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 680, + 2 + ] + } + }); } if (tst06(s58) !== 58) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 681, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 681, + 2 + ] + } + }); } if (tst06(t58) !== 58) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 682, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 682, + 2 + ] + } + }); } if (tst06(s59) !== 59) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 683, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 683, + 2 + ] + } + }); } if (tst06(t59) !== 59) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 684, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 684, + 2 + ] + } + }); } if (tst06(s60) !== 60) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 685, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 685, + 2 + ] + } + }); } if (tst06(t60) !== 60) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 686, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 686, + 2 + ] + } + }); } if (tst06(s61) !== 61) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 687, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 687, + 2 + ] + } + }); } if (tst06(t61) !== 61) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 688, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 688, + 2 + ] + } + }); } if (tst06(s62) !== 62) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 689, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 689, + 2 + ] + } + }); } if (tst06(t62) !== 62) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 690, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 690, + 2 + ] + } + }); } if (tst06(s63) !== 63) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 691, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 691, + 2 + ] + } + }); } if (tst06(t63) !== 63) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 692, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 692, + 2 + ] + } + }); } if (tst06(s64) !== 64) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 693, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 693, + 2 + ] + } + }); } if (tst06(t64) !== 64) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 694, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 694, + 2 + ] + } + }); } if (tst06(s65) !== 65) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 695, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 695, + 2 + ] + } + }); } if (tst06(t65) !== 65) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 696, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 696, + 2 + ] + } + }); } if (tst06(s66) !== 66) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 697, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 697, + 2 + ] + } + }); } if (tst06(t66) !== 66) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 698, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 698, + 2 + ] + } + }); } if (tst06(s67) !== 67) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 699, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 699, + 2 + ] + } + }); } if (tst06(t67) !== 67) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 700, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 700, + 2 + ] + } + }); } if (tst06(s68) !== 68) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 701, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 701, + 2 + ] + } + }); } if (tst06(t68) !== 68) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 702, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 702, + 2 + ] + } + }); } if (tst06(s69) !== 69) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 703, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 703, + 2 + ] + } + }); } if (tst06(t69) !== 69) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 704, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 704, + 2 + ] + } + }); } if (tst06(s70) !== 70) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 705, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 705, + 2 + ] + } + }); } if (tst06(t70) !== 70) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 706, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 706, + 2 + ] + } + }); } if (tst06(s71) !== 71) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 707, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 707, + 2 + ] + } + }); } if (tst06(t71) !== 71) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 708, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 708, + 2 + ] + } + }); } if (tst06(s72) !== 72) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 709, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 709, + 2 + ] + } + }); } if (tst06(t72) !== 72) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 710, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 710, + 2 + ] + } + }); } if (tst06(s73) !== 73) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 711, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 711, + 2 + ] + } + }); } if (tst06(t73) !== 73) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 712, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 712, + 2 + ] + } + }); } if (tst06(s74) !== 74) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 713, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 713, + 2 + ] + } + }); } if (tst06(t74) !== 74) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 714, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 714, + 2 + ] + } + }); } if (tst06(s75) !== 75) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 715, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 715, + 2 + ] + } + }); } if (tst06(t75) !== 75) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 716, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 716, + 2 + ] + } + }); } if (tst06(s76) !== 76) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 717, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 717, + 2 + ] + } + }); } if (tst06(t76) !== 76) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 718, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 718, + 2 + ] + } + }); } if (tst06(s77) !== 77) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 719, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 719, + 2 + ] + } + }); } if (tst06(t77) !== 77) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 720, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 720, + 2 + ] + } + }); } if (tst06(s78) !== 78) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 721, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 721, + 2 + ] + } + }); } if (tst06(t78) !== 78) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 722, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 722, + 2 + ] + } + }); } if (tst06(s79) !== 79) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 723, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 723, + 2 + ] + } + }); } if (tst06(t79) !== 79) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 724, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 724, + 2 + ] + } + }); } if (tst06(s80) !== 80) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 725, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 725, + 2 + ] + } + }); } if (tst06(t80) !== 80) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 726, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 726, + 2 + ] + } + }); } if (tst06(s81) !== 81) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 727, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 727, + 2 + ] + } + }); } if (tst06(t81) !== 81) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 728, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 728, + 2 + ] + } + }); } if (tst06(s82) !== 82) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 729, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 729, + 2 + ] + } + }); } if (tst06(t82) !== 82) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 730, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 730, + 2 + ] + } + }); } if (tst06(s83) !== 83) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 731, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 731, + 2 + ] + } + }); } if (tst06(t83) !== 83) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 732, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 732, + 2 + ] + } + }); } if (tst06(s84) !== 84) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 733, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 733, + 2 + ] + } + }); } if (tst06(t84) !== 84) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 734, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 734, + 2 + ] + } + }); } if (tst06(s85) !== 85) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 735, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 735, + 2 + ] + } + }); } if (tst06(t85) !== 85) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 736, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 736, + 2 + ] + } + }); } if (tst06(s86) !== 86) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 737, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 737, + 2 + ] + } + }); } if (tst06(t86) !== 86) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 738, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 738, + 2 + ] + } + }); } if (tst06(s87) !== 87) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 739, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 739, + 2 + ] + } + }); } if (tst06(t87) !== 87) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 740, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 740, + 2 + ] + } + }); } if (tst06(s88) !== 88) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 741, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 741, + 2 + ] + } + }); } if (tst06(t88) !== 88) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 742, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 742, + 2 + ] + } + }); } if (tst06(s89) !== 89) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 743, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 743, + 2 + ] + } + }); } if (tst06(t89) !== 89) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 744, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 744, + 2 + ] + } + }); } if (tst06(s90) !== 90) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 745, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 745, + 2 + ] + } + }); } if (tst06(t90) !== 90) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 746, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 746, + 2 + ] + } + }); } if (tst06(s91) !== 91) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 747, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 747, + 2 + ] + } + }); } if (tst06(t91) !== 91) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 748, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 748, + 2 + ] + } + }); } if (tst06("") !== -1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/stringmatch_test.ml", - 749, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/stringmatch_test.ml", + 749, + 2 + ] + } + }); } exports.tst01 = tst01; diff --git a/jscomp/test/dist/jscomp/test/test_array_primitive.js b/jscomp/test/dist/jscomp/test/test_array_primitive.js index b99f8a3f98..8fa84f6ad7 100644 --- a/jscomp/test/dist/jscomp/test/test_array_primitive.js +++ b/jscomp/test/dist/jscomp/test/test_array_primitive.js @@ -13,22 +13,24 @@ function caml_array_sub(x, offset, len) { function caml_array_set(xs, index, newval) { if (index < 0 || index >= xs.length) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "index out of bounds", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); } Caml_array.set(xs, index, newval); } function caml_array_get(xs, index) { if (index < 0 || index >= xs.length) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "index out of bounds", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "index out of bounds" + } + }); } return Caml_array.get(xs, index); } diff --git a/jscomp/test/dist/jscomp/test/test_bool_equal.js b/jscomp/test/dist/jscomp/test/test_bool_equal.js index 9339a09c12..5109459de8 100644 --- a/jscomp/test/dist/jscomp/test/test_bool_equal.js +++ b/jscomp/test/dist/jscomp/test/test_bool_equal.js @@ -19,50 +19,54 @@ function bool_equal(x, y) { function assertions(param) { if (true !== true) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_bool_equal.ml", - 25, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_bool_equal.ml", + 25, + 2 + ] + } + }); } if (false !== false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_bool_equal.ml", - 26, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_bool_equal.ml", + 26, + 2 + ] + } + }); } if (true === false) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_bool_equal.ml", - 27, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_bool_equal.ml", + 27, + 2 + ] + } + }); } if (false !== true) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_bool_equal.ml", - 28, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_bool_equal.ml", + 28, + 2 + ] + } + }); } function f0(x) { diff --git a/jscomp/test/dist/jscomp/test/test_closure.js b/jscomp/test/dist/jscomp/test/test_closure.js index e23268002d..63b726f89b 100644 --- a/jscomp/test/dist/jscomp/test/test_closure.js +++ b/jscomp/test/dist/jscomp/test/test_closure.js @@ -30,15 +30,16 @@ Stdlib__Array.iter((function (x) { }), u); if (v.contents !== 45) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_closure.ml", - 53, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_closure.ml", + 53, + 2 + ] + } + }); } exports.v = v; diff --git a/jscomp/test/dist/jscomp/test/test_exception.js b/jscomp/test/dist/jscomp/test/test_exception.js index 2afd20fa27..fa701db18c 100644 --- a/jscomp/test/dist/jscomp/test/test_exception.js +++ b/jscomp/test/dist/jscomp/test/test_exception.js @@ -8,41 +8,46 @@ var Test_common = require("./test_common.js"); var Local = /* @__PURE__ */Caml_exceptions.create("Test_exception.Local"); function f(param) { - throw { - MEL_EXN_ID: Local, - _1: 3, - Error: new Error() - }; + throw new Error(Local, { + cause: { + MEL_EXN_ID: Local, + _1: 3 + } + }); } function g(param) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function h(param) { - throw { - MEL_EXN_ID: Test_common.U, - _1: 3, - Error: new Error() - }; + throw new Error(Test_common.U, { + cause: { + MEL_EXN_ID: Test_common.U, + _1: 3 + } + }); } function x(param) { - throw { - MEL_EXN_ID: Test_common.H, - Error: new Error() - }; + throw new Error(Test_common.H, { + cause: { + MEL_EXN_ID: Test_common.H + } + }); } function xx(param) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "x", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "x" + } + }); } var Nullary = /* @__PURE__ */Caml_exceptions.create("Test_exception.Nullary"); diff --git a/jscomp/test/dist/jscomp/test/test_exception_escape.js b/jscomp/test/dist/jscomp/test/test_exception_escape.js index 57a49d4d4f..9ec824165e 100644 --- a/jscomp/test/dist/jscomp/test/test_exception_escape.js +++ b/jscomp/test/dist/jscomp/test/test_exception_escape.js @@ -8,11 +8,12 @@ var A = /* @__PURE__ */Caml_exceptions.create("Test_exception_escape.N.A"); var f; try { - throw { - MEL_EXN_ID: A, - _1: 3, - Error: new Error() - }; + throw new Error(A, { + cause: { + MEL_EXN_ID: A, + _1: 3 + } + }); } catch (exn){ f = 3; diff --git a/jscomp/test/dist/jscomp/test/test_for_map.js b/jscomp/test/dist/jscomp/test/test_for_map.js index 71a5fdd704..12a203b9fb 100644 --- a/jscomp/test/dist/jscomp/test/test_for_map.js +++ b/jscomp/test/dist/jscomp/test/test_for_map.js @@ -59,17 +59,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -91,17 +93,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -167,10 +171,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -207,10 +212,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -284,10 +290,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -372,10 +379,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -410,10 +418,11 @@ function max_binding(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -443,11 +452,12 @@ function remove_min_binding(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge(t1, t2) { @@ -758,15 +768,16 @@ function merge$1(f, s1, s2) { var match$1 = split(v2, s1); return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union(f, s1, s2) { diff --git a/jscomp/test/dist/jscomp/test/test_incomplete.js b/jscomp/test/dist/jscomp/test/test_incomplete.js index dff907b33b..78e0bdf73a 100644 --- a/jscomp/test/dist/jscomp/test/test_incomplete.js +++ b/jscomp/test/dist/jscomp/test/test_incomplete.js @@ -6,15 +6,16 @@ function f(x) { if (!(x > 3 || x < 1)) { return /* 'a' */97; } - throw { - MEL_EXN_ID: "Match_failure", - _1: [ - "test_incomplete.ml", - 3, - 2 - ], - Error: new Error() - }; + throw new Error("Match_failure", { + cause: { + MEL_EXN_ID: "Match_failure", + _1: [ + "test_incomplete.ml", + 3, + 2 + ] + } + }); } function f2(x) { diff --git a/jscomp/test/dist/jscomp/test/test_int_map_find.js b/jscomp/test/dist/jscomp/test/test_int_map_find.js index ab9a603dff..3b1e89611c 100644 --- a/jscomp/test/dist/jscomp/test/test_int_map_find.js +++ b/jscomp/test/dist/jscomp/test/test_int_map_find.js @@ -46,17 +46,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -78,17 +80,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { diff --git a/jscomp/test/dist/jscomp/test/test_internalOO.js b/jscomp/test/dist/jscomp/test/test_internalOO.js index 8579dbf5b0..f70d997b83 100644 --- a/jscomp/test/dist/jscomp/test/test_internalOO.js +++ b/jscomp/test/dist/jscomp/test/test_internalOO.js @@ -94,17 +94,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -126,17 +128,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -202,10 +206,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -242,10 +247,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -319,10 +325,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -407,10 +414,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -445,10 +453,11 @@ function max_binding(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -478,11 +487,12 @@ function remove_min_binding(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge(t1, t2) { @@ -793,15 +803,16 @@ function merge$1(f, s1, s2) { var match$1 = split(v2, s1); return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union(f, s1, s2) { @@ -1227,17 +1238,19 @@ function bal$1(l, x, d, r) { if (lr) { return create$1(create$1(ll, lv, ld, lr.l), lr.v, lr.d, create$1(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -1259,17 +1272,19 @@ function bal$1(l, x, d, r) { if (rl) { return create$1(create$1(l, x, d, rl.l), rl.v, rl.d, create$1(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty$1(param) { @@ -1335,10 +1350,11 @@ function find$1(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1375,10 +1391,11 @@ function find_first$1(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1452,10 +1469,11 @@ function find_last$1(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1540,10 +1558,11 @@ function min_binding$1(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1578,10 +1597,11 @@ function max_binding$1(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1611,11 +1631,12 @@ function remove_min_binding$1(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge$2(t1, t2) { @@ -1926,15 +1947,16 @@ function merge$3(f, s1, s2) { var match$1 = split$1(v2, s1); return concat_or_join$1(merge$3(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$3(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union$1(f, s1, s2) { @@ -2360,17 +2382,19 @@ function bal$2(l, x, d, r) { if (lr) { return create$2(create$2(ll, lv, ld, lr.l), lr.v, lr.d, create$2(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -2392,17 +2416,19 @@ function bal$2(l, x, d, r) { if (rl) { return create$2(create$2(l, x, d, rl.l), rl.v, rl.d, create$2(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty$2(param) { @@ -2468,10 +2494,11 @@ function find$2(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2508,10 +2535,11 @@ function find_first$2(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2585,10 +2613,11 @@ function find_last$2(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2673,10 +2702,11 @@ function min_binding$2(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2711,10 +2741,11 @@ function max_binding$2(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -2744,11 +2775,12 @@ function remove_min_binding$2(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge$4(t1, t2) { @@ -3059,15 +3091,16 @@ function merge$5(f, s1, s2) { var match$1 = split$2(v2, s1); return concat_or_join$2(merge$5(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$5(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union$2(f, s1, s2) { @@ -3527,7 +3560,9 @@ function get_method_label(table, name) { table.methods_by_label = Curry._3(add$2, label, true, table.methods_by_label); return label; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -3562,7 +3597,9 @@ function get_method(table, label) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return Caml_array.get(table.methods, label); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -3619,7 +3656,9 @@ function narrow(table, vars, virt_meths, concr_meths) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { tmp = true; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } by_label.contents = Curry._3(add$2, label, tmp, by_label.contents); @@ -3682,7 +3721,9 @@ function new_variable(table, name) { } return index; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -3715,17 +3756,20 @@ function get_variable(table, name) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID === Stdlib.Not_found) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_internalOO.ml", - 280, - 50 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_internalOO.ml", + 280, + 50 + ] + } + }); } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -3805,11 +3849,12 @@ function make_class_store(pub_meths, class_init, init_table) { function dummy_class(loc) { var undef = function (param) { - throw { - MEL_EXN_ID: Stdlib.Undefined_recursive_module, - _1: loc, - Error: new Error() - }; + throw new Error(Stdlib.Undefined_recursive_module, { + cause: { + MEL_EXN_ID: Stdlib.Undefined_recursive_module, + _1: loc + } + }); }; return [ undef, diff --git a/jscomp/test/dist/jscomp/test/test_list.js b/jscomp/test/dist/jscomp/test/test_list.js index a63038bb38..e33ae0bed7 100644 --- a/jscomp/test/dist/jscomp/test/test_list.js +++ b/jscomp/test/dist/jscomp/test/test_list.js @@ -27,31 +27,34 @@ function hd(param) { if (param) { return param.hd; } - throw { - MEL_EXN_ID: "Failure", - _1: "hd", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "hd" + } + }); } function tl(param) { if (param) { return param.tl; } - throw { - MEL_EXN_ID: "Failure", - _1: "tl", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "tl" + } + }); } function nth(l, n) { if (n < 0) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.nth", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.nth" + } + }); } var _l = l; var _n = n; @@ -66,11 +69,12 @@ function nth(l, n) { _l = l$1.tl; continue ; } - throw { - MEL_EXN_ID: "Failure", - _1: "nth", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "nth" + } + }); }; } @@ -204,20 +208,22 @@ function map2(f, l1, l2) { tl: map2(f, l1.tl, l2.tl) }; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.map2" + } + }); } if (!l2) { return /* [] */0; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.map2" + } + }); } function rev_map2(f, l1, l2) { @@ -238,18 +244,20 @@ function rev_map2(f, l1, l2) { }; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.rev_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } if (l2$1) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.rev_map2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.rev_map2" + } + }); } return accu; }; @@ -266,20 +274,22 @@ function iter2(f, _l1, _l2) { _l1 = l1.tl; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.iter2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.iter2" + } + }); } if (!l2) { return ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.iter2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.iter2" + } + }); }; } @@ -295,18 +305,20 @@ function fold_left2(f, _accu, _l1, _l2) { _accu = Curry._3(f, accu, l1.hd, l2.hd); continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_left2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } if (l2) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_left2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_left2" + } + }); } return accu; }; @@ -317,18 +329,20 @@ function fold_right2(f, l1, l2, accu) { if (l2) { return Curry._3(f, l1.hd, l2.hd, fold_right2(f, l1.tl, l2.tl, accu)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } if (l2) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.fold_right2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.fold_right2" + } + }); } return accu; } @@ -374,20 +388,22 @@ function for_all2(p, _l1, _l2) { _l1 = l1.tl; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.for_all2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.for_all2" + } + }); } if (!l2) { return true; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.for_all2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.for_all2" + } + }); }; } @@ -404,20 +420,22 @@ function exists2(p, _l1, _l2) { _l1 = l1.tl; continue ; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.exists2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.exists2" + } + }); } if (!l2) { return false; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.exists2", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.exists2" + } + }); }; } @@ -460,10 +478,11 @@ function assoc(x, _param) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -478,10 +497,11 @@ function assq(x, _param) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -556,10 +576,11 @@ function find(p, _param) { _param = param.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -654,20 +675,22 @@ function combine(l1, l2) { tl: combine(l1.tl, l2.tl) }; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.combine", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.combine" + } + }); } if (!l2) { return /* [] */0; } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "List.combine", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "List.combine" + } + }); } function merge(cmp, l1, l2) { @@ -704,15 +727,16 @@ function chop(_k, _l) { _k = k - 1 | 0; continue ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_list.ml", - 224, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_list.ml", + 224, + 11 + ] + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/test_match_exception.js b/jscomp/test/dist/jscomp/test/test_match_exception.js index 3dbe373011..f67774141c 100644 --- a/jscomp/test/dist/jscomp/test/test_match_exception.js +++ b/jscomp/test/dist/jscomp/test/test_match_exception.js @@ -14,7 +14,9 @@ function f(g, x) { if (exn.MEL_EXN_ID === Stdlib.Not_found) { return 3; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/test_per.js b/jscomp/test/dist/jscomp/test/test_per.js index 785b03627f..33cff5a097 100644 --- a/jscomp/test/dist/jscomp/test/test_per.js +++ b/jscomp/test/dist/jscomp/test/test_per.js @@ -15,19 +15,21 @@ var Curry = require("melange.js/curry.js"); var Stdlib = require("melange/stdlib.js"); function failwith(s) { - throw { - MEL_EXN_ID: Stdlib.Failure, - _1: s, - Error: new Error() - }; + throw new Error(Stdlib.Failure, { + cause: { + MEL_EXN_ID: Stdlib.Failure, + _1: s + } + }); } function invalid_arg(s) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: s, - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: s + } + }); } var Exit = /* @__PURE__ */Caml_exceptions.create("Test_per.Exit"); @@ -103,11 +105,12 @@ function $caret(s1, s2) { function char_of_int(n) { if (n < 0 || n > 255) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "char_of_int", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "char_of_int" + } + }); } return n; } @@ -127,11 +130,12 @@ function bool_of_string(param) { case "true" : return true; default: - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "bool_of_string", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "bool_of_string" + } + }); } } @@ -248,22 +252,24 @@ function output_string(oc, s) { function output(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "output", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "output" + } + }); } Caml_io.caml_ml_output(oc, s, ofs, len); } function output_substring(oc, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "output_substring", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "output_substring" + } + }); } Caml_io.caml_ml_output(oc, s, ofs, len); } @@ -318,11 +324,12 @@ function open_in_bin(name) { function input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "input", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "input" + } + }); } return Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); } @@ -336,10 +343,11 @@ function unsafe_really_input(ic, s, _ofs, _len) { } var r = Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); if (r === 0) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); } _len = len - r | 0; _ofs = ofs + r | 0; @@ -349,11 +357,12 @@ function unsafe_really_input(ic, s, _ofs, _len) { function really_input(ic, s, ofs, len) { if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw { - MEL_EXN_ID: Stdlib.Invalid_argument, - _1: "really_input", - Error: new Error() - }; + throw new Error(Stdlib.Invalid_argument, { + cause: { + MEL_EXN_ID: Stdlib.Invalid_argument, + _1: "really_input" + } + }); } unsafe_really_input(ic, s, ofs, len); } @@ -390,10 +399,11 @@ function input_line(chan) { if (accu) { return build_result(Caml_bytes.caml_create_bytes(len), len, accu); } - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); } if (n > 0) { var res = Caml_bytes.caml_create_bytes(n - 1 | 0); diff --git a/jscomp/test/dist/jscomp/test/test_seq.js b/jscomp/test/dist/jscomp/test/test_seq.js index 307c8b7a6b..2beacfadc2 100644 --- a/jscomp/test/dist/jscomp/test/test_seq.js +++ b/jscomp/test/dist/jscomp/test/test_seq.js @@ -24,22 +24,24 @@ function assoc3(x, _l) { _l = l.tl; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } function help_action(param) { - throw { - MEL_EXN_ID: Stop, - _1: { - TAG: /* Unknown */0, - _0: "-help" - }, - Error: new Error() - }; + throw new Error(Stop, { + cause: { + MEL_EXN_ID: Stop, + _1: { + TAG: /* Unknown */0, + _0: "-help" + } + } + }); } function v(speclist) { @@ -72,7 +74,9 @@ function add_help(speclist) { tl: /* [] */0 }; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } var add2; @@ -95,7 +99,9 @@ function add_help(speclist) { tl: /* [] */0 }; } else { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } return Stdlib.$at(speclist, Stdlib.$at(add1, add2)); diff --git a/jscomp/test/dist/jscomp/test/test_set.js b/jscomp/test/dist/jscomp/test/test_set.js index 7914c9a38f..8dd176fa99 100644 --- a/jscomp/test/dist/jscomp/test/test_set.js +++ b/jscomp/test/dist/jscomp/test/test_set.js @@ -37,17 +37,19 @@ function Make(Ord) { if (lr) { return create(create(ll, lv, lr._0), lr._1, create(lr._2, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; - } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); + } + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -67,17 +69,19 @@ function Make(Ord) { if (rl) { return create(create(l, v, rl._0), rl._1, create(rl._2, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); }; var add = function (x, t) { if (!t) { @@ -150,10 +154,11 @@ function Make(Ord) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var max_elt = function (_param) { @@ -166,10 +171,11 @@ function Make(Ord) { _param = param._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var remove_min_elt = function (param) { @@ -181,11 +187,12 @@ function Make(Ord) { return param._2; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); }; var merge = function (t1, t2) { if (t1) { @@ -567,10 +574,11 @@ function Make(Ord) { _param = c < 0 ? param._0 : param._2; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; }; var of_sorted_list = function (l) { @@ -660,15 +668,16 @@ function Make(Ord) { match$4[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_set.ml", - 372, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_set.ml", + 372, + 18 + ] + } + }); }; return sub(Stdlib__List.length(l), l)[0]; }; diff --git a/jscomp/test/dist/jscomp/test/test_simple_obj.js b/jscomp/test/dist/jscomp/test/test_simple_obj.js index 0ccccedb3c..52cea27a6b 100644 --- a/jscomp/test/dist/jscomp/test/test_simple_obj.js +++ b/jscomp/test/dist/jscomp/test/test_simple_obj.js @@ -89,83 +89,90 @@ var v = CamlinternalOO.create_object_opt(undefined, $$class$3); function test(param) { if (Caml_oo_curry.js1(23515, 1, uu) !== "uu") { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 21, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 21, + 4 + ] + } + }); } if (Caml_oo_curry.js3(4846113, 2, uuu, 1, 20) !== 21) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 22, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 22, + 4 + ] + } + }); } if (Caml_oo_curry.js3(4846113, 3, v, 3, 7) !== 10) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 23, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 23, + 4 + ] + } + }); } if (Caml_oo_curry.js1(5243894, 4, u) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 25, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 25, + 4 + ] + } + }); } if (Caml_oo_curry.js1(5243895, 5, u) !== 4) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 26, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 26, + 4 + ] + } + }); } if (Caml_oo_curry.js3(23297, 6, u, 1, 2) !== 3) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 27, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 27, + 4 + ] + } + }); } if (Caml_oo_curry.js2(616641298, 7, u, 32) === 32) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_simple_obj.ml", - 28, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_simple_obj.ml", + 28, + 4 + ] + } + }); } exports.u = u; diff --git a/jscomp/test/dist/jscomp/test/test_static_catch_ident.js b/jscomp/test/dist/jscomp/test/test_static_catch_ident.js index 6f9e23ba93..99b65ee420 100644 --- a/jscomp/test/dist/jscomp/test/test_static_catch_ident.js +++ b/jscomp/test/dist/jscomp/test/test_static_catch_ident.js @@ -11,7 +11,9 @@ function scanf_bad_input(ib, x) { if (x.MEL_EXN_ID === Scan_failure || x.MEL_EXN_ID === Stdlib.Failure) { s = x._1; } else { - throw x; + throw new Error(x.MEL_EXN_ID, { + cause: x + }); } for(var _i = 0; _i <= 100; ++_i){ console.log(s); diff --git a/jscomp/test/dist/jscomp/test/test_string.js b/jscomp/test/dist/jscomp/test/test_string.js index b9f24ff6bd..b09f4cdda0 100644 --- a/jscomp/test/dist/jscomp/test/test_string.js +++ b/jscomp/test/dist/jscomp/test/test_string.js @@ -11,15 +11,16 @@ function f(param) { case "bbbb" : return 1; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_string.ml", - 4, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_string.ml", + 4, + 18 + ] + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/test_string_case.js b/jscomp/test/dist/jscomp/test/test_string_case.js index 7a9f74be25..8306f9b227 100644 --- a/jscomp/test/dist/jscomp/test/test_string_case.js +++ b/jscomp/test/dist/jscomp/test/test_string_case.js @@ -9,15 +9,16 @@ function f(param) { case "bcde" : return 1; default: - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_string_case.ml", - 4, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_string_case.ml", + 4, + 9 + ] + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/test_string_const.js b/jscomp/test/dist/jscomp/test/test_string_const.js index 264c6278ba..95b5d2e6f4 100644 --- a/jscomp/test/dist/jscomp/test/test_string_const.js +++ b/jscomp/test/dist/jscomp/test/test_string_const.js @@ -16,7 +16,9 @@ catch (raw_exn){ console.log(exn._1); hh = /* 'a' */97; } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/jscomp/test/dist/jscomp/test/test_string_map.js b/jscomp/test/dist/jscomp/test/test_string_map.js index ab2c4b9796..d85fc6b8a8 100644 --- a/jscomp/test/dist/jscomp/test/test_string_map.js +++ b/jscomp/test/dist/jscomp/test/test_string_map.js @@ -46,17 +46,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -78,17 +80,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function add(x, data, m) { @@ -146,10 +150,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } diff --git a/jscomp/test/dist/jscomp/test/test_trywith.js b/jscomp/test/dist/jscomp/test/test_trywith.js index 2793067fec..c002f2add5 100644 --- a/jscomp/test/dist/jscomp/test/test_trywith.js +++ b/jscomp/test/dist/jscomp/test/test_trywith.js @@ -12,7 +12,9 @@ function ff(g, x) { catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); if (exn.MEL_EXN_ID !== Stdlib.Not_found) { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -22,7 +24,9 @@ function ff(g, x) { catch (raw_exn$1){ var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); if (exn$1.MEL_EXN_ID !== Stdlib.Out_of_memory) { - throw exn$1; + throw new Error(exn$1.MEL_EXN_ID, { + cause: exn$1 + }); } } @@ -32,7 +36,9 @@ function ff(g, x) { catch (raw_exn$2){ var exn$2 = Caml_js_exceptions.internalToOCamlException(raw_exn$2); if (exn$2.MEL_EXN_ID !== Stdlib.Sys_error) { - throw exn$2; + throw new Error(exn$2.MEL_EXN_ID, { + cause: exn$2 + }); } } @@ -42,7 +48,9 @@ function ff(g, x) { catch (raw_exn$3){ var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); if (exn$3.MEL_EXN_ID !== Stdlib.Invalid_argument) { - throw exn$3; + throw new Error(exn$3.MEL_EXN_ID, { + cause: exn$3 + }); } } @@ -52,7 +60,9 @@ function ff(g, x) { catch (raw_exn$4){ var exn$4 = Caml_js_exceptions.internalToOCamlException(raw_exn$4); if (exn$4.MEL_EXN_ID !== Stdlib.End_of_file) { - throw exn$4; + throw new Error(exn$4.MEL_EXN_ID, { + cause: exn$4 + }); } } @@ -62,7 +72,9 @@ function ff(g, x) { catch (raw_exn$5){ var exn$5 = Caml_js_exceptions.internalToOCamlException(raw_exn$5); if (exn$5.MEL_EXN_ID !== Stdlib.Match_failure) { - throw exn$5; + throw new Error(exn$5.MEL_EXN_ID, { + cause: exn$5 + }); } } @@ -72,7 +84,9 @@ function ff(g, x) { catch (raw_exn$6){ var exn$6 = Caml_js_exceptions.internalToOCamlException(raw_exn$6); if (exn$6.MEL_EXN_ID !== Stdlib.Stack_overflow) { - throw exn$6; + throw new Error(exn$6.MEL_EXN_ID, { + cause: exn$6 + }); } } @@ -82,7 +96,9 @@ function ff(g, x) { catch (raw_exn$7){ var exn$7 = Caml_js_exceptions.internalToOCamlException(raw_exn$7); if (exn$7.MEL_EXN_ID !== Stdlib.Sys_blocked_io) { - throw exn$7; + throw new Error(exn$7.MEL_EXN_ID, { + cause: exn$7 + }); } } @@ -92,7 +108,9 @@ function ff(g, x) { catch (raw_exn$8){ var exn$8 = Caml_js_exceptions.internalToOCamlException(raw_exn$8); if (exn$8.MEL_EXN_ID !== Stdlib.Assert_failure) { - throw exn$8; + throw new Error(exn$8.MEL_EXN_ID, { + cause: exn$8 + }); } } @@ -104,15 +122,18 @@ function ff(g, x) { if (exn$9.MEL_EXN_ID === Stdlib.Undefined_recursive_module) { return ; } - throw exn$9; + throw new Error(exn$9.MEL_EXN_ID, { + cause: exn$9 + }); } } function u(param) { - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); } function f(x) { @@ -122,15 +143,16 @@ function f(x) { if (x.TAG === /* D */0) { return 1; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_trywith.ml", - 51, - 9 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_trywith.ml", + 51, + 9 + ] + } + }); } var u1 = "bad character decimal encoding \\"; diff --git a/jscomp/test/dist/jscomp/test/test_unsupported_primitive.js b/jscomp/test/dist/jscomp/test/test_unsupported_primitive.js index 7a0a3e6f2e..850bacbf17 100644 --- a/jscomp/test/dist/jscomp/test/test_unsupported_primitive.js +++ b/jscomp/test/dist/jscomp/test/test_unsupported_primitive.js @@ -5,11 +5,12 @@ var Caml_external_polyfill = require("melange.js/caml_external_polyfill.js"); function to_buffer(buff, ofs, len, v, flags) { if (ofs < 0 || len < 0 || ofs > (buff.length - len | 0)) { - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Marshal.to_buffer: substring out of bounds", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Marshal.to_buffer: substring out of bounds" + } + }); } return Caml_external_polyfill.resolve("caml_output_value_to_buffer")(buff, ofs, len, v, flags); } diff --git a/jscomp/test/dist/jscomp/test/test_while_closure.js b/jscomp/test/dist/jscomp/test/test_while_closure.js index c31993cbd1..cb6b3751e7 100644 --- a/jscomp/test/dist/jscomp/test/test_while_closure.js +++ b/jscomp/test/dist/jscomp/test/test_while_closure.js @@ -35,15 +35,16 @@ Stdlib__Array.iter((function (x) { console.log(String(v.contents)); if (v.contents !== 45) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/test_while_closure.ml", - 63, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/test_while_closure.ml", + 63, + 4 + ] + } + }); } var count = 10; diff --git a/jscomp/test/dist/jscomp/test/ticker.js b/jscomp/test/dist/jscomp/test/ticker.js index 55bfaada94..4a08d5cd81 100644 --- a/jscomp/test/dist/jscomp/test/ticker.js +++ b/jscomp/test/dist/jscomp/test/ticker.js @@ -36,7 +36,9 @@ function split(delim, s) { tl: l }; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } var l_0 = Stdlib__String.sub(s, i$p + 1 | 0, (i - i$p | 0) - 1 | 0); var l$1 = { @@ -165,17 +167,19 @@ function bal(l, x, d, r) { if (lr) { return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -197,17 +201,19 @@ function bal(l, x, d, r) { if (rl) { return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.bal" + } + }); } function is_empty(param) { @@ -273,10 +279,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -313,10 +320,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -390,10 +398,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -478,10 +487,11 @@ function min_binding(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -516,10 +526,11 @@ function max_binding(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -549,11 +560,12 @@ function remove_min_binding(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Map.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt" + } + }); } function merge(t1, t2) { @@ -864,15 +876,16 @@ function merge$1(f, s1, s2) { var match$1 = split$1(v2, s1); return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/map.ml", - 408, - 10 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/map.ml", + 408, + 10 + ] + } + }); } function union(f, s1, s2) { @@ -1315,19 +1328,21 @@ function compute_update_sequences(all_tickers) { var l$1 = Stdlib__List.sort_uniq((function (lhs, rhs) { var x = lhs.rank; if (typeof x === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "All nodes should be ranked" + } + }); } var y = rhs.rank; if (typeof y === "number") { - throw { - MEL_EXN_ID: "Failure", - _1: "All nodes should be ranked", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "All nodes should be ranked" + } + }); } return Caml.caml_int_compare(x._0, y._0); }), l); @@ -1353,11 +1368,12 @@ function process_quote(ticker_map, new_ticker, new_value) { ticker.value = new_value; return ; } - throw { - MEL_EXN_ID: "Failure", - _1: "Only single Market ticker should be udpated upon a new quote", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Only single Market ticker should be udpated upon a new quote" + } + }); }), update_sequence); } @@ -1387,11 +1403,12 @@ function process_input_line(ticker_map, all_tickers, line) { var match$1 = match.tl; if (match$1) { if (match$1.tl) { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } var ticker_map$1 = ticker_map !== undefined ? Caml_option.valFromOption(ticker_map) : compute_update_sequences(all_tickers); var value = Caml_format.caml_float_of_string(match$1.hd); @@ -1401,17 +1418,19 @@ function process_input_line(ticker_map, all_tickers, line) { Caml_option.some(ticker_map$1) ]; } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); case "R" : var match$2 = tokens.tl; if (match$2) { @@ -1425,11 +1444,12 @@ function process_input_line(ticker_map, all_tickers, line) { var match$5 = match$4.tl; if (match$5) { if (match$5.tl) { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } return [ { @@ -1439,28 +1459,31 @@ function process_input_line(ticker_map, all_tickers, line) { ticker_map ]; } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); case "-" : var match$6 = match$3.tl; if (match$6) { var match$7 = match$6.tl; if (match$7) { if (match$7.tl) { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } return [ { @@ -1470,24 +1493,27 @@ function process_input_line(ticker_map, all_tickers, line) { ticker_map ]; } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); case "S" : if (match$3.tl) { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } return [ { @@ -1502,39 +1528,44 @@ function process_input_line(ticker_map, all_tickers, line) { ticker_map ]; default: - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } default: - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } } else { - throw { - MEL_EXN_ID: "Failure", - _1: "Invalid input line", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "Invalid input line" + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/topsort_test.js b/jscomp/test/dist/jscomp/test/topsort_test.js index 4c3e9204d3..93a37bb59a 100644 --- a/jscomp/test/dist/jscomp/test/topsort_test.js +++ b/jscomp/test/dist/jscomp/test/topsort_test.js @@ -122,15 +122,16 @@ if (!Caml_obj.caml_equal(dfs1({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 29, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 29, + 2 + ] + } + }); } Stdlib.print_newline(undefined); @@ -160,15 +161,16 @@ if (!Caml_obj.caml_equal(dfs1({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 32, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 32, + 2 + ] + } + }); } function dfs2(nodes, graph, visited) { @@ -221,15 +223,16 @@ if (!Caml_obj.caml_equal(dfs2({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 47, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 47, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(dfs2({ @@ -257,15 +260,16 @@ if (!Caml_obj.caml_equal(dfs2({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 48, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 48, + 2 + ] + } + }); } function dfs3(nodes, graph) { @@ -315,15 +319,16 @@ if (!Caml_obj.caml_equal(dfs3({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 65, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 65, + 2 + ] + } + }); } if (!Caml_obj.caml_equal(dfs3({ @@ -351,15 +356,16 @@ if (!Caml_obj.caml_equal(dfs3({ } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 66, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 66, + 2 + ] + } + }); } var grwork = { @@ -440,15 +446,16 @@ if (!Caml_obj.caml_equal(unsafe_topsort(grwork), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 110, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 110, + 2 + ] + } + }); } var funarg = { @@ -488,17 +495,19 @@ function bal(l, v, r) { if (lr) { return create(create(ll, lv, lr.l), lr.v, create(lr.r, v, r)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } if (hr <= (hl + 2 | 0)) { return /* Node */{ @@ -518,17 +527,19 @@ function bal(l, v, r) { if (rl) { return create(create(l, v, rl.l), rl.v, create(rl.r, rv, rr)); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.bal", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.bal" + } + }); } function add(x, t) { @@ -617,10 +628,11 @@ function min_elt(_param) { _param = l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -649,10 +661,11 @@ function max_elt(_param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -679,11 +692,12 @@ function remove_min_elt(param) { return param.r; } } - throw { - MEL_EXN_ID: "Invalid_argument", - _1: "Set.remove_min_elt", - Error: new Error() - }; + throw new Error("Invalid_argument", { + cause: { + MEL_EXN_ID: "Invalid_argument", + _1: "Set.remove_min_elt" + } + }); } function concat(t1, t2) { @@ -1165,10 +1179,11 @@ function find(x, _param) { _param = c < 0 ? param.l : param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1199,10 +1214,11 @@ function find_first(f, _param) { _param = param.r; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1264,10 +1280,11 @@ function find_last(f, _param) { _param = param.l; continue ; } - throw { - MEL_EXN_ID: Stdlib.Not_found, - Error: new Error() - }; + throw new Error(Stdlib.Not_found, { + cause: { + MEL_EXN_ID: Stdlib.Not_found + } + }); }; } @@ -1482,15 +1499,16 @@ function of_list(l) { match$4[1] ]; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/stdlib/set.ml", - 571, - 18 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/stdlib/set.ml", + 571, + 18 + ] + } + }); }; return sub(Stdlib__List.length(l$1), l$1)[0]; } else { @@ -1666,14 +1684,15 @@ function pathsort(graph) { var stack = param[1]; var set = param[0]; if (Curry._2(mem, node, set)) { - throw { - MEL_EXN_ID: Cycle, - _1: { - hd: node, - tl: stack - }, - Error: new Error() - }; + throw new Error(Cycle, { + cause: { + MEL_EXN_ID: Cycle, + _1: { + hd: node, + tl: stack + } + } + }); } return [ Curry._2(add, node, set), @@ -1724,15 +1743,16 @@ if (!Caml_obj.caml_equal(pathsort(grwork), { } } })) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 150, - 4 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 150, + 4 + ] + } + }); } try { @@ -1743,15 +1763,16 @@ try { ], tl: grwork }); - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 156, - 8 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 156, + 8 + ] + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -1781,15 +1802,16 @@ catch (raw_exn){ exit = 1; } if (exit === 1) { - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/topsort_test.ml", - 159, - 11 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/topsort_test.ml", + 159, + 11 + ] + } + }); } } diff --git a/jscomp/test/dist/jscomp/test/tscanf_test.js b/jscomp/test/dist/jscomp/test/tscanf_test.js index 55e9751b7a..d97924bc97 100644 --- a/jscomp/test/dist/jscomp/test/tscanf_test.js +++ b/jscomp/test/dist/jscomp/test/tscanf_test.js @@ -912,15 +912,16 @@ function verify_read(c) { }), id) === c) { return ; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/tscanf_test.ml", - 174, - 2 - ], - Error: new Error() - }; + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/tscanf_test.ml", + 174, + 2 + ] + } + }); } function verify_scan_Chars(param) { @@ -1739,11 +1740,12 @@ function scan_elems$1(ib, accu) { }); } if (c !== 93) { - throw { - MEL_EXN_ID: "Failure", - _1: "scan_elems", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "scan_elems" + } + }); } return Stdlib__List.rev({ hd: i, @@ -1830,11 +1832,12 @@ function scan_elems$2(ib, accu) { }); } console.log(Caml_bytes.bytes_to_string(Stdlib__Bytes.make(1, c))); - throw { - MEL_EXN_ID: "Failure", - _1: "scan_elems", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "scan_elems" + } + }); })); } catch (raw_exn){ @@ -1853,7 +1856,9 @@ function scan_elems$2(ib, accu) { if (exn.MEL_EXN_ID === Stdlib.End_of_file) { return accu; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -2057,11 +2062,12 @@ function scan_rest(ib, accu) { })); } if (c !== 93) { - throw { - MEL_EXN_ID: "Failure", - _1: "scan_rest", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "scan_rest" + } + }); } return accu; })); @@ -2084,11 +2090,12 @@ function scan_elems$4(ib, accu) { _1: " %c " }), (function (c) { if (c !== 91) { - throw { - MEL_EXN_ID: "Failure", - _1: "scan_elems", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "scan_elems" + } + }); } if (Caml_obj.caml_equal(accu, /* [] */0)) { return Curry._1(Stdlib__Scanf.bscanf(ib, /* Format */{ @@ -2129,11 +2136,12 @@ function scan_elems$4(ib, accu) { } })); } - throw { - MEL_EXN_ID: "Failure", - _1: "scan_elems", - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: "scan_elems" + } + }); })); } @@ -2260,11 +2268,12 @@ function scan_rest$1(ib, accu) { }, _1: "scan_int_list" }); - throw { - MEL_EXN_ID: "Failure", - _1: s, - Error: new Error() - }; + throw new Error("Failure", { + cause: { + MEL_EXN_ID: "Failure", + _1: s + } + }); } })); })); @@ -2340,7 +2349,9 @@ function scan_elems$5(ib, scan_elem, accu) { if (exn.MEL_EXN_ID === Stdlib__Scanf.Scan_failure) { return accu; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } @@ -4340,10 +4351,11 @@ function next_char(ob, param) { var s = Stdlib__Buffer.contents(ob); var len = s.length; if (len === 0) { - throw { - MEL_EXN_ID: Stdlib.End_of_file, - Error: new Error() - }; + throw new Error(Stdlib.End_of_file, { + cause: { + MEL_EXN_ID: Stdlib.End_of_file + } + }); } var c = Caml_string.get(s, 0); ob.position = 0; diff --git a/jscomp/test/dist/jscomp/test/variant.js b/jscomp/test/dist/jscomp/test/variant.js index ccc8b275f5..5ba9ccc4af 100644 --- a/jscomp/test/dist/jscomp/test/variant.js +++ b/jscomp/test/dist/jscomp/test/variant.js @@ -98,7 +98,9 @@ function rollback_path(subst, p) { } } else { - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } } @@ -135,7 +137,9 @@ function fooExn(f) { var match = exn._1; return match[0] + match[1] | 0; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } } diff --git a/test/blackbox-tests/exn-cause.t b/test/blackbox-tests/exn-cause.t new file mode 100644 index 0000000000..167c0e6fb2 --- /dev/null +++ b/test/blackbox-tests/exn-cause.t @@ -0,0 +1,147 @@ + + $ . ./setup.sh + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + $ cat > dune < (melange.emit + > (target js-out) + > (preprocess (pps melange.ppx))) + > EOF + $ cat > x.ml << EOF + > exception A of int + > let () = + > let a0 = + > try [%mel.raw{| (function (){throw 2} ()) |}] with + > | A x -> x + > | Js.Exn.Error v -> Obj.magic v + > | _ -> assert false + > in + > Js.log a0 + > EOF + $ dune build @melange + $ cat _build/default/js-out/x.js + // Generated by Melange + 'use strict'; + + var Caml_exceptions = require("melange.js/caml_exceptions.js"); + var Caml_js_exceptions = require("melange.js/caml_js_exceptions.js"); + var Js__Js_exn = require("melange.js/js_exn.js"); + + var A = /* @__PURE__ */Caml_exceptions.create("Melange__X.A"); + + var a0; + + try { + a0 = ((function (){throw 2} ()) + ); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.MEL_EXN_ID === A || exn.MEL_EXN_ID === Js__Js_exn.$$Error) { + a0 = exn._1; + } else { + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "x.ml", + 7, + 11 + ] + } + }); + } + } + + console.log(a0); + + exports.A = A; + /* a0 Not a pure module */ + $ node _build/default/js-out/x.js + 2 + +Raise `null` / `undefined` + + $ cat > x.ml << EOF + > exception A of int + > let () = + > let a0 = + > try [%mel.raw{| (function (){throw undefined} ()) |}] with + > | A x -> x + > | Js.Exn.Error v -> Obj.magic v + > | _ -> assert false + > and a1 = + > try [%mel.raw{| (function (){throw null} ()) |}] with + > | A x -> x + > | Js.Exn.Error v -> Obj.magic v + > | _ -> assert false + > in + > Js.log2 a0 a1 + > EOF + $ dune build @melange + $ cat _build/default/js-out/x.js + // Generated by Melange + 'use strict'; + + var Caml_exceptions = require("melange.js/caml_exceptions.js"); + var Caml_js_exceptions = require("melange.js/caml_js_exceptions.js"); + var Js__Js_exn = require("melange.js/js_exn.js"); + + var A = /* @__PURE__ */Caml_exceptions.create("Melange__X.A"); + + var a0; + + try { + a0 = ((function (){throw undefined} ()) + ); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.MEL_EXN_ID === A || exn.MEL_EXN_ID === Js__Js_exn.$$Error) { + a0 = exn._1; + } else { + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "x.ml", + 7, + 11 + ] + } + }); + } + } + + var a1; + + try { + a1 = ((function (){throw null} ()) + ); + } + catch (raw_exn$1){ + var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); + if (exn$1.MEL_EXN_ID === A || exn$1.MEL_EXN_ID === Js__Js_exn.$$Error) { + a1 = exn$1._1; + } else { + throw new Error("Assert_failure", { + cause: { + MEL_EXN_ID: "Assert_failure", + _1: [ + "x.ml", + 12, + 11 + ] + } + }); + } + } + + console.log(a0, a1); + + exports.A = A; + /* a0 Not a pure module */ + $ node _build/default/js-out/x.js + undefined null diff --git a/test/blackbox-tests/mel-as-inline-records.t b/test/blackbox-tests/mel-as-inline-records.t index 2250061e2e..b60bf8ec7b 100644 --- a/test/blackbox-tests/mel-as-inline-records.t +++ b/test/blackbox-tests/mel-as-inline-records.t @@ -23,11 +23,12 @@ Test `@mel.as` in inline records / record extensions function user3(param) { try { - throw { - MEL_EXN_ID: UserException, - renamed: "Corentin", - Error: new Error() - }; + throw new Error(UserException, { + cause: { + MEL_EXN_ID: UserException, + renamed: "Corentin" + } + }); } catch (raw_exn){ var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); @@ -35,7 +36,9 @@ Test `@mel.as` in inline records / record extensions console.log("name:", exn.renamed); return ; } - throw exn; + throw new Error(exn.MEL_EXN_ID, { + cause: exn + }); } }