diff --git a/CHANGELOG.md b/CHANGELOG.md index 034f1b6daf..872a72e3f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - Add [`Deno`](https://deno.land/api?s=Deno) to reserved names, so that modules named `Deno` don't clash with the globally exposed `Deno` object. https://github.com/rescript-lang/rescript-compiler/pull/6428 - Disable ESLint/TSLint on gentype outputs properly. https://github.com/rescript-lang/rescript-compiler/pull/6442 - Improve `rescript` CLI to use `stdout`/`stderr` appropriately for help command's message. https://github.com/rescript-lang/rescript-compiler/pull/6439 +- Generate `f()` instead of `f(undefined)` for `f()` https://github.com/rescript-lang/rescript-compiler/pull/6459 # 11.0.0-rc.4 diff --git a/jscomp/core/j.ml b/jscomp/core/j.ml index 099cb24901..2d3e9329bc 100644 --- a/jscomp/core/j.ml +++ b/jscomp/core/j.ml @@ -159,7 +159,7 @@ and expression_desc = *) | Number of number | Object of property_map - | Undefined + | Undefined of {isUnit: bool} | Null | Await of expression diff --git a/jscomp/core/js_analyzer.ml b/jscomp/core/js_analyzer.ml index a4ca28e105..d2de7d61bc 100644 --- a/jscomp/core/js_analyzer.ml +++ b/jscomp/core/js_analyzer.ml @@ -82,7 +82,7 @@ let free_variables_of_expression st = let rec no_side_effect_expression_desc (x : J.expression_desc) = match x with - | Undefined | Null | Bool _ | Var _ -> true + | Undefined _ | Null | Bool _ | Var _ -> true | Fun _ -> true | Number _ -> true (* Can be refined later *) | Static_index (obj, (_name : string), (_pos : int32 option)) -> @@ -153,7 +153,7 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression) ({ expression_desc = y0 } : J.expression) = match x0 with | Null -> y0 = Null - | Undefined -> y0 = Undefined + | Undefined x -> y0 = Undefined x | Number (Int { i }) -> ( match y0 with Number (Int { i = j }) -> i = j | _ -> false) | Number (Float _) -> false diff --git a/jscomp/core/js_cmj_format.ml b/jscomp/core/js_cmj_format.ml index 7356a1a5ba..9f33ebc7e5 100644 --- a/jscomp/core/js_cmj_format.ml +++ b/jscomp/core/js_cmj_format.ml @@ -113,7 +113,7 @@ let get_result midVal = match midVal.persistent_closed_lambda with | Some (Lconst - (Const_js_null | Const_js_undefined | Const_js_true | Const_js_false)) + (Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false)) | None -> midVal | Some _ -> diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 48e7a6c4dd..79a8ff13a4 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -160,7 +160,7 @@ let exp_need_paren (e : J.expression) = | Raw_js_code { code_info = Stmt _ } | Length _ | Call _ | Caml_block_tag _ | Seq _ | Static_index _ | Cond _ | Bin _ | Is_null_or_undefined _ | String_index _ | Array_index _ - | String_append _ | Var _ | Undefined | Null | Str _ | Array _ + | String_append _ | Var _ | Undefined _ | Null | Str _ | Array _ | Optional_block _ | Caml_block _ | FlatCall _ | Typeof _ | Number _ | Js_not _ | Bool _ | New _ -> false @@ -519,7 +519,7 @@ and expression_desc cxt ~(level : int) f x : cxt = | Null -> P.string f L.null; cxt - | Undefined -> + | Undefined _ -> P.string f L.undefined; cxt | Var v -> vident cxt f v @@ -569,7 +569,14 @@ and expression_desc cxt ~(level : int) f x : cxt = pp_function ~is_method ~return_unit ~async cxt f ~fn_state:(No_name { single_arg = true }) params body env - | _ -> arguments cxt f el) + | _ -> + let el = match el with + | [e] when e.expression_desc = Undefined {isUnit = true} -> + (* omit passing undefined when the call is f() *) + [] + | _ -> + el in + arguments cxt f el) | _, _ -> let len = List.length el in if 1 <= len && len <= 8 then ( @@ -736,7 +743,7 @@ and expression_desc cxt ~(level : int) f x : cxt = let fields = Ext_list.array_list_filter_map fields el (fun f x -> match x.expression_desc with - | Undefined -> None + | Undefined _ -> None | _ -> Some (Js_op.Lit f, x)) in expression_desc cxt ~level f (Object fields)) @@ -774,7 +781,7 @@ and expression_desc cxt ~(level : int) f x : cxt = | _ -> Ext_list.filter_map tails (fun (f, x) -> match x.expression_desc with - | Undefined when is_optional f -> None + | Undefined _ when is_optional f -> None | _ -> Some (f, x)) in if untagged then @@ -1176,7 +1183,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt = in semi f; cxt - | Undefined -> + | Undefined _ -> return_sp f; semi f; cxt @@ -1270,16 +1277,16 @@ and function_body (cxt : cxt) f ~return_unit (b : J.block) : unit = | If ( bool, then_, - [ { statement_desc = Return { expression_desc = Undefined } } ] ) -> + [ { statement_desc = Return { expression_desc = Undefined _ } } ] ) -> ignore (statement false cxt f { s with statement_desc = If (bool, then_, []) } : cxt) - | Return { expression_desc = Undefined } -> () + | Return { expression_desc = Undefined _ } -> () | Return exp when return_unit -> ignore (statement false cxt f (S.exp exp) : cxt) | _ -> ignore (statement false cxt f s : cxt)) - | [ s; { statement_desc = Return { expression_desc = Undefined } } ] -> + | [ s; { statement_desc = Return { expression_desc = Undefined _ } } ] -> ignore (statement false cxt f s : cxt) | s :: r -> let cxt = statement false cxt f s in diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index a807fa6531..10e9e93929 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -60,7 +60,7 @@ let var ?comment id : t = { expression_desc = Var (Id id); comment } Invariant: it should not call an external module .. *) let js_global ?comment (v : string) = var ?comment (Ext_ident.create_js v) -let undefined : t = { expression_desc = Undefined; comment = None } +let undefined : t = { expression_desc = Undefined {isUnit = false}; comment = None } let nil : t = { expression_desc = Null; comment = None } let call ?comment ~info e0 args : t = @@ -183,7 +183,7 @@ let is_array (e0 : t) : t = let new_ ?comment e0 args : t = { expression_desc = New (e0, Some args); comment } -let unit : t = { expression_desc = Undefined; comment = None } +let unit : t = { expression_desc = Undefined {isUnit = true}; comment = None } (* let math ?comment v args : t = {comment ; expression_desc = Math(v,args)} *) @@ -256,17 +256,17 @@ let dummy_obj ?comment (info : Lam_tag_info.t) : t = *) let rec seq ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with - | ( ( Seq (a, { expression_desc = Number _ | Undefined }) - | Seq ({ expression_desc = Number _ | Undefined }, a) ), + | ( ( Seq (a, { expression_desc = Number _ | Undefined _ }) + | Seq ({ expression_desc = Number _ | Undefined _ }, a) ), _ ) -> seq ?comment a e1 - | _, Seq ({ expression_desc = Number _ | Undefined }, a) -> + | _, Seq ({ expression_desc = Number _ | Undefined _ }, a) -> (* Return value could not be changed*) seq ?comment e0 a - | _, Seq (a, ({ expression_desc = Number _ | Undefined } as v)) -> + | _, Seq (a, ({ expression_desc = Number _ | Undefined _ } as v)) -> (* Return value could not be changed*) seq ?comment (seq e0 a) v - | (Number _ | Var _ | Undefined), _ -> e1 + | (Number _ | Var _ | Undefined _), _ -> e1 | _ -> { expression_desc = Seq (e0, e1); comment } let fuse_to_seq x xs = if xs = [] then x else Ext_list.fold_left xs x seq @@ -567,22 +567,22 @@ let str_equal (txt0:string) (delim0:External_arg_spec.delim) txt1 delim1 = let rec triple_equal ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with - | ( (Null | Undefined), + | ( (Null | Undefined _), (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _) ) when no_side_effect e1 -> false_ | ( (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _), - (Null | Undefined) ) + (Null | Undefined _) ) when no_side_effect e0 -> false_ | Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1) | Optional_block (a, _), Optional_block (b, _) -> triple_equal ?comment a b - | Undefined, Optional_block _ - | Optional_block _, Undefined - | Null, Undefined - | Undefined, Null -> + | Undefined _, Optional_block _ + | Optional_block _, Undefined _ + | Null, Undefined _ + | Undefined _, Null -> false_ - | Null, Null | Undefined, Undefined -> true_ + | Null, Null | Undefined _, Undefined _ -> true_ | _ -> { expression_desc = Bin (EqEqEq, e0, e1); comment } let bin ?comment (op : J.binop) (e0 : t) (e1 : t) : t = @@ -654,7 +654,7 @@ let and_ ?comment (e1 : t) (e2 : t) : t = | Var i, Bin (And, l, ({ expression_desc = Var j; _ } as r)) when Js_op_util.same_vident i j -> { e2 with expression_desc = Bin (And, r, l) } - | ( Bin (NotEqEq, { expression_desc = Var i }, { expression_desc = Undefined }), + | ( Bin (NotEqEq, { expression_desc = Var i }, { expression_desc = Undefined _ }), Bin ( EqEqEq, { expression_desc = Var j }, @@ -702,7 +702,7 @@ let not (e : t) : t = let not_empty_branch (x : t) = match x.expression_desc with - | Number (Int { i = 0l }) | Undefined -> false + | Number (Int { i = 0l }) | Undefined _ -> false | _ -> true let rec econd ?comment (pred : t) (ifso : t) (ifnot : t) : t = @@ -735,8 +735,8 @@ let rec econd ?comment (pred : t) (ifso : t) (ifnot : t) : t = econd (or_ pred (not pred1)) ifso ifso1 | Js_not e, _, _ when not_empty_branch ifnot -> econd ?comment e ifnot ifso | ( _, - Seq (a, { expression_desc = Undefined }), - Seq (b, { expression_desc = Undefined }) ) -> + Seq (a, { expression_desc = Undefined _ }), + Seq (b, { expression_desc = Undefined _ }) ) -> seq (econd ?comment pred a b) undefined | _ -> if Js_analyzer.eq_expression ifso ifnot then @@ -746,7 +746,7 @@ let rec econd ?comment (pred : t) (ifso : t) (ifnot : t) : t = let rec float_equal ?comment (e0 : t) (e1 : t) : t = match (e0.expression_desc, e1.expression_desc) with | Number (Int { i = i0; _ }), Number (Int { i = i1 }) -> bool (i0 = i1) - | Undefined, Undefined -> true_ + | Undefined _, Undefined _ -> true_ (* | (Bin(Bor, {expression_desc = Number(Int {i = 0l; _})}, ({expression_desc = Caml_block_tag _; _} as a )) @@ -983,11 +983,11 @@ let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) = args, call_info ); } - | Ceq, Optional_block _, Undefined | Ceq, Undefined, Optional_block _ -> + | Ceq, Optional_block _, Undefined _ | Ceq, Undefined _, Optional_block _ -> false_ | Ceq, _, _ -> int_equal e0 e1 - | Cneq, Optional_block _, Undefined - | Cneq, Undefined, Optional_block _ + | Cneq, Optional_block _, Undefined _ + | Cneq, Undefined _, Optional_block _ | Cneq, Caml_block _, Number _ | Cneq, Number _, Caml_block _ -> true_ @@ -1281,36 +1281,36 @@ let is_null ?comment (x : t) = triple_equal ?comment x nil let is_undef ?comment x = triple_equal ?comment x undefined let for_sure_js_null_undefined (x : t) = - match x.expression_desc with Null | Undefined -> true | _ -> false + match x.expression_desc with Null | Undefined _ -> true | _ -> false let is_null_undefined ?comment (x : t) : t = match x.expression_desc with - | Null | Undefined -> true_ + | Null | Undefined _ -> true_ | Number _ | Array _ | Caml_block _ -> false_ | _ -> { comment; expression_desc = Is_null_or_undefined x } let eq_null_undefined_boolean ?comment (a : t) (b : t) = match (a.expression_desc, b.expression_desc) with - | ( (Null | Undefined), + | ( (Null | Undefined _), (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _) ) -> false_ | ( (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _), - (Null | Undefined) ) -> + (Null | Undefined _) ) -> false_ - | Null, Undefined | Undefined, Null -> false_ - | Null, Null | Undefined, Undefined -> true_ + | Null, Undefined _ | Undefined _, Null -> false_ + | Null, Null | Undefined _, Undefined _ -> true_ | _ -> { expression_desc = Bin (EqEqEq, a, b); comment } let neq_null_undefined_boolean ?comment (a : t) (b : t) = match (a.expression_desc, b.expression_desc) with - | ( (Null | Undefined), + | ( (Null | Undefined _), (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _) ) -> true_ | ( (Bool _ | Number _ | Typeof _ | Fun _ | Array _ | Caml_block _), - (Null | Undefined) ) -> + (Null | Undefined _) ) -> true_ - | Null, Null | Undefined, Undefined -> false_ - | Null, Undefined | Undefined, Null -> true_ + | Null, Null | Undefined _, Undefined _ -> false_ + | Null, Undefined _ | Undefined _, Null -> true_ | _ -> { expression_desc = Bin (NotEqEq, a, b); comment } (** TODO: in the future add a flag diff --git a/jscomp/core/js_fold.ml b/jscomp/core/js_fold.ml index 42d8410ba6..fd4eba1356 100644 --- a/jscomp/core/js_fold.ml +++ b/jscomp/core/js_fold.ml @@ -169,7 +169,7 @@ class fold = | Object _x0 -> let _self = _self#property_map _x0 in _self - | Undefined -> _self + | Undefined _ -> _self | Null -> _self | Await _x0 -> let _self = _self#expression _x0 in diff --git a/jscomp/core/js_of_lam_option.ml b/jscomp/core/js_of_lam_option.ml index 7d13ac5d13..7c2edf133b 100644 --- a/jscomp/core/js_of_lam_option.ml +++ b/jscomp/core/js_of_lam_option.ml @@ -36,7 +36,9 @@ type option_unwrap_time = Static_unwrapped | Runtime_maybe_unwrapped *) let none : J.expression = E.undefined -let is_none_static (arg : J.expression_desc) = arg = Undefined +let is_none_static (arg : J.expression_desc) = match arg with + | Undefined _ -> true + | _ -> false let is_not_none (e : J.expression) : J.expression = let desc = e.expression_desc in diff --git a/jscomp/core/js_pass_flatten_and_mark_dead.ml b/jscomp/core/js_pass_flatten_and_mark_dead.ml index d89d9cd513..6ff6066283 100644 --- a/jscomp/core/js_pass_flatten_and_mark_dead.ml +++ b/jscomp/core/js_pass_flatten_and_mark_dead.ml @@ -192,7 +192,7 @@ let subst_map (substitution : J.expression Hash_ident.t) = let _, e, bindings = Ext_list.fold_left ls (0, [], []) (fun (i, e, acc) x -> match x.expression_desc with - | Var _ | Number _ | Str _ | J.Bool _ | Undefined -> + | Var _ | Number _ | Str _ | J.Bool _ | Undefined _ -> (* TODO: check the optimization *) (i + 1, x :: e, acc) | _ -> @@ -257,7 +257,7 @@ let subst_map (substitution : J.expression Hash_ident.t) = match Ext_list.nth_opt ls (Int32.to_int i) with | Some ({ - expression_desc = J.Var _ | Number _ | Str _ | Undefined; + expression_desc = J.Var _ | Number _ | Str _ | Undefined _; } as x) -> x | None | Some _ -> super.expression self x) diff --git a/jscomp/core/js_record_fold.ml b/jscomp/core/js_record_fold.ml index 04b4f546ba..86117cbcf7 100644 --- a/jscomp/core/js_record_fold.ml +++ b/jscomp/core/js_record_fold.ml @@ -175,7 +175,7 @@ let expression_desc : 'a. ('a, expression_desc) fn = | Object _x0 -> let st = property_map _self st _x0 in st - | Undefined -> st + | Undefined _ -> st | Null -> st | Await _x0 -> let st = _self.expression _self st _x0 in diff --git a/jscomp/core/js_record_iter.ml b/jscomp/core/js_record_iter.ml index e7a0cdfddd..d0f523ed7e 100644 --- a/jscomp/core/js_record_iter.ml +++ b/jscomp/core/js_record_iter.ml @@ -131,7 +131,7 @@ let expression_desc : expression_desc fn = | Caml_block_tag (_x0, _tag) -> _self.expression _self _x0 | Number _ -> () | Object _x0 -> property_map _self _x0 - | Undefined -> () + | Undefined _ -> () | Null -> () | Await _x0 -> _self.expression _self _x0 diff --git a/jscomp/core/js_record_map.ml b/jscomp/core/js_record_map.ml index 742d9e3641..371d54eb6a 100644 --- a/jscomp/core/js_record_map.ml +++ b/jscomp/core/js_record_map.ml @@ -173,7 +173,7 @@ let expression_desc : expression_desc fn = | Object _x0 -> let _x0 = property_map _self _x0 in Object _x0 - | Undefined as v -> v + | Undefined _ as v -> v | Null as v -> v | Await _x0 -> let _x0 = _self.expression _self _x0 in diff --git a/jscomp/core/js_stmt_make.ml b/jscomp/core/js_stmt_make.ml index 80136396f9..82773ae80e 100644 --- a/jscomp/core/js_stmt_make.ml +++ b/jscomp/core/js_stmt_make.ml @@ -44,10 +44,10 @@ let rec block ?comment (b : J.block) : t = (* It's a statement, we can discard some values *) let rec exp ?comment (e : E.t) : t = match e.expression_desc with - | Seq ({ expression_desc = Number _ | Undefined }, b) - | Seq (b, { expression_desc = Number _ | Undefined }) -> + | Seq ({ expression_desc = Number _ | Undefined _ }, b) + | Seq (b, { expression_desc = Number _ | Undefined _ }) -> exp ?comment b - | Number _ | Undefined -> block [] + | Number _ | Undefined _ -> block [] (* TODO: we can do more *) (* | _ when is_pure e -> block [] *) | _ -> { statement_desc = Exp e; comment } @@ -63,10 +63,10 @@ let declare_variable ?comment ?ident_info ~kind (ident : Ident.t) : t = } let define_variable ?comment ?ident_info ~kind (v : Ident.t) - (exp : J.expression) : t = - if exp.expression_desc = Undefined then + (exp : J.expression) : t = match exp.expression_desc with + | Undefined _ -> declare_variable ?comment ?ident_info ~kind v - else + | _ -> let property : J.property = kind in let ident_info : J.ident_info = match ident_info with None -> { used_stats = NA } | Some x -> x diff --git a/jscomp/core/lam.ml b/jscomp/core/lam.ml index c41a70a993..c1686e2047 100644 --- a/jscomp/core/lam.ml +++ b/jscomp/core/lam.ml @@ -419,7 +419,7 @@ let stringswitch (lam : t) cases default : t = let true_ : t = Lconst Const_js_true let false_ : t = Lconst Const_js_false -let unit : t = Lconst Const_js_undefined +let unit : t = Lconst (Const_js_undefined {isUnit = true}) let rec seq (a : t) b : t = match a with @@ -635,7 +635,7 @@ let rec eval_const_as_bool (v : Lam_constant.t) : bool = | Const_int { i = x } -> x <> 0l | Const_char x -> x <> 0 | Const_int64 x -> x <> 0L - | Const_js_false | Const_js_null | Const_module_alias | Const_js_undefined -> + | Const_js_false | Const_js_null | Const_module_alias | Const_js_undefined _ -> false | Const_js_true | Const_string _ | Const_pointer _ | Const_float _ | Const_block _ | Const_float_array _ -> diff --git a/jscomp/core/lam_analysis.ml b/jscomp/core/lam_analysis.ml index 66edeb0678..eacfe0a872 100644 --- a/jscomp/core/lam_analysis.ml +++ b/jscomp/core/lam_analysis.ml @@ -194,7 +194,7 @@ let rec size (lam : Lam.t) = and size_constant x = match x with | Const_int _ | Const_char _ | Const_float _ | Const_int64 _ | Const_pointer _ - | Const_js_null | Const_js_undefined | Const_module_alias | Const_js_true + | Const_js_null | Const_js_undefined _ | Const_module_alias | Const_js_true | Const_js_false -> 1 | Const_string _ -> @@ -270,6 +270,6 @@ let safe_to_inline (lam : Lam.t) = | Lconst ( Const_pointer _ | Const_int { comment = Pt_constructor _ } - | Const_js_true | Const_js_false | Const_js_undefined ) -> + | Const_js_true | Const_js_false | Const_js_undefined _ ) -> true | _ -> false diff --git a/jscomp/core/lam_compile.ml b/jscomp/core/lam_compile.ml index d3366c8023..7361a1e22d 100644 --- a/jscomp/core/lam_compile.ml +++ b/jscomp/core/lam_compile.ml @@ -30,6 +30,7 @@ let args_either_function_or_const (args : Lam.t list) = match x with Lfunction _ | Lconst _ -> true | _ -> false) let call_info_of_ap_status (ap_status : Lam.apply_status) : Js_call_info.t = + (* XXX *) match ap_status with | App_infer_full -> { arity = Full; call_info = Call_ml } | App_uncurry -> { arity = Full; call_info = Call_na } diff --git a/jscomp/core/lam_compile_const.ml b/jscomp/core/lam_compile_const.ml index 0a09b6b5eb..98acf07cb8 100644 --- a/jscomp/core/lam_compile_const.ml +++ b/jscomp/core/lam_compile_const.ml @@ -28,7 +28,7 @@ module E = Js_exp_make let rec is_some_none_aux (x : Lam_constant.t) acc = match x with | Const_some v -> is_some_none_aux v (acc + 1) - | Const_module_alias | Const_js_undefined -> acc + | Const_module_alias | Const_js_undefined _ -> acc | _ -> -1 let rec nested_some_none n none = @@ -37,7 +37,7 @@ let rec nested_some_none n none = let rec translate_some (x : Lam_constant.t) : J.expression = let depth = is_some_none_aux x 0 in if depth < 0 then E.optional_not_nest_block (translate x) - else nested_some_none depth (E.optional_block (translate Const_js_undefined)) + else nested_some_none depth (E.optional_block (translate (Const_js_undefined {isUnit = false}))) and translate (x : Lam_constant.t) : J.expression = match x with @@ -46,7 +46,8 @@ and translate (x : Lam_constant.t) : J.expression = | Const_js_true -> E.bool true | Const_js_false -> E.bool false | Const_js_null -> E.nil - | Const_js_undefined -> E.undefined + | Const_js_undefined {isUnit = true} -> E.unit + | Const_js_undefined {isUnit = false} -> E.undefined | Const_int { i; comment = Pt_constructor {cstr_name={name; tag_type=None}}} when name <> "[]" -> E.str name | Const_int { i; comment = Pt_constructor {cstr_name={tag_type = Some t}}} -> diff --git a/jscomp/core/lam_compile_primitive.ml b/jscomp/core/lam_compile_primitive.ml index 99d092d702..b25269aaec 100644 --- a/jscomp/core/lam_compile_primitive.ml +++ b/jscomp/core/lam_compile_primitive.ml @@ -95,14 +95,14 @@ let translate output_prefix loc (cxt : Lam_compile_context.t) match args with | [ e ] -> ( match e.expression_desc with - | Var _ | Undefined | Null -> Js_of_lam_option.null_to_opt e + | Var _ | Undefined _ | Null -> Js_of_lam_option.null_to_opt e | _ -> E.runtime_call Js_runtime_modules.option "null_to_opt" args) | _ -> assert false) | Pundefined_to_opt -> ( match args with | [ e ] -> ( match e.expression_desc with - | Var _ | Undefined | Null -> Js_of_lam_option.undef_to_opt e + | Var _ | Undefined _ | Null -> Js_of_lam_option.undef_to_opt e | _ -> E.runtime_call Js_runtime_modules.option "undefined_to_opt" args) | _ -> assert false) @@ -110,7 +110,7 @@ let translate output_prefix loc (cxt : Lam_compile_context.t) match args with | [ e ] -> ( match e.expression_desc with - | Var _ | Undefined | Null -> Js_of_lam_option.null_undef_to_opt e + | Var _ | Undefined _ | Null -> Js_of_lam_option.null_undef_to_opt e | _ -> E.runtime_call Js_runtime_modules.option "nullable_to_opt" args ) | _ -> assert false) diff --git a/jscomp/core/lam_constant_convert.ml b/jscomp/core/lam_constant_convert.ml index fa7f51e504..5e3fa49537 100644 --- a/jscomp/core/lam_constant_convert.ml +++ b/jscomp/core/lam_constant_convert.ml @@ -39,7 +39,7 @@ let rec convert_constant (const : Lambda.structured_constant) : Lam_constant.t = | Const_base (Const_nativeint _) -> assert false | Const_pointer (0, Pt_constructor { name = "()"; const = 1; non_const = 0 }) -> - Const_js_undefined + Const_js_undefined {isUnit = true} | Const_false -> Const_js_false | Const_true -> Const_js_true | Const_pointer (i, p) -> ( diff --git a/jscomp/core/lam_convert.ml b/jscomp/core/lam_convert.ml index a26dad1e07..922184e3a1 100644 --- a/jscomp/core/lam_convert.ml +++ b/jscomp/core/lam_convert.ml @@ -442,7 +442,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : | _ when s = "#null" -> Lam.const Const_js_null | _ when s = "#os_type" -> prim ~primitive:(Pctconst Ostype) ~args:[ unit ] loc - | _ when s = "#undefined" -> Lam.const Const_js_undefined + | _ when s = "#undefined" -> Lam.const (Const_js_undefined {isUnit = false}) | _ when s = "#init_mod" -> ( let args = Ext_list.map args convert_aux in match args with diff --git a/jscomp/core/lam_eta_conversion.ml b/jscomp/core/lam_eta_conversion.ml index 25f5bd1957..a92639f1f2 100644 --- a/jscomp/core/lam_eta_conversion.ml +++ b/jscomp/core/lam_eta_conversion.ml @@ -44,7 +44,7 @@ let transform_under_supply n ap_info fn args = | Lconst ( Const_int _ | Const_char _ | Const_string _ | Const_float _ | Const_int64 _ | Const_pointer _ | Const_js_true | Const_js_false - | Const_js_undefined ) + | Const_js_undefined _ ) | Lprim { primitive = Pfield (_, Fld_module _); _ } | Lfunction _ -> (lam :: acc, bind) diff --git a/jscomp/core/lam_pass_lets_dce.ml b/jscomp/core/lam_pass_lets_dce.ml index 618526706a..b9459eb168 100644 --- a/jscomp/core/lam_pass_lets_dce.ml +++ b/jscomp/core/lam_pass_lets_dce.ml @@ -53,7 +53,7 @@ let lets_helper (count_var : Ident.t -> Lam_pass_count.used_info) lam : Lam.t = (( Const_int _ | Const_char _ | Const_float _ ) - | Const_pointer _ |Const_js_true | Const_js_false | Const_js_undefined) (* could be poly-variant [`A] -> [65a]*) + | Const_pointer _ |Const_js_true | Const_js_false | Const_js_undefined _) (* could be poly-variant [`A] -> [65a]*) | Lprim {primitive = Pfield (_); args = [ Lglobal_module _ diff --git a/jscomp/core/lam_pass_remove_alias.ml b/jscomp/core/lam_pass_remove_alias.ml index 9ad2ef7f9e..4889d1c268 100644 --- a/jscomp/core/lam_pass_remove_alias.ml +++ b/jscomp/core/lam_pass_remove_alias.ml @@ -33,7 +33,7 @@ let id_is_for_sure_true_in_boolean (tbl : Lam_stats.ident_tbl) id = Eval_true | Some (Constant (Const_int { i })) -> if i = 0l then Eval_false else Eval_true - | Some (Constant (Const_js_false | Const_js_null | Const_js_undefined)) -> + | Some (Constant (Const_js_false | Const_js_null | Const_js_undefined _)) -> Eval_false | Some ( Constant _ | Module _ | FunctionId _ | Exception | Parameter | NA diff --git a/jscomp/core/lam_print.ml b/jscomp/core/lam_print.ml index 82bbf31b48..f7390234c5 100644 --- a/jscomp/core/lam_print.ml +++ b/jscomp/core/lam_print.ml @@ -19,7 +19,7 @@ let rec struct_const ppf (cst : Lam_constant.t) = | Const_js_false -> fprintf ppf "#false" | Const_js_null -> fprintf ppf "#null" | Const_module_alias -> fprintf ppf "#alias" - | Const_js_undefined -> fprintf ppf "#undefined" + | Const_js_undefined _ -> fprintf ppf "#undefined" | Const_int { i } -> fprintf ppf "%ld" i | Const_char i -> fprintf ppf "%s" (Ext_util.string_of_int_as_char i) | Const_string { s } -> fprintf ppf "%S" s diff --git a/jscomp/core/lam_stats_export.ml b/jscomp/core/lam_stats_export.ml index d7fcc61f0f..c4b98bbb87 100644 --- a/jscomp/core/lam_stats_export.ml +++ b/jscomp/core/lam_stats_export.ml @@ -55,7 +55,7 @@ let values_of_export (meta : Lam_stats.t) (export_map : Lam.t Map_ident.t) : match optlam with | Some (Lconst - ( Const_js_null | Const_js_undefined | Const_js_true + ( Const_js_null | Const_js_undefined _ | Const_js_true | Const_js_false )) | None -> optlam diff --git a/jscomp/frontend/lam_constant.ml b/jscomp/frontend/lam_constant.ml index 26cbb04b66..346dc02368 100644 --- a/jscomp/frontend/lam_constant.ml +++ b/jscomp/frontend/lam_constant.ml @@ -42,7 +42,7 @@ let string_of_pointer_info (x : pointer_info) : string option = type t = | Const_js_null - | Const_js_undefined + | Const_js_undefined of {isUnit: bool} | Const_js_true | Const_js_false | Const_int of {i: int32; comment: pointer_info} @@ -63,7 +63,7 @@ let rec eq_approx (x : t) (y : t) = match x with | Const_module_alias -> y = Const_module_alias | Const_js_null -> y = Const_js_null - | Const_js_undefined -> y = Const_js_undefined + | Const_js_undefined b -> y = Const_js_undefined b | Const_js_true -> y = Const_js_true | Const_js_false -> y = Const_js_false | Const_int ix -> ( @@ -104,4 +104,4 @@ let rec eq_approx (x : t) (y : t) = | Const_some iy -> eq_approx ix iy | _ -> false) -let lam_none : t = Const_js_undefined +let lam_none : t = Const_js_undefined {isUnit = false} diff --git a/jscomp/frontend/lam_constant.mli b/jscomp/frontend/lam_constant.mli index e4fd1c5a5f..3426b9a466 100644 --- a/jscomp/frontend/lam_constant.mli +++ b/jscomp/frontend/lam_constant.mli @@ -38,7 +38,7 @@ val string_of_pointer_info : pointer_info -> string option type t = | Const_js_null - | Const_js_undefined + | Const_js_undefined of {isUnit: bool} | Const_js_true | Const_js_false | Const_int of {i: int32; comment: pointer_info} diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index e950e7f1d5..0ee038afc0 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -574,7 +574,7 @@ function test(t) { case "string" : return t; case "function" : - return t(undefined); + return t(); } } diff --git a/jscomp/test/alias_test.js b/jscomp/test/alias_test.js index 924eb499f8..0ea3140892 100644 --- a/jscomp/test/alias_test.js +++ b/jscomp/test/alias_test.js @@ -17,7 +17,7 @@ function ff(param) { return "cool " + a22; } -var a23 = ff(undefined); +var a23 = ff(); var a15 = a10; diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index 6b77ece736..0c674d3b90 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -30,9 +30,9 @@ var arr = [ 3 ]; -var toplevelAwait = await topFoo(undefined); +var toplevelAwait = await topFoo(); -var toplevelAwait2 = Caml_array.get(arr, await topFoo(undefined)); +var toplevelAwait2 = Caml_array.get(arr, await topFoo()); exports.next = next; exports.useNext = useNext; diff --git a/jscomp/test/async_inline.js b/jscomp/test/async_inline.js index 0e2191d0fa..1c891d0c22 100644 --- a/jscomp/test/async_inline.js +++ b/jscomp/test/async_inline.js @@ -8,7 +8,7 @@ async function willBeInlined(param) { return 3; } -var inlined = willBeInlined(undefined); +var inlined = willBeInlined(); function wrapSomethingAsync(param) { ((async function (param) { @@ -21,7 +21,7 @@ function wrapSomethingAsync2(param) { ((async function (param) { var test = await Promise.resolve("Test"); console.log(test); - })(undefined)); + })()); } async function doSomethingAsync(someAsyncFunction) { diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index 92e4100b44..a2314104bf 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -361,7 +361,7 @@ function random(param) { function random_vars(n) { var vars = Caml_array.make(n, false); for(var i = 0; i < n; ++i){ - Caml_array.set(vars, i, random(undefined)); + Caml_array.set(vars, i, random()); } return vars; } @@ -411,7 +411,7 @@ function main(param) { }; } -main(undefined); +main(); var initSize_1 = 8191; diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index bd6f9c2804..38ca9b8632 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -59,7 +59,7 @@ function f2(param) { console.log(Pervasives.string_of_float(v)); } -f2(undefined); +f2(); exports.map = map; exports.init = init; diff --git a/jscomp/test/bs_MapInt_test.js b/jscomp/test/bs_MapInt_test.js index affc4e0246..7dea07a710 100644 --- a/jscomp/test/bs_MapInt_test.js +++ b/jscomp/test/bs_MapInt_test.js @@ -25,7 +25,7 @@ function test(param) { should(Belt_MapInt.isEmpty(m)); } -test(undefined); +test(); var M; diff --git a/jscomp/test/bs_auto_uncurry.js b/jscomp/test/bs_auto_uncurry.js index 7713d21050..31f7a653f2 100644 --- a/jscomp/test/bs_auto_uncurry.js +++ b/jscomp/test/bs_auto_uncurry.js @@ -122,7 +122,7 @@ function unit_magic(param) { return 3; } -var f_unit_magic = unit_magic(undefined); +var f_unit_magic = unit_magic(); function hh(xs) { return function (param) { diff --git a/jscomp/test/bs_hashtbl_string_test.js b/jscomp/test/bs_hashtbl_string_test.js index 66a8c76044..f747ef5b4e 100644 --- a/jscomp/test/bs_hashtbl_string_test.js +++ b/jscomp/test/bs_hashtbl_string_test.js @@ -294,7 +294,7 @@ function bench7(param) { console.time("bs_hashtbl_string_test.res 181"); -bench7(undefined); +bench7(); console.timeEnd("bs_hashtbl_string_test.res 181"); diff --git a/jscomp/test/bs_rbset_int_bench.js b/jscomp/test/bs_rbset_int_bench.js index 84b9732348..c26328a964 100644 --- a/jscomp/test/bs_rbset_int_bench.js +++ b/jscomp/test/bs_rbset_int_bench.js @@ -47,7 +47,7 @@ function bench(param) { console.time("bs_rbset_int_bench.res 24"); -bench(undefined); +bench(); console.timeEnd("bs_rbset_int_bench.res 24"); diff --git a/jscomp/test/bs_set_bench.js b/jscomp/test/bs_set_bench.js index f0583c36bd..c522372a1a 100644 --- a/jscomp/test/bs_set_bench.js +++ b/jscomp/test/bs_set_bench.js @@ -47,7 +47,7 @@ function bench(param) { console.time("bs_set_bench.res 24"); -bench(undefined); +bench(); console.timeEnd("bs_set_bench.res 24"); diff --git a/jscomp/test/bs_unwrap_test.js b/jscomp/test/bs_unwrap_test.js index 215b5d5d5e..b020cf41f4 100644 --- a/jscomp/test/bs_unwrap_test.js +++ b/jscomp/test/bs_unwrap_test.js @@ -30,7 +30,7 @@ var arg_pair = { console.log(arg_pair.VAL); -console.log(undefined); +console.log(); console.log(1, undefined); diff --git a/jscomp/test/const_block_test.js b/jscomp/test/const_block_test.js index 6d60450f1f..0d6830a09f 100644 --- a/jscomp/test/const_block_test.js +++ b/jscomp/test/const_block_test.js @@ -35,7 +35,7 @@ function h(param) { } function g(param) { - f(undefined); + f(); return { TAG: "Eq", _0: [ diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 3fc32e65a8..96d22f2c4a 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -81,7 +81,7 @@ Mt.from_pair_suites("Cps_test", { return { TAG: "Eq", _0: 55, - _1: test(undefined) + _1: test() }; }) ], @@ -92,7 +92,7 @@ Mt.from_pair_suites("Cps_test", { return { TAG: "Eq", _0: 15, - _1: test_closure(undefined) + _1: test_closure() }; }) ], @@ -103,7 +103,7 @@ Mt.from_pair_suites("Cps_test", { return { TAG: "Eq", _0: 30, - _1: test_closure2(undefined) + _1: test_closure2() }; }) ], diff --git a/jscomp/test/demo_int_map.js b/jscomp/test/demo_int_map.js index 9b9d5aedc6..8e4a314c90 100644 --- a/jscomp/test/demo_int_map.js +++ b/jscomp/test/demo_int_map.js @@ -160,6 +160,6 @@ function test(param) { } } -test(undefined); +test(); /* Not a pure module */ diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index 3db1c75c36..123a360b94 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -60,7 +60,7 @@ function f2(param) { console.log(Pervasives.string_of_float(v)); } -f2(undefined); +f2(); var suites = { contents: /* [] */0 diff --git a/jscomp/test/event_ffi.js b/jscomp/test/event_ffi.js index f68c99ff36..e422d719e3 100644 --- a/jscomp/test/event_ffi.js +++ b/jscomp/test/event_ffi.js @@ -5,11 +5,11 @@ var List = require("../../lib/js/list.js"); var Curry = require("../../lib/js/curry.js"); function h0(x) { - return x(undefined); + return x(); } function h00(x) { - return x(undefined); + return x(); } function h1(x, y) { diff --git a/jscomp/test/exception_raise_test.js b/jscomp/test/exception_raise_test.js index 48138dac16..6ea49475de 100644 --- a/jscomp/test/exception_raise_test.js +++ b/jscomp/test/exception_raise_test.js @@ -188,7 +188,7 @@ function eq(loc, x, y) { } try { - ((()=>{throw 2})(undefined)); + ((()=>{throw 2})()); } catch (raw_e$2){ var e = Caml_js_exceptions.internalToOCamlException(raw_e$2); diff --git a/jscomp/test/exception_rebound_err_test.js b/jscomp/test/exception_rebound_err_test.js index 92e5dc1952..40ffd42b90 100644 --- a/jscomp/test/exception_rebound_err_test.js +++ b/jscomp/test/exception_rebound_err_test.js @@ -79,7 +79,7 @@ function f(g) { } } -eq("File \"exception_rebound_err_test.res\", line 31, characters 3-10", test_js_error4(undefined), 7); +eq("File \"exception_rebound_err_test.res\", line 31, characters 3-10", test_js_error4(), 7); Mt.from_pair_suites("Exception_rebound_err_test", suites.contents); diff --git a/jscomp/test/ext_filename_test.js b/jscomp/test/ext_filename_test.js index 65c301b886..229a506941 100644 --- a/jscomp/test/ext_filename_test.js +++ b/jscomp/test/ext_filename_test.js @@ -23,7 +23,7 @@ var node_current = "."; var cwd = { LAZY_DONE: false, VAL: (function () { - return Caml_sys.sys_getcwd(undefined); + return Caml_sys.sys_getcwd(); }) }; diff --git a/jscomp/test/ffi_arity_test.js b/jscomp/test/ffi_arity_test.js index 410aaca3b1..500d287b13 100644 --- a/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/ffi_arity_test.js @@ -55,7 +55,7 @@ function fff(param) { } function g() { - fff(undefined); + fff(); } function abc(x, y, z) { @@ -66,7 +66,7 @@ function abc(x, y, z) { var abc_u = abc; -fff(undefined); +fff(); Mt.from_pair_suites("Ffi_arity_test", { hd: [ diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 7571c529bb..9b6a0b1e22 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -276,7 +276,7 @@ var suites_1 = { return { TAG: "Eq", _0: 84, - _1: for_7(undefined) + _1: for_7() }; }) ], @@ -287,7 +287,7 @@ var suites_1 = { return { TAG: "Eq", _0: 294, - _1: for_8(undefined) + _1: for_8() }; }) ], @@ -307,7 +307,7 @@ var suites_1 = { ], 5 ]], - _1: for_9(undefined) + _1: for_9() }; }) ], diff --git a/jscomp/test/for_side_effect_test.js b/jscomp/test/for_side_effect_test.js index c23e93c0cb..e770b02941 100644 --- a/jscomp/test/for_side_effect_test.js +++ b/jscomp/test/for_side_effect_test.js @@ -25,7 +25,7 @@ var suites_0 = [ return { TAG: "Eq", _0: 10, - _1: test2(undefined) + _1: test2() }; }) ]; diff --git a/jscomp/test/fun_pattern_match.js b/jscomp/test/fun_pattern_match.js index ee24bdd38e..25975a53c3 100644 --- a/jscomp/test/fun_pattern_match.js +++ b/jscomp/test/fun_pattern_match.js @@ -69,7 +69,7 @@ function r(param) { return x; } -var match = r(undefined); +var match = r(); var v = Curry._1(match.VAL, undefined); diff --git a/jscomp/test/functor_app_test.js b/jscomp/test/functor_app_test.js index b3cb51dc08..635ae811b6 100644 --- a/jscomp/test/functor_app_test.js +++ b/jscomp/test/functor_app_test.js @@ -39,7 +39,7 @@ eq("File \"functor_app_test.res\", line 15, characters 3-10", Curry._2(Y0.h, 1, eq("File \"functor_app_test.res\", line 16, characters 3-10", Curry._2(Y1.h, 2, 3), 6); -var v = Functor_def.$$return(undefined); +var v = Functor_def.$$return(); eq("File \"functor_app_test.res\", line 20, characters 3-10", v, 2); diff --git a/jscomp/test/global_module_alias_test.js b/jscomp/test/global_module_alias_test.js index 9595de9a20..991a40febb 100644 --- a/jscomp/test/global_module_alias_test.js +++ b/jscomp/test/global_module_alias_test.js @@ -110,9 +110,9 @@ function xx(param) { return List; } -eq("File \"global_module_alias_test.res\", line 80, characters 12-19", g(undefined), 4); +eq("File \"global_module_alias_test.res\", line 80, characters 12-19", g(), 4); -var V = xx(undefined); +var V = xx(); eq("File \"global_module_alias_test.res\", line 84, characters 5-12", Curry._1(V.length, { hd: 1, @@ -127,7 +127,7 @@ eq("File \"global_module_alias_test.res\", line 84, characters 5-12", Curry._1(V eq("File \"global_module_alias_test.res\", line 85, characters 5-12", v.contents, 15); -var H$1 = f(undefined); +var H$1 = f(); eq("File \"global_module_alias_test.res\", line 87, characters 5-12", Curry._1(H$1.length, { hd: 1, diff --git a/jscomp/test/gpr_1409_test.js b/jscomp/test/gpr_1409_test.js index 9d9dc6ae81..80826b9193 100644 --- a/jscomp/test/gpr_1409_test.js +++ b/jscomp/test/gpr_1409_test.js @@ -58,9 +58,9 @@ function make(foo) { }; } -var a_ = make(undefined)(undefined); +var a_ = make(undefined)(); -var b_ = make(42)(undefined); +var b_ = make(42)(); eq("File \"gpr_1409_test.res\", line 26, characters 3-10", b_.foo, "42"); diff --git a/jscomp/test/gpr_1817_test.js b/jscomp/test/gpr_1817_test.js index 13a831129e..16a623257e 100644 --- a/jscomp/test/gpr_1817_test.js +++ b/jscomp/test/gpr_1817_test.js @@ -39,7 +39,7 @@ function f(param) { ]; } -var match = f(undefined); +var match = f(); var a2 = match[2]; diff --git a/jscomp/test/gpr_2682_test.js b/jscomp/test/gpr_2682_test.js index 2696a65731..a169156607 100644 --- a/jscomp/test/gpr_2682_test.js +++ b/jscomp/test/gpr_2682_test.js @@ -43,7 +43,7 @@ forIn({ var f3 = (()=>true); -var bbbb = f3(undefined); +var bbbb = f3(); if (!bbbb) { throw { diff --git a/jscomp/test/gpr_2731_test.js b/jscomp/test/gpr_2731_test.js index 9dcd6a23ee..a12d56ab70 100644 --- a/jscomp/test/gpr_2731_test.js +++ b/jscomp/test/gpr_2731_test.js @@ -14,9 +14,9 @@ function g(param) { return 1; } -var c = g(undefined); +var c = g(); -var d = g(undefined); +var d = g(); exports.f = f; exports.a = a; diff --git a/jscomp/test/gpr_3697_test.js b/jscomp/test/gpr_3697_test.js index e5990aecb7..8f637814e5 100644 --- a/jscomp/test/gpr_3697_test.js +++ b/jscomp/test/gpr_3697_test.js @@ -9,7 +9,7 @@ function fix(param) { _0: { LAZY_DONE: false, VAL: (function () { - return fix(undefined); + return fix(); }) } }; diff --git a/jscomp/test/hashtbl_test.js b/jscomp/test/hashtbl_test.js index dd2a67101a..afb8268a04 100644 --- a/jscomp/test/hashtbl_test.js +++ b/jscomp/test/hashtbl_test.js @@ -61,7 +61,7 @@ var suites_0 = [ tl: /* [] */0 } }, - _1: f(undefined) + _1: f() }; }) ]; diff --git a/jscomp/test/imm_map_bench.js b/jscomp/test/imm_map_bench.js index a54dbd0ca9..63b569c7c7 100644 --- a/jscomp/test/imm_map_bench.js +++ b/jscomp/test/imm_map_bench.js @@ -46,13 +46,13 @@ function test2(param) { console.time("imm_map_bench.res 43"); -test(undefined); +test(); console.timeEnd("imm_map_bench.res 43"); console.time("imm_map_bench.res 44"); -test2(undefined); +test2(); console.timeEnd("imm_map_bench.res 44"); diff --git a/jscomp/test/incomplete_toplevel_test.js b/jscomp/test/incomplete_toplevel_test.js index c8a4a699e9..701ec21cf2 100644 --- a/jscomp/test/incomplete_toplevel_test.js +++ b/jscomp/test/incomplete_toplevel_test.js @@ -11,7 +11,7 @@ function f(param) { ]; } -var match = f(undefined); +var match = f(); var a = match[0]; diff --git a/jscomp/test/io_test.js b/jscomp/test/io_test.js index 58e4915e0a..61e043cbb0 100644 --- a/jscomp/test/io_test.js +++ b/jscomp/test/io_test.js @@ -4,9 +4,9 @@ function f(param) { console.error("x"); - console.log(undefined); + console.log(); console.log("hi"); - console.log(undefined); + console.log(); } exports.f = f; diff --git a/jscomp/test/js_null_test.js b/jscomp/test/js_null_test.js index 7cf7afa641..2143ef0a8e 100644 --- a/jscomp/test/js_null_test.js +++ b/jscomp/test/js_null_test.js @@ -23,7 +23,7 @@ var suites_1 = { return { TAG: "Eq", _0: Caml_option.some(undefined), - _1: Caml_option.some(undefined) + _1: Caml_option.some() }; }) ], diff --git a/jscomp/test/jsoo_400_test.js b/jscomp/test/jsoo_400_test.js index 24e1328720..fa8e5fdc63 100644 --- a/jscomp/test/jsoo_400_test.js +++ b/jscomp/test/jsoo_400_test.js @@ -22,7 +22,7 @@ Mt.from_pair_suites("Jsoo_400_test", { return { TAG: "ThrowAny", _0: (function (param) { - u(undefined); + u(); }) }; }) diff --git a/jscomp/test/lazy_test.js b/jscomp/test/lazy_test.js index 02ff1e0d02..b973dbdc5e 100644 --- a/jscomp/test/lazy_test.js +++ b/jscomp/test/lazy_test.js @@ -188,7 +188,7 @@ Mt.from_pair_suites("Lazy_test", { (function (param) { return { TAG: "Eq", - _0: lazy_test(undefined), + _0: lazy_test(), _1: [ 3, 32 diff --git a/jscomp/test/loop_regression_test.js b/jscomp/test/loop_regression_test.js index 6bbb9e3a86..4cee928188 100644 --- a/jscomp/test/loop_regression_test.js +++ b/jscomp/test/loop_regression_test.js @@ -27,7 +27,7 @@ var suites_0 = [ return { TAG: "Eq", _0: 55, - _1: f(undefined) + _1: f() }; }) ]; diff --git a/jscomp/test/mario_game.js b/jscomp/test/mario_game.js index 31ae3eb138..95150eadbc 100644 --- a/jscomp/test/mario_game.js +++ b/jscomp/test/mario_game.js @@ -847,7 +847,7 @@ function make$2($staropt$star, $staropt$star$1, spawnable, context, param) { var dir = $staropt$star$1 !== undefined ? $staropt$star$1 : "Left"; var spr = make(spawnable, dir, context); var params = make_type$2(spawnable); - var id$1 = id !== undefined ? id : new_id(undefined); + var id$1 = id !== undefined ? id : new_id(); var obj = { params: params, pos: { @@ -2253,7 +2253,7 @@ function translate_keys(param) { function run_update_collid(state, collid, all_collids) { if (collid.TAG === "Player") { var o = collid._2; - var keys = translate_keys(undefined); + var keys = translate_keys(); o.crouch = false; var match = update_player(o, keys, state.ctx); var player; @@ -3313,7 +3313,7 @@ function generate(w, h, context) { } function init(param) { - Random.self_init(undefined); + Random.self_init(); } var Procedural_generator = { @@ -3326,7 +3326,7 @@ var loadCount = { }; function load(param) { - Random.self_init(undefined); + Random.self_init(); var canvas_id = "canvas"; var el = document.getElementById(canvas_id); var canvas; @@ -3343,7 +3343,7 @@ function load(param) { var context = Curry._1(canvas.getContext, "2d"); document.addEventListener("keydown", keydown, true); document.addEventListener("keyup", keyup, true); - Random.self_init(undefined); + Random.self_init(); update_loop(canvas, generate(2400, 256, context), [ 2400, 256 @@ -3354,7 +3354,7 @@ function load(param) { function inc_counter(param) { loadCount.contents = loadCount.contents + 1 | 0; if (loadCount.contents === 4) { - return load(undefined); + return load(); } } @@ -3365,7 +3365,7 @@ function preload(param) { var img = document.createElement("img"); img.src = img_src$1; img.addEventListener("load", (function (ev) { - inc_counter(undefined); + inc_counter(); return true; }), true); }), { @@ -3384,7 +3384,7 @@ function preload(param) { } window.onload = (function (param) { - preload(undefined); + preload(); return true; }); diff --git a/jscomp/test/mt.js b/jscomp/test/mt.js index c71b21abe4..ba3c501e1a 100644 --- a/jscomp/test/mt.js +++ b/jscomp/test/mt.js @@ -201,7 +201,7 @@ var from_pair_suites = (function from_pair_suites(name, suites) { }); -var val_unit = Promise.resolve(undefined); +var val_unit = Promise.resolve(); var from_promise_suites = (function from_promise_suites(name, suites) { var match = $$Array.to_list(Process.argv); @@ -230,7 +230,7 @@ var from_promise_suites = (function from_promise_suites(name, suites) { function old_from_promise_suites_donotuse(name, suites) { var match = $$Array.to_list(Process.argv); if (match) { - if (is_mocha(undefined)) { + if (is_mocha()) { describe(name, (function () { List.iter((function (param) { var code = param[1]; diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index d3ca5ba7f6..a93a34a8c1 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -3490,7 +3490,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { Error: new Error() }; } - var c = get(undefined); + var c = get(); switch (c) { case 48 : case 49 : @@ -3646,7 +3646,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { Error: new Error() }; } - var c$1 = get(undefined); + var c$1 = get(); if (c$1 >= 64) { if (c$1 !== 92) { if (c$1 !== 123) { @@ -3693,7 +3693,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (i.contents === l) { return ; } - var d = get(undefined); + var d = get(); if (d > 57 || d < 48) { i.contents = i.contents - 1 | 0; return ; @@ -3704,7 +3704,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (i.contents === l) { return i$1; } - var d$1 = get(undefined); + var d$1 = get(); if (d$1 > 57 || d$1 < 48) { i.contents = i.contents - 1 | 0; return i$1; @@ -3728,7 +3728,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { Error: new Error() }; } - var c = get(undefined); + var c = get(); if (c === /* '[' */91) { if (accept(/* '=' */61)) { throw { @@ -3819,7 +3819,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { Error: new Error() }; } - var c$1 = get(undefined); + var c$1 = get(); if (!accept(/* '.' */46)) { throw { RE_EXN_ID: Not_supported, @@ -3843,7 +3843,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { VAL: c }; } - var c$2 = get(undefined); + var c$2 = get(); if (c$2 >= 58) { if (c$2 >= 123) { return { @@ -4022,7 +4022,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (s !== /* [] */0 && accept(/* ']' */93)) { return s; } - var match = $$char(undefined); + var match = $$char(); if (match.NAME === "Char") { var c = match.VAL; if (accept(/* '-' */45)) { @@ -4047,7 +4047,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { } }; } - var match$1 = $$char(undefined); + var match$1 = $$char(); if (match$1.NAME !== "Char") { return { hd: { @@ -4098,7 +4098,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { }; }; var piece = function (param) { - var r = atom(undefined); + var r = atom(); if (accept(/* '*' */42)) { return greedy_mod(repn(r, 0, undefined)); } @@ -4111,9 +4111,9 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { if (!accept(/* '{' */123)) { return r; } - var i$1 = integer(undefined); + var i$1 = integer(); if (i$1 !== undefined) { - var j = accept(/* ',' */44) ? integer(undefined) : i$1; + var j = accept(/* ',' */44) ? integer() : i$1; if (!accept(/* '}' */125)) { throw { RE_EXN_ID: Parse_error, @@ -4138,7 +4138,7 @@ function parse(multiline, dollar_endonly, dotall, ungreedy, s) { return seq$2(List.rev(left)); } _left = { - hd: piece(undefined), + hd: piece(), tl: left }; continue ; diff --git a/jscomp/test/random_test.js b/jscomp/test/random_test.js index d0f146b030..e32d5eadf9 100644 --- a/jscomp/test/random_test.js +++ b/jscomp/test/random_test.js @@ -33,14 +33,14 @@ function approx(f) { }; } -Mt_global.collect_neq(id, suites, "File \"random_test.res\", line 9, characters 2-9", (Random.self_init(undefined), Random.$$int(10000)), (Random.self_init(undefined), Random.$$int(1000))); +Mt_global.collect_neq(id, suites, "File \"random_test.res\", line 9, characters 2-9", (Random.self_init(), Random.$$int(10000)), (Random.self_init(), Random.$$int(1000))); Random.init(0); var v = Caml_array.make(10, false); for(var i = 0; i <= 9; ++i){ - Caml_array.set(v, i, Random.bool(undefined)); + Caml_array.set(v, i, Random.bool()); } Mt_global.collect_eq(id, suites, "File \"random_test.res\", line 28, characters 12-19", v, [ @@ -63,7 +63,7 @@ var h = Random.int64([ 3 ]); -var vv = Random.bits(undefined); +var vv = Random.bits(); var xx = Random.$$float(3.0); diff --git a/jscomp/test/raw_hash_tbl_bench.js b/jscomp/test/raw_hash_tbl_bench.js index b3872389b4..6252b105ba 100644 --- a/jscomp/test/raw_hash_tbl_bench.js +++ b/jscomp/test/raw_hash_tbl_bench.js @@ -27,7 +27,7 @@ function bench(param) { } } -bench(undefined); +bench(); var count = 1000000; diff --git a/jscomp/test/raw_output_test.js b/jscomp/test/raw_output_test.js index 3facdda2aa..515fb69a3f 100644 --- a/jscomp/test/raw_output_test.js +++ b/jscomp/test/raw_output_test.js @@ -7,11 +7,11 @@ function mk(fn) { return Curry._1(fn, undefined); } -(((_)=> console.log('should works'))(undefined)); +(((_)=> console.log('should works'))()); console.log((function () { return 1; - })(undefined)); + })()); exports.mk = mk; /* Not a pure module */ diff --git a/jscomp/test/reasonReactRouter.js b/jscomp/test/reasonReactRouter.js index c8f193aa8f..708d608960 100644 --- a/jscomp/test/reasonReactRouter.js +++ b/jscomp/test/reasonReactRouter.js @@ -129,9 +129,9 @@ function urlNotEqual(a, b) { function url(param) { return { - path: path(undefined), - hash: hash(undefined), - search: search(undefined) + path: path(), + hash: hash(), + search: search() }; } @@ -143,7 +143,7 @@ function watchUrl(callback) { }; } var watcherID = function (param) { - Curry._1(callback, url(undefined)); + Curry._1(callback, url()); }; $$window.addEventListener("popstate", watcherID); return watcherID; @@ -163,7 +163,7 @@ function useUrl(serverUrl, param) { if (serverUrl !== undefined) { return serverUrl; } else { - return url(undefined); + return url(); } }); var setUrl = match[1]; @@ -174,7 +174,7 @@ function useUrl(serverUrl, param) { return url; })); }); - var newUrl = url(undefined); + var newUrl = url(); if (urlNotEqual(newUrl, url$1)) { Curry._1(setUrl, (function (param) { return newUrl; diff --git a/jscomp/test/rec_fun_test.js b/jscomp/test/rec_fun_test.js index 5333ec8b7e..34a5cbd997 100644 --- a/jscomp/test/rec_fun_test.js +++ b/jscomp/test/rec_fun_test.js @@ -49,7 +49,7 @@ function g(param) { console.log(String(next(0, true))); } -g(undefined); +g(); var x = {}; diff --git a/jscomp/test/stack_test.js b/jscomp/test/stack_test.js index 9c3e68f93d..dc7dc1d548 100644 --- a/jscomp/test/stack_test.js +++ b/jscomp/test/stack_test.js @@ -42,7 +42,7 @@ var suites_0 = [ } } }, - _1: v(undefined) + _1: v() }; }) ]; diff --git a/jscomp/test/stream_parser_test.js b/jscomp/test/stream_parser_test.js index 5069483368..d6b499381b 100644 --- a/jscomp/test/stream_parser_test.js +++ b/jscomp/test/stream_parser_test.js @@ -32,12 +32,12 @@ function parse(token) { } }; var parse_atom = function (param) { - var n = token$1(undefined); + var n = token$1(); switch (n.TAG) { case "Kwd" : if (n._0 === "(") { - var v = parse_expr_aux(parse_term_aux(parse_atom(undefined))); - var match = token$1(undefined); + var v = parse_expr_aux(parse_term_aux(parse_atom())); + var match = token$1(); if (match.TAG === "Kwd") { if (match._0 === ")") { return v; @@ -72,13 +72,13 @@ function parse(token) { } }; var parse_term_aux = function (e1) { - var e = token$1(undefined); + var e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { case "*" : - return Math.imul(e1, parse_term_aux(parse_atom(undefined))); + return Math.imul(e1, parse_term_aux(parse_atom())); case "/" : - return Caml_int32.div(e1, parse_term_aux(parse_atom(undefined))); + return Caml_int32.div(e1, parse_term_aux(parse_atom())); default: Queue.push(e, look_ahead); return e1; @@ -89,13 +89,13 @@ function parse(token) { } }; var parse_expr_aux = function (e1) { - var e = token$1(undefined); + var e = token$1(); if (e.TAG === "Kwd") { switch (e._0) { case "+" : - return e1 + parse_expr_aux(parse_term_aux(parse_atom(undefined))) | 0; + return e1 + parse_expr_aux(parse_term_aux(parse_atom())) | 0; case "-" : - return e1 - parse_expr_aux(parse_term_aux(parse_atom(undefined))) | 0; + return e1 - parse_expr_aux(parse_term_aux(parse_atom())) | 0; default: Queue.push(e, look_ahead); return e1; @@ -105,7 +105,7 @@ function parse(token) { return e1; } }; - var r = parse_expr_aux(parse_term_aux(parse_atom(undefined))); + var r = parse_expr_aux(parse_term_aux(parse_atom())); return [ r, Queue.fold((function (acc, x) { @@ -167,14 +167,14 @@ function l_parse(token) { var parse_f_aux = function (_a) { while(true) { var a = _a; - var t = token$1(undefined); + var t = token$1(); if (t.TAG === "Kwd") { switch (t._0) { case "*" : - _a = Math.imul(a, parse_f(undefined)); + _a = Math.imul(a, parse_f()); continue ; case "/" : - _a = Caml_int32.div(a, parse_f(undefined)); + _a = Caml_int32.div(a, parse_f()); continue ; default: Queue.push(t, look_ahead); @@ -187,12 +187,12 @@ function l_parse(token) { }; }; var parse_f = function (param) { - var i = token$1(undefined); + var i = token$1(); switch (i.TAG) { case "Kwd" : if (i._0 === "(") { - var v = parse_t_aux(parse_f_aux(parse_f(undefined))); - var t = token$1(undefined); + var v = parse_t_aux(parse_f_aux(parse_f())); + var t = token$1(); if (t.TAG === "Kwd") { if (t._0 === ")") { return v; @@ -227,14 +227,14 @@ function l_parse(token) { var parse_t_aux = function (_a) { while(true) { var a = _a; - var t = token$1(undefined); + var t = token$1(); if (t.TAG === "Kwd") { switch (t._0) { case "+" : - _a = a + parse_f_aux(parse_f(undefined)) | 0; + _a = a + parse_f_aux(parse_f()) | 0; continue ; case "-" : - _a = a - parse_f_aux(parse_f(undefined)) | 0; + _a = a - parse_f_aux(parse_f()) | 0; continue ; default: Queue.push(t, look_ahead); @@ -246,7 +246,7 @@ function l_parse(token) { } }; }; - var r = parse_t_aux(parse_f_aux(parse_f(undefined))); + var r = parse_t_aux(parse_f_aux(parse_f())); return [ r, Queue.fold((function (acc, x) { diff --git a/jscomp/test/tailcall_inline_test.js b/jscomp/test/tailcall_inline_test.js index f1d7923e50..491916a1ab 100644 --- a/jscomp/test/tailcall_inline_test.js +++ b/jscomp/test/tailcall_inline_test.js @@ -30,7 +30,7 @@ var suites_0 = [ (function (param) { return { TAG: "Eq", - _0: f(undefined), + _0: f(), _1: [ 0, 1, diff --git a/jscomp/test/test_closure.js b/jscomp/test/test_closure.js index 0665a00d5c..a9d1b9d69f 100644 --- a/jscomp/test/test_closure.js +++ b/jscomp/test/test_closure.js @@ -23,7 +23,7 @@ function f(param) { return arr; } -var u = f(undefined); +var u = f(); $$Array.iter((function (x) { Curry._1(x, undefined); diff --git a/jscomp/test/test_per.js b/jscomp/test/test_per.js index 4bffdb0292..27edfb87f7 100644 --- a/jscomp/test/test_per.js +++ b/jscomp/test/test_per.js @@ -217,7 +217,7 @@ function open_out_bin(name) { } function flush_all(param) { - var _x = Caml_external_polyfill.resolve("ml_out_channels_list")(undefined); + var _x = Caml_external_polyfill.resolve("ml_out_channels_list")(); while(true) { var x = _x; if (!x) { diff --git a/jscomp/test/test_while_closure.js b/jscomp/test/test_while_closure.js index 6a3ee2d576..430c53070d 100644 --- a/jscomp/test/test_while_closure.js +++ b/jscomp/test/test_while_closure.js @@ -26,7 +26,7 @@ function f(param) { }; } -f(undefined); +f(); $$Array.iter((function (x) { Curry._1(x, undefined); diff --git a/jscomp/test/tramp_fib.js b/jscomp/test/tramp_fib.js index c1ac8e7852..11f7db3f2e 100644 --- a/jscomp/test/tramp_fib.js +++ b/jscomp/test/tramp_fib.js @@ -45,7 +45,7 @@ function iter(_bounce) { if (bounce.TAG === "Continue") { return bounce._0; } - _bounce = bounce._0(undefined); + _bounce = bounce._0(); continue ; }; } diff --git a/jscomp/test/uncurried_default.args.js b/jscomp/test/uncurried_default.args.js index 7ece8cb8ec..1c24e3b6dc 100644 --- a/jscomp/test/uncurried_default.args.js +++ b/jscomp/test/uncurried_default.args.js @@ -103,7 +103,7 @@ function foo3$1(xOpt, yOpt) { var r3$1 = foo3$1(undefined, undefined); function foo(func) { - return func(undefined) + 1 | 0; + return func() + 1 | 0; } var M = { diff --git a/jscomp/test/unit_undefined_test.js b/jscomp/test/unit_undefined_test.js index 2d336c22a1..4a43c971bb 100644 --- a/jscomp/test/unit_undefined_test.js +++ b/jscomp/test/unit_undefined_test.js @@ -54,11 +54,11 @@ function u2(x) { var u3 = Caml_option.some(undefined); -eq("File \"unit_undefined_test.res\", line 41, characters 3-10", Caml_option.some(undefined), Caml_option.some(undefined)); +eq("File \"unit_undefined_test.res\", line 41, characters 3-10", Caml_option.some(), Caml_option.some(undefined)); eq("File \"unit_undefined_test.res\", line 42, characters 3-10", u1, Caml_option.some(undefined)); -eq("File \"unit_undefined_test.res\", line 43, characters 3-10", Caml_option.some(undefined), Caml_option.some(undefined)); +eq("File \"unit_undefined_test.res\", line 43, characters 3-10", Caml_option.some(), Caml_option.some(undefined)); eq("File \"unit_undefined_test.res\", line 44, characters 3-10", u3, Caml_option.some(undefined)); diff --git a/lib/es6/arg.js b/lib/es6/arg.js index 65d286c7d5..082ea58bec 100644 --- a/lib/es6/arg.js +++ b/lib/es6/arg.js @@ -327,7 +327,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist case "Unit" : return Curry._1(f._0, undefined); case "Bool" : - var arg = get_arg(undefined); + var arg = get_arg(); var s$1 = bool_of_string_opt(arg); if (s$1 !== undefined) { Curry._1(f._0, s$1); @@ -343,24 +343,24 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set" : - no_arg(undefined); + no_arg(); f._0.contents = true; return ; case "Clear" : - no_arg(undefined); + no_arg(); f._0.contents = false; return ; case "String" : - var arg$1 = get_arg(undefined); + var arg$1 = get_arg(); Curry._1(f._0, arg$1); - return consume_arg(undefined); + return consume_arg(); case "Set_string" : - f._0.contents = get_arg(undefined); - return consume_arg(undefined); + f._0.contents = get_arg(); + return consume_arg(); case "Int" : - var arg$2 = get_arg(undefined); + var arg$2 = get_arg(); var x = int_of_string_opt(arg$2); if (x !== undefined) { Curry._1(f._0, x); @@ -376,9 +376,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set_int" : - var arg$3 = get_arg(undefined); + var arg$3 = get_arg(); var x$1 = int_of_string_opt(arg$3); if (x$1 !== undefined) { f._0.contents = x$1; @@ -394,9 +394,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Float" : - var arg$4 = get_arg(undefined); + var arg$4 = get_arg(); var x$2 = float_of_string_opt(arg$4); if (x$2 !== undefined) { Curry._1(f._0, x$2); @@ -412,9 +412,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set_float" : - var arg$5 = get_arg(undefined); + var arg$5 = get_arg(); var x$3 = float_of_string_opt(arg$5); if (x$3 !== undefined) { f._0.contents = x$3; @@ -430,15 +430,15 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Tuple" : return List.iter(treat_action, f._0); case "Symbol" : var symb = f._0; - var arg$6 = get_arg(undefined); + var arg$6 = get_arg(); if (List.mem(arg$6, symb)) { Curry._1(f._1, arg$6); - return consume_arg(undefined); + return consume_arg(); } throw { RE_EXN_ID: Stop, @@ -454,7 +454,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist var f$1 = f._0; while(current.contents < (argv.contents.length - 1 | 0)) { Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0)); - consume_arg(undefined); + consume_arg(); }; return ; case "Expand" : @@ -465,9 +465,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - var arg$7 = get_arg(undefined); + var arg$7 = get_arg(); var newarg = Curry._1(f._0, arg$7); - consume_arg(undefined); + consume_arg(); var before = $$Array.sub(argv.contents, 0, current.contents + 1 | 0); var after = $$Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); argv.contents = Caml_array.concat({ diff --git a/lib/es6/camlinternalLazy.js b/lib/es6/camlinternalLazy.js index 7b80d775fb..697cd9e5de 100644 --- a/lib/es6/camlinternalLazy.js +++ b/lib/es6/camlinternalLazy.js @@ -9,7 +9,7 @@ function is_val(l) { var Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined"); function forward_with_closure(blk, closure) { - var result = closure(undefined); + var result = closure(); blk.VAL = result; blk.LAZY_DONE = true; return result; diff --git a/lib/es6/genlex.js b/lib/es6/genlex.js index 18dcf24292..09a9b041b3 100644 --- a/lib/es6/genlex.js +++ b/lib/es6/genlex.js @@ -104,7 +104,7 @@ function make_lexer(keywords) { continue ; case 34 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); return { TAG: "String", _0: string(strm__) @@ -161,12 +161,12 @@ function make_lexer(keywords) { var c$2 = Stream.peek(strm__); if (c$2 !== undefined && !(c$2 > 57 || c$2 < 48)) { Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(/* '-' */45); store(c$2); return number(strm__); } else { - reset_buffer(undefined); + reset_buffer(); store(/* '-' */45); return ident2(strm__); } @@ -265,30 +265,30 @@ function make_lexer(keywords) { return keyword_or_error(c); case 2 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); while(true) { var c$3 = Stream.peek(strm__); if (c$3 === undefined) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } if (c$3 >= 91) { if (c$3 > 122 || c$3 < 95) { if (c$3 > 255 || c$3 < 192) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 === 96) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 >= 48) { if (!(c$3 > 64 || c$3 < 58)) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 !== 39) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } Stream.junk(strm__); store(c$3); @@ -296,12 +296,12 @@ function make_lexer(keywords) { }; case 3 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); return ident2(strm__); case 4 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); return number(strm__); @@ -312,26 +312,26 @@ function make_lexer(keywords) { while(true) { var c = Stream.peek(strm__); if (c === undefined) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } if (c >= 94) { if (c > 125 || c < 95) { if (c >= 127) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c !== 124) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c >= 65) { if (c !== 92) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else { if (c < 33) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } switch (c) { case 34 : @@ -351,7 +351,7 @@ function make_lexer(keywords) { case 56 : case 57 : case 59 : - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); case 33 : case 35 : case 36 : @@ -416,14 +416,14 @@ function make_lexer(keywords) { } return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; }; } } return { TAG: "Int", - _0: Caml_format.int_of_string(get_string(undefined)) + _0: Caml_format.int_of_string(get_string()) }; }; }; @@ -443,13 +443,13 @@ function make_lexer(keywords) { if (c === undefined) { return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; } if (c > 57 || c < 48) { return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; } Stream.junk(strm__); @@ -487,7 +487,7 @@ function make_lexer(keywords) { continue ; } Stream.junk(strm__); - return get_string(undefined); + return get_string(); } throw { RE_EXN_ID: Stream.Failure, diff --git a/lib/es6/hashtbl.js b/lib/es6/hashtbl.js index 71dec6eff7..621cc7b164 100644 --- a/lib/es6/hashtbl.js +++ b/lib/es6/hashtbl.js @@ -42,7 +42,7 @@ function is_randomized(param) { var prng = { LAZY_DONE: false, VAL: (function () { - return Random.State.make_self_init(undefined); + return Random.State.make_self_init(); }) }; diff --git a/lib/es6/parsing.js b/lib/es6/parsing.js index f192934e19..ff983c6466 100644 --- a/lib/es6/parsing.js +++ b/lib/es6/parsing.js @@ -93,12 +93,12 @@ function yyparse(tables, start, lexer, lexbuf) { Error: new Error() }; case "Grow_stacks_1" : - grow_stacks(undefined); + grow_stacks(); _arg = undefined; _cmd = "Stacks_grown_1"; continue ; case "Grow_stacks_2" : - grow_stacks(undefined); + grow_stacks(); _arg = undefined; _cmd = "Stacks_grown_2"; continue ; @@ -191,11 +191,11 @@ function rhs_end_pos(n) { } function symbol_start(param) { - return symbol_start_pos(undefined).pos_cnum; + return symbol_start_pos().pos_cnum; } function symbol_end(param) { - return symbol_end_pos(undefined).pos_cnum; + return symbol_end_pos().pos_cnum; } function rhs_start(n) { diff --git a/lib/es6/pervasivesU.js b/lib/es6/pervasivesU.js index 98659ee37b..66770b5ddb 100644 --- a/lib/es6/pervasivesU.js +++ b/lib/es6/pervasivesU.js @@ -199,13 +199,13 @@ var exit_function = { function at_exit(f) { var g = exit_function.contents; exit_function.contents = (function () { - f(undefined); - g(undefined); + f(); + g(); }); } function exit(retcode) { - exit_function.contents(undefined); + exit_function.contents(); return Caml_sys.sys_exit(retcode); } diff --git a/lib/es6/random.js b/lib/es6/random.js index 2dad856f57..89cc63f188 100644 --- a/lib/es6/random.js +++ b/lib/es6/random.js @@ -52,7 +52,7 @@ function make(seed) { } function make_self_init(param) { - return make(random_seed(undefined)); + return make(random_seed()); } function copy(s) { @@ -240,7 +240,7 @@ function init(seed) { } function self_init(param) { - full_init$1(random_seed(undefined)); + full_init$1(random_seed()); } function get_state(param) { diff --git a/lib/es6/sys.js b/lib/es6/sys.js index 2031b91a13..c40e28b6df 100644 --- a/lib/es6/sys.js +++ b/lib/es6/sys.js @@ -3,9 +3,9 @@ import * as Caml_sys from "./caml_sys.js"; import * as Caml_exceptions from "./caml_exceptions.js"; -var match = Caml_sys.sys_get_argv(undefined); +var match = Caml_sys.sys_get_argv(); -var os_type = Caml_sys.os_type(undefined); +var os_type = Caml_sys.os_type(); var backend_type = { TAG: "Other", @@ -14,9 +14,9 @@ var backend_type = { var big_endian = false; -var unix = Caml_sys.os_type(undefined) === "Unix"; +var unix = Caml_sys.os_type() === "Unix"; -var win32 = Caml_sys.os_type(undefined) === "Win32"; +var win32 = Caml_sys.os_type() === "Win32"; function getenv_opt(s) { var x = typeof process === "undefined" ? undefined : process; diff --git a/lib/js/arg.js b/lib/js/arg.js index 998f7ec0be..caae76bace 100644 --- a/lib/js/arg.js +++ b/lib/js/arg.js @@ -327,7 +327,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist case "Unit" : return Curry._1(f._0, undefined); case "Bool" : - var arg = get_arg(undefined); + var arg = get_arg(); var s$1 = bool_of_string_opt(arg); if (s$1 !== undefined) { Curry._1(f._0, s$1); @@ -343,24 +343,24 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set" : - no_arg(undefined); + no_arg(); f._0.contents = true; return ; case "Clear" : - no_arg(undefined); + no_arg(); f._0.contents = false; return ; case "String" : - var arg$1 = get_arg(undefined); + var arg$1 = get_arg(); Curry._1(f._0, arg$1); - return consume_arg(undefined); + return consume_arg(); case "Set_string" : - f._0.contents = get_arg(undefined); - return consume_arg(undefined); + f._0.contents = get_arg(); + return consume_arg(); case "Int" : - var arg$2 = get_arg(undefined); + var arg$2 = get_arg(); var x = int_of_string_opt(arg$2); if (x !== undefined) { Curry._1(f._0, x); @@ -376,9 +376,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set_int" : - var arg$3 = get_arg(undefined); + var arg$3 = get_arg(); var x$1 = int_of_string_opt(arg$3); if (x$1 !== undefined) { f._0.contents = x$1; @@ -394,9 +394,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Float" : - var arg$4 = get_arg(undefined); + var arg$4 = get_arg(); var x$2 = float_of_string_opt(arg$4); if (x$2 !== undefined) { Curry._1(f._0, x$2); @@ -412,9 +412,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Set_float" : - var arg$5 = get_arg(undefined); + var arg$5 = get_arg(); var x$3 = float_of_string_opt(arg$5); if (x$3 !== undefined) { f._0.contents = x$3; @@ -430,15 +430,15 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - return consume_arg(undefined); + return consume_arg(); case "Tuple" : return List.iter(treat_action, f._0); case "Symbol" : var symb = f._0; - var arg$6 = get_arg(undefined); + var arg$6 = get_arg(); if (List.mem(arg$6, symb)) { Curry._1(f._1, arg$6); - return consume_arg(undefined); + return consume_arg(); } throw { RE_EXN_ID: Stop, @@ -454,7 +454,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist var f$1 = f._0; while(current.contents < (argv.contents.length - 1 | 0)) { Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0)); - consume_arg(undefined); + consume_arg(); }; return ; case "Expand" : @@ -465,9 +465,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist Error: new Error() }; } - var arg$7 = get_arg(undefined); + var arg$7 = get_arg(); var newarg = Curry._1(f._0, arg$7); - consume_arg(undefined); + consume_arg(); var before = $$Array.sub(argv.contents, 0, current.contents + 1 | 0); var after = $$Array.sub(argv.contents, current.contents + 1 | 0, (argv.contents.length - current.contents | 0) - 1 | 0); argv.contents = Caml_array.concat({ diff --git a/lib/js/camlinternalLazy.js b/lib/js/camlinternalLazy.js index 867d359675..f812859e83 100644 --- a/lib/js/camlinternalLazy.js +++ b/lib/js/camlinternalLazy.js @@ -9,7 +9,7 @@ function is_val(l) { var Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined"); function forward_with_closure(blk, closure) { - var result = closure(undefined); + var result = closure(); blk.VAL = result; blk.LAZY_DONE = true; return result; diff --git a/lib/js/genlex.js b/lib/js/genlex.js index 89aa30a1c1..27b3c7d43d 100644 --- a/lib/js/genlex.js +++ b/lib/js/genlex.js @@ -104,7 +104,7 @@ function make_lexer(keywords) { continue ; case 34 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); return { TAG: "String", _0: string(strm__) @@ -161,12 +161,12 @@ function make_lexer(keywords) { var c$2 = Stream.peek(strm__); if (c$2 !== undefined && !(c$2 > 57 || c$2 < 48)) { Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(/* '-' */45); store(c$2); return number(strm__); } else { - reset_buffer(undefined); + reset_buffer(); store(/* '-' */45); return ident2(strm__); } @@ -265,30 +265,30 @@ function make_lexer(keywords) { return keyword_or_error(c); case 2 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); while(true) { var c$3 = Stream.peek(strm__); if (c$3 === undefined) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } if (c$3 >= 91) { if (c$3 > 122 || c$3 < 95) { if (c$3 > 255 || c$3 < 192) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 === 96) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 >= 48) { if (!(c$3 > 64 || c$3 < 58)) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c$3 !== 39) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } Stream.junk(strm__); store(c$3); @@ -296,12 +296,12 @@ function make_lexer(keywords) { }; case 3 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); return ident2(strm__); case 4 : Stream.junk(strm__); - reset_buffer(undefined); + reset_buffer(); store(c); return number(strm__); @@ -312,26 +312,26 @@ function make_lexer(keywords) { while(true) { var c = Stream.peek(strm__); if (c === undefined) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } if (c >= 94) { if (c > 125 || c < 95) { if (c >= 127) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c !== 124) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else if (c >= 65) { if (c !== 92) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } } else { if (c < 33) { - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); } switch (c) { case 34 : @@ -351,7 +351,7 @@ function make_lexer(keywords) { case 56 : case 57 : case 59 : - return ident_or_keyword(get_string(undefined)); + return ident_or_keyword(get_string()); case 33 : case 35 : case 36 : @@ -416,14 +416,14 @@ function make_lexer(keywords) { } return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; }; } } return { TAG: "Int", - _0: Caml_format.int_of_string(get_string(undefined)) + _0: Caml_format.int_of_string(get_string()) }; }; }; @@ -443,13 +443,13 @@ function make_lexer(keywords) { if (c === undefined) { return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; } if (c > 57 || c < 48) { return { TAG: "Float", - _0: Caml_format.float_of_string(get_string(undefined)) + _0: Caml_format.float_of_string(get_string()) }; } Stream.junk(strm__); @@ -487,7 +487,7 @@ function make_lexer(keywords) { continue ; } Stream.junk(strm__); - return get_string(undefined); + return get_string(); } throw { RE_EXN_ID: Stream.Failure, diff --git a/lib/js/hashtbl.js b/lib/js/hashtbl.js index 72aeaf29ef..83edfef324 100644 --- a/lib/js/hashtbl.js +++ b/lib/js/hashtbl.js @@ -42,7 +42,7 @@ function is_randomized(param) { var prng = { LAZY_DONE: false, VAL: (function () { - return Random.State.make_self_init(undefined); + return Random.State.make_self_init(); }) }; diff --git a/lib/js/parsing.js b/lib/js/parsing.js index e024f371cd..a041925b2c 100644 --- a/lib/js/parsing.js +++ b/lib/js/parsing.js @@ -93,12 +93,12 @@ function yyparse(tables, start, lexer, lexbuf) { Error: new Error() }; case "Grow_stacks_1" : - grow_stacks(undefined); + grow_stacks(); _arg = undefined; _cmd = "Stacks_grown_1"; continue ; case "Grow_stacks_2" : - grow_stacks(undefined); + grow_stacks(); _arg = undefined; _cmd = "Stacks_grown_2"; continue ; @@ -191,11 +191,11 @@ function rhs_end_pos(n) { } function symbol_start(param) { - return symbol_start_pos(undefined).pos_cnum; + return symbol_start_pos().pos_cnum; } function symbol_end(param) { - return symbol_end_pos(undefined).pos_cnum; + return symbol_end_pos().pos_cnum; } function rhs_start(n) { diff --git a/lib/js/pervasivesU.js b/lib/js/pervasivesU.js index 2ebec348ac..31c6560d8a 100644 --- a/lib/js/pervasivesU.js +++ b/lib/js/pervasivesU.js @@ -199,13 +199,13 @@ var exit_function = { function at_exit(f) { var g = exit_function.contents; exit_function.contents = (function () { - f(undefined); - g(undefined); + f(); + g(); }); } function exit(retcode) { - exit_function.contents(undefined); + exit_function.contents(); return Caml_sys.sys_exit(retcode); } diff --git a/lib/js/random.js b/lib/js/random.js index 3c5436cce6..f0ceb6521d 100644 --- a/lib/js/random.js +++ b/lib/js/random.js @@ -52,7 +52,7 @@ function make(seed) { } function make_self_init(param) { - return make(random_seed(undefined)); + return make(random_seed()); } function copy(s) { @@ -240,7 +240,7 @@ function init(seed) { } function self_init(param) { - full_init$1(random_seed(undefined)); + full_init$1(random_seed()); } function get_state(param) { diff --git a/lib/js/sys.js b/lib/js/sys.js index 34fc5edfd8..a0088d3afc 100644 --- a/lib/js/sys.js +++ b/lib/js/sys.js @@ -3,9 +3,9 @@ var Caml_sys = require("./caml_sys.js"); var Caml_exceptions = require("./caml_exceptions.js"); -var match = Caml_sys.sys_get_argv(undefined); +var match = Caml_sys.sys_get_argv(); -var os_type = Caml_sys.os_type(undefined); +var os_type = Caml_sys.os_type(); var backend_type = { TAG: "Other", @@ -14,9 +14,9 @@ var backend_type = { var big_endian = false; -var unix = Caml_sys.os_type(undefined) === "Unix"; +var unix = Caml_sys.os_type() === "Unix"; -var win32 = Caml_sys.os_type(undefined) === "Win32"; +var win32 = Caml_sys.os_type() === "Win32"; function getenv_opt(s) { var x = typeof process === "undefined" ? undefined : process;