diff --git a/compiler/frontend/ast_core_type.ml b/compiler/frontend/ast_core_type.ml index 9d3c7e05f2..faf9b8f954 100644 --- a/compiler/frontend/ast_core_type.ml +++ b/compiler/frontend/ast_core_type.ml @@ -156,7 +156,7 @@ let mk_fn_type (new_arg_types_ty : param_type list) (result : t) : t = let list_of_arrow (ty : t) : t * param_type list = let rec aux (ty : t) acc = match ty.ptyp_desc with - | Ptyp_arrow (label, t1, t2, _) -> + | Ptyp_arrow (label, t1, t2, arity) when arity = None || acc = [] -> aux t2 (({label; ty = t1; attr = ty.ptyp_attributes; loc = ty.ptyp_loc} : param_type) diff --git a/compiler/frontend/ast_derive_js_mapper.ml b/compiler/frontend/ast_derive_js_mapper.ml index 7596e970a5..7336fcc0db 100644 --- a/compiler/frontend/ast_derive_js_mapper.ml +++ b/compiler/frontend/ast_derive_js_mapper.ml @@ -130,7 +130,7 @@ let app1 = Ast_compatible.app1 let app2 = Ast_compatible.app2 let ( ->~ ) a b = - Ast_uncurried.uncurried_type ~loc:Location.none ~arity:1 + Ast_uncurried.uncurried_type ~arity:1 (Ast_compatible.arrow ~arity:(Some 1) a b) let raise_when_not_found_ident = @@ -295,7 +295,7 @@ let init () = let pat_from_js = {Asttypes.loc; txt = from_js} in let to_js_type result = Ast_comb.single_non_rec_val pat_to_js - (Ast_uncurried.uncurried_type ~loc:Location.none ~arity:1 + (Ast_uncurried.uncurried_type ~arity:1 (Ast_compatible.arrow ~arity:(Some 1) core_type result)) in let new_type, new_tdcl = diff --git a/compiler/frontend/ast_derive_projector.ml b/compiler/frontend/ast_derive_projector.ml index a35972018e..26c94a51ca 100644 --- a/compiler/frontend/ast_derive_projector.ml +++ b/compiler/frontend/ast_derive_projector.ml @@ -120,9 +120,8 @@ let init () = Ext_list.flat_map tdcls handle_tdcl); signature_gen = (fun (tdcls : Parsetree.type_declaration list) _explict_nonrec -> - let handle_uncurried_type_tranform ~loc ~arity t = - if arity > 0 then Ast_uncurried.uncurried_type ~loc ~arity t - else t + let handle_uncurried_type_tranform ~arity t = + if arity > 0 then Ast_uncurried.uncurried_type ~arity t else t in let handle_tdcl tdcl = let core_type = @@ -142,8 +141,7 @@ let init () = Ast_comb.single_non_rec_val ?attrs:gentype_attrs pld_name (Ast_compatible.arrow ~arity:None core_type pld_type (*arity will alwys be 1 since these are single param functions*) - |> handle_uncurried_type_tranform ~arity:1 - ~loc:pld_name.loc)) + |> handle_uncurried_type_tranform ~arity:1)) | Ptype_variant constructor_declarations -> Ext_list.map constructor_declarations (fun @@ -170,7 +168,7 @@ let init () = {loc; txt = Ext_string.uncapitalize_ascii con_name} (Ext_list.fold_right pcd_args annotate_type (fun x acc -> Ast_compatible.arrow ~arity:None x acc) - |> handle_uncurried_type_tranform ~arity ~loc)) + |> handle_uncurried_type_tranform ~arity)) | Ptype_open | Ptype_abstract -> Ast_derive_util.not_applicable tdcl.ptype_loc deriving_name; [] diff --git a/compiler/frontend/ast_exp_handle_external.ml b/compiler/frontend/ast_exp_handle_external.ml index 27f7afa502..437e12dbe2 100644 --- a/compiler/frontend/ast_exp_handle_external.ml +++ b/compiler/frontend/ast_exp_handle_external.ml @@ -133,7 +133,7 @@ let handle_ffi ~loc ~payload = match !is_function with | Some arity -> let type_ = - Ast_uncurried.uncurried_type ~loc + Ast_uncurried.uncurried_type ~arity:(if arity = 0 then 1 else arity) (arrow ~arity) in diff --git a/compiler/frontend/ast_external_process.ml b/compiler/frontend/ast_external_process.ml index c5464862fa..ebf393852f 100644 --- a/compiler/frontend/ast_external_process.ml +++ b/compiler/frontend/ast_external_process.ml @@ -938,7 +938,7 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type) | {ptyp_desc = Ptyp_arrow (_, _, _, Some _); _} as t -> ( t, fun ~arity (x : Parsetree.core_type) -> - Ast_uncurried.uncurried_type ~loc ~arity x ) + Ast_uncurried.uncurried_type ~arity x ) | _ -> (type_annotation, fun ~arity:_ x -> x) in let result_type, arg_types_ty = diff --git a/compiler/frontend/ast_typ_uncurry.ml b/compiler/frontend/ast_typ_uncurry.ml index c79daf08ba..0b4f2a8692 100644 --- a/compiler/frontend/ast_typ_uncurry.ml +++ b/compiler/frontend/ast_typ_uncurry.ml @@ -66,5 +66,5 @@ let to_uncurry_type loc (mapper : Bs_ast_mapper.mapper) | _ -> assert false in match arity with - | Some arity -> Ast_uncurried.uncurried_type ~loc ~arity fn_type + | Some arity -> Ast_uncurried.uncurried_type ~arity fn_type | None -> assert false diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index b20d40ecf8..3578f7866e 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -120,10 +120,7 @@ module T = struct | _ -> assert false in let arity = arity_from_type t_arity in - let fun_t = - {fun_t with ptyp_desc = Ptyp_arrow (lbl, t1, t2, Some arity)} - in - {typ0 with ptyp_desc = Ptyp_constr (lid, [fun_t])} + {fun_t with ptyp_desc = Ptyp_arrow (lbl, t1, t2, Some arity)} | _ -> typ0) | Ptyp_object (l, o) -> object_ ~loc ~attrs (List.map (object_field sub) l) o diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 57ff7f440d..2f30496b9b 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -98,20 +98,21 @@ module T = struct match desc with | Ptyp_any -> any ~loc ~attrs () | Ptyp_var s -> var ~loc ~attrs s - | Ptyp_arrow (lab, t1, t2, _) -> - arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) + | Ptyp_arrow (lab, t1, t2, arity) -> ( + let typ0 = arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) in + match arity with + | None -> typ0 + | Some arity -> + let arity_string = "Has_arity" ^ string_of_int arity in + let arity_type = + Ast_helper0.Typ.variant ~loc + [Rtag (Location.mknoloc arity_string, [], true, [])] + Closed None + in + Ast_helper0.Typ.constr ~loc + {txt = Lident "function$"; loc} + [typ0; arity_type]) | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) - | Ptyp_constr - ( ({txt = Lident "function$"} as lid), - [({ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} as t_arg)] ) -> - let encode_arity_string arity = "Has_arity" ^ string_of_int arity in - let arity_type ~loc arity = - Ast_helper0.Typ.variant ~loc - [Rtag ({txt = encode_arity_string arity; loc}, [], true, [])] - Closed None - in - constr ~loc ~attrs (map_loc sub lid) - [sub.typ sub t_arg; arity_type ~loc:Location.none arity] | Ptyp_constr (lid, tl) -> constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) | Ptyp_object (l, o) -> diff --git a/compiler/ml/ast_uncurried.ml b/compiler/ml/ast_uncurried.ml index 6c12b2731b..d93fb94bfc 100644 --- a/compiler/ml/ast_uncurried.ml +++ b/compiler/ml/ast_uncurried.ml @@ -1,13 +1,10 @@ (* Uncurried AST *) -let uncurried_type ~loc ~arity (t_arg : Parsetree.core_type) = - let t_arg = - match t_arg.ptyp_desc with - | Ptyp_arrow (l, t1, t2, _) -> - {t_arg with ptyp_desc = Ptyp_arrow (l, t1, t2, Some arity)} - | _ -> assert false - in - Ast_helper.Typ.constr ~loc {txt = Lident "function$"; loc} [t_arg] +let uncurried_type ~arity (t_arg : Parsetree.core_type) = + match t_arg.ptyp_desc with + | Ptyp_arrow (l, t1, t2, _) -> + {t_arg with ptyp_desc = Ptyp_arrow (l, t1, t2, Some arity)} + | _ -> assert false let uncurried_fun ~arity fun_expr = let fun_expr = @@ -44,8 +41,9 @@ let tarrow_to_arity_opt (t_arity : Types.type_expr) = | _ -> None let make_uncurried_type ~env ~arity (t : Types.type_expr) = - let lid : Longident.t = Lident "function$" in - let path = Env.lookup_type lid env in + (* let lid : Longident.t = Lident "function$" in + let path = Env.lookup_type lid env in *) + let _ = env in let t = match t.desc with | Tarrow (l, t1, t2, c, _) -> @@ -54,17 +52,13 @@ let make_uncurried_type ~env ~arity (t : Types.type_expr) = | Tvar _ -> t | _ -> assert false in - Ctype.newconstr path [t] + t let uncurried_type_get_arity ~env typ = - match (Ctype.expand_head env typ).desc with - | Tconstr (Pident {name = "function$"}, [t], _) -> tarrow_to_arity t - | _ -> assert false + tarrow_to_arity (Ctype.expand_head env typ) let uncurried_type_get_arity_opt ~env typ = - match (Ctype.expand_head env typ).desc with - | Tconstr (Pident {name = "function$"}, [t], _) -> Some (tarrow_to_arity t) - | _ -> None + tarrow_to_arity_opt (Ctype.expand_head env typ) let remove_function_dollar ?env typ = match @@ -73,15 +67,12 @@ let remove_function_dollar ?env typ = | None -> Ctype.repr typ) .desc with - | Tconstr (Pident {name = "function$"}, [t], _) -> t | _ -> typ let core_type_remove_function_dollar (typ : Parsetree.core_type) = match typ.ptyp_desc with - | Ptyp_constr ({txt = Lident "function$"}, [t]) -> t | _ -> typ let tcore_type_remove_function_dollar (typ : Typedtree.core_type) = match typ.ctyp_desc with - | Ttyp_constr (Pident {name = "function$"}, _, [t]) -> t | _ -> typ diff --git a/compiler/ml/oprint.ml b/compiler/ml/oprint.ml index 93dd3afe4f..153d68fb18 100644 --- a/compiler/ml/oprint.ml +++ b/compiler/ml/oprint.ml @@ -249,7 +249,7 @@ let rec print_out_type ppf = function | ty -> print_out_type_1 ppf ty and print_out_type_1 ppf = function - | Otyp_arrow (lab, ty1, ty2) -> + | Otyp_arrow (lab, ty1, ty2, _) -> pp_open_box ppf 0; if lab <> "" then ( pp_print_string ppf lab; @@ -271,24 +271,6 @@ and print_simple_out_type ppf = function fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "") print_ident id - | Otyp_constr (Oide_dot (Oide_dot (Oide_ident "Js", "Fn"), name), [tyl]) -> - let res = - if name = "arity0" then - Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []), tyl) - else tyl - in - fprintf ppf "@[<0>(%a@ [@bs])@]" print_out_type_1 res - | Otyp_constr (Oide_dot (Oide_dot (Oide_ident "Js_OO", "Meth"), name), [tyl]) - -> - let res = - if name = "arity0" then - Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []), tyl) - else tyl - in - fprintf ppf "@[<0>(%a@ [@meth])@]" print_out_type_1 res - | Otyp_constr (Oide_dot (Oide_dot (Oide_ident "Js_OO", "Callback"), _), [tyl]) - -> - fprintf ppf "@[<0>(%a@ [@this])@]" print_out_type_1 tyl | Otyp_constr (id, tyl) -> pp_open_box ppf 0; print_typargs ppf tyl; diff --git a/compiler/ml/outcometree.ml b/compiler/ml/outcometree.ml index dcd620b5e6..13724209fa 100644 --- a/compiler/ml/outcometree.ml +++ b/compiler/ml/outcometree.ml @@ -53,7 +53,7 @@ type out_type = | Otyp_abstract | Otyp_open | Otyp_alias of out_type * string - | Otyp_arrow of string * out_type * out_type + | Otyp_arrow of string * out_type * out_type * Asttypes.arity | Otyp_class of bool * out_ident * out_type list | Otyp_constr of out_ident * out_type list | Otyp_manifest of out_type * out_type diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index 7ee86f3d17..c4f56214c1 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -224,8 +224,7 @@ and expression_desc = (* let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) *) - | Pexp_fun of - arg_label * expression option * pattern * expression * int option + | Pexp_fun of arg_label * expression option * pattern * expression * arity (* fun P -> E1 (Simple, None) fun ~l:P -> E1 (Labelled l, None) fun ?l:P -> E1 (Optional l, None) diff --git a/compiler/ml/printtyp.ml b/compiler/ml/printtyp.ml index ab990159e7..90a9fa1289 100644 --- a/compiler/ml/printtyp.ml +++ b/compiler/ml/printtyp.ml @@ -587,7 +587,7 @@ let rec tree_of_typexp sch ty = let non_gen = is_non_gen sch ty in let name_gen = if non_gen then new_weak_name ty else new_name in Otyp_var (non_gen, name_of_type name_gen ty) - | Tarrow (l, ty1, ty2, _, _) -> + | Tarrow (l, ty1, ty2, _, arity) -> let pr_arrow l ty1 ty2 = let lab = string_of_label l in let t1 = @@ -599,7 +599,8 @@ let rec tree_of_typexp sch ty = | _ -> Otyp_stuff "" else tree_of_typexp sch ty1 in - Otyp_arrow (lab, t1, tree_of_typexp sch ty2) + (* should pass arity here? *) + Otyp_arrow (lab, t1, tree_of_typexp sch ty2, arity) in pr_arrow l ty1 ty2 | Ttuple tyl -> Otyp_tuple (tree_of_typlist sch tyl) diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 8ef3fbfa89..deb9a2b63a 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -75,7 +75,6 @@ type error = | Literal_overflow of string | Unknown_literal of string * char | Illegal_letrec_pat - | Labels_omitted of string list | Empty_record_literal | Uncurried_arity_mismatch of type_expr * int * int | Field_not_optional of string * type_expr @@ -1945,7 +1944,7 @@ let rec list_labels_aux env visited ls ty_fun = if List.memq ty visited then (List.rev ls, false) else match ty.desc with - | Tarrow (l, _, ty_res, _, _) -> + | Tarrow (l, _, ty_res, _, arity) when arity = None || visited = [] -> list_labels_aux env (ty :: visited) (l :: ls) ty_res | _ -> (List.rev ls, is_Tvar ty) @@ -3539,7 +3538,7 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : in unify_exp env funct uncurried_typ else if - Ast_uncurried.tarrow_to_arity_opt + Ast_uncurried.uncurried_type_get_arity_opt ~env (Ast_uncurried.remove_function_dollar ~env funct.exp_type) = None then @@ -3700,23 +3699,6 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : type_unknown_args max_arity ~args ~top_arity omitted ty_fun0 sargs (* This is the hot path for non-labeled function*) in - let () = - let ls, tvar = list_labels env funct.exp_type in - if not tvar then - let labels = Ext_list.filter ls (fun l -> not (is_optional l)) in - if - Ext_list.same_length labels sargs - && List.for_all (fun (l, _) -> l = Nolabel) sargs - && List.exists (fun l -> l <> Nolabel) labels - then - raise - (Error - ( funct.exp_loc, - env, - Labels_omitted - (List.map Printtyp.string_of_label - (Ext_list.filter labels (fun x -> x <> Nolabel))) )) - in if total_app then force_uncurried_type funct; let ty, max_arity = extract_uncurried_type funct in let top_arity = if total_app then Some max_arity else None in @@ -3728,7 +3710,7 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : in let exp = type_expect env sarg ty_arg in (match (expand_head env exp.exp_type).desc with - | Tarrow _ -> + | Tarrow _ when not total_app -> Location.prerr_warning exp.exp_loc Warnings.Partial_application | Tvar _ -> Delayed_checks.add_delayed_check (fun () -> @@ -4345,23 +4327,6 @@ let report_error env ppf error = let arity_a = arity_a |> string_of_int in let arity_b = arity_b |> string_of_int in report_arity_mismatch ~arity_a ~arity_b ppf - | Expr_type_clash - ( ( _, - { - desc = - Tconstr - (Pdot (Pdot (Pident {name = "Js_OO"}, "Meth", _), a, _), _, _); - } ) - :: ( _, - { - desc = - Tconstr - (Pdot (Pdot (Pident {name = "Js_OO"}, "Meth", _), b, _), _, _); - } ) - :: _, - _ ) - when a <> b -> - fprintf ppf "This method has %s but was expected %s" a b | Expr_type_clash (trace, type_clash_context) -> (* modified *) fprintf ppf "@["; @@ -4544,16 +4509,6 @@ let report_error env ppf error = fprintf ppf "Unknown modifier '%c' for literal %s%c" m n m | Illegal_letrec_pat -> fprintf ppf "Only variables are allowed as left-hand side of `let rec'" - | Labels_omitted [label] -> - fprintf ppf - "Label ~%s was omitted in the application of this labeled function." label - | Labels_omitted labels -> - let labels_string = - labels |> List.map (fun label -> "~" ^ label) |> String.concat ", " - in - fprintf ppf - "Labels %s were omitted in the application of this labeled function." - labels_string | Empty_record_literal -> fprintf ppf "Empty record literal {} should be type annotated or used in a record \ diff --git a/compiler/ml/typecore.mli b/compiler/ml/typecore.mli index 35749847b0..6d69191021 100644 --- a/compiler/ml/typecore.mli +++ b/compiler/ml/typecore.mli @@ -118,7 +118,6 @@ type error = | Literal_overflow of string | Unknown_literal of string * char | Illegal_letrec_pat - | Labels_omitted of string list | Empty_record_literal | Uncurried_arity_mismatch of type_expr * int * int | Field_not_optional of string * type_expr diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index e909a46b9f..43d13cf450 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -78,7 +78,7 @@ and expression_desc = | Texp_let of rec_flag * value_binding list * expression | Texp_function of { arg_label: arg_label; - arity: int option; + arity: arity; param: Ident.t; case: case; partial: partial; diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index f75fdfa8f7..d6c6988078 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -132,7 +132,7 @@ and expression_desc = *) | Texp_function of { arg_label: arg_label; - arity: int option; + arity: arity; param: Ident.t; case: case; partial: partial; diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index e678dd9092..80a2ce2dde 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -4074,7 +4074,7 @@ and parse_poly_type_expr p = let t_fun = Ast_helper.Typ.arrow ~loc ~arity:None Asttypes.Nolabel typ return_type in - Ast_uncurried.uncurried_type ~loc ~arity:1 t_fun + Ast_uncurried.uncurried_type ~arity:1 t_fun | _ -> Ast_helper.Typ.var ~loc:var.loc var.txt) | _ -> assert false) | _ -> parse_typ_expr p @@ -4429,7 +4429,7 @@ and parse_es6_arrow_type ~attrs p = Ast_helper.Typ.arrow ~loc ~attrs ~arity:None arg_lbl typ t in if param_num = 1 then - (param_num - 1, Ast_uncurried.uncurried_type ~loc ~arity t_arg, 1) + (param_num - 1, Ast_uncurried.uncurried_type ~arity t_arg, 1) else (param_num - 1, t_arg, arity + 1)) parameters (List.length parameters, return_type, return_type_arity + 1) @@ -4489,7 +4489,7 @@ and parse_arrow_type_rest ~es6_arrow ~start_pos typ p = let arrow_typ = Ast_helper.Typ.arrow ~loc ~arity:None Asttypes.Nolabel typ return_type in - Ast_uncurried.uncurried_type ~loc ~arity:1 arrow_typ + Ast_uncurried.uncurried_type ~arity:1 arrow_typ | _ -> typ and parse_typ_expr_region p = @@ -5098,9 +5098,7 @@ and parse_type_equation_or_constr_decl p = let arrow_type = Ast_helper.Typ.arrow ~loc ~arity:None Asttypes.Nolabel typ return_type in - let arrow_type = - Ast_uncurried.uncurried_type ~loc ~arity:1 arrow_type - in + let arrow_type = Ast_uncurried.uncurried_type ~arity:1 arrow_type in let typ = parse_type_alias p arrow_type in (Some typ, Asttypes.Public, Parsetree.Ptype_abstract) diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index 80feaf742b..e8b97c7815 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -82,7 +82,8 @@ let print_out_attributes_doc (attrs : Outcometree.out_attribute list) = let rec collect_arrow_args (out_type : Outcometree.out_type) args = match out_type with - | Otyp_arrow (label, arg_type, return_type) -> + | Otyp_arrow (label, arg_type, return_type, arity) + when arity = None || args = [] -> let arg = (label, arg_type) in collect_arrow_args return_type (arg :: args) | _ as return_type -> (List.rev args, return_type) @@ -147,21 +148,6 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) = Doc.text alias_txt; Doc.rparen; ] - | Otyp_constr (Oide_dot (Oide_dot (Oide_ident "Js", "Fn"), "arity0"), [typ]) - -> - (* Compatibility with compiler up to v10.x *) - Doc.concat [Doc.text "(. ()) => "; print_out_type_doc typ] - | Otyp_constr - ( Oide_dot (Oide_dot (Oide_ident "Js", "Fn"), _), - [(Otyp_arrow _ as arrow_type)] ) -> - (* Compatibility with compiler up to v10.x *) - print_out_arrow_type arrow_type - | Otyp_constr (Oide_ident "function$", [(Otyp_arrow _ as arrow_type)]) -> - (* function$<(int, int) => int> -> (int, int) => int *) - print_out_arrow_type arrow_type - | Otyp_constr (Oide_ident "function$", [Otyp_var _]) -> - (* function$<'a, arity> -> _ => _ *) - print_out_type_doc (Otyp_stuff "_ => _") | Otyp_constr (out_ident, []) -> print_out_ident_doc ~allow_uident:false out_ident | Otyp_manifest (typ1, typ2) -> @@ -295,12 +281,7 @@ and print_out_arrow_type typ = let args_doc = let needs_parens = match typ_args with - | [ - ( _, - ( Otyp_tuple _ | Otyp_arrow _ - | Otyp_constr (Oide_ident "function$", [Otyp_arrow _]) ) ); - ] -> - true + | [(_, (Otyp_tuple _ | Otyp_arrow _))] -> true (* single argument should not be wrapped *) | [("", _)] -> false | _ -> true diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index 56d91114de..b61ae36951 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -1,12 +1,15 @@ open Parsetree -let arrow_type ?(max_arity = max_int) ?(attrs = []) ct = +let arrow_type ?(max_arity = max_int) ct = let has_as_attr attrs = Ext_list.exists attrs (fun (x, _) -> x.Asttypes.txt = "as") in let rec process attrs_before acc typ arity = match typ with - | typ when arity < 0 -> (attrs_before, List.rev acc, typ) + | _ when arity < 0 -> (attrs_before, List.rev acc, typ) + | {ptyp_desc = Ptyp_arrow (_, _, _, Some _); ptyp_attributes = []} + when acc <> [] -> + (attrs_before, List.rev acc, typ) | { ptyp_desc = Ptyp_arrow ((Nolabel as lbl), typ1, typ2, _); ptyp_attributes = []; @@ -51,9 +54,8 @@ let arrow_type ?(max_arity = max_int) ?(attrs = []) ct = ptyp_desc = Ptyp_arrow (Nolabel, _typ1, _typ2, _); ptyp_attributes = attrs1; } as typ -> - let attrs = attrs @ attrs1 in - process attrs [] {typ with ptyp_attributes = []} max_arity - | typ -> process attrs [] typ max_arity + process attrs1 [] {typ with ptyp_attributes = []} max_arity + | typ -> process [] [] typ max_arity let functor_type modtype = let rec process acc modtype = diff --git a/compiler/syntax/src/res_parsetree_viewer.mli b/compiler/syntax/src/res_parsetree_viewer.mli index 56629acd89..f478f1e633 100644 --- a/compiler/syntax/src/res_parsetree_viewer.mli +++ b/compiler/syntax/src/res_parsetree_viewer.mli @@ -3,7 +3,6 @@ * we restructure the tree into (a, b, c) and its returnType d *) val arrow_type : ?max_arity:int -> - ?attrs:Parsetree.attributes -> Parsetree.core_type -> Parsetree.attributes * (Parsetree.attributes * Asttypes.arg_label * Parsetree.core_type) list diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 6f88b4fc65..a6b3ba0cad 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -1587,9 +1587,6 @@ and print_label_declaration ~state (ld : Parsetree.label_declaration) cmt_tbl = ]) and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = - let parent_attrs = - ParsetreeViewer.filter_parsing_attrs typ_expr.ptyp_attributes - in let print_arrow ~arity typ_expr = let max_arity = match arity with @@ -1597,7 +1594,7 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = | None -> max_int in let attrs_before, args, return_type = - ParsetreeViewer.arrow_type ~max_arity ~attrs:parent_attrs typ_expr + ParsetreeViewer.arrow_type ~max_arity typ_expr in let return_type_needs_parens = match return_type.ptyp_desc with diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 860577fc40..7b5b08f55d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -981,7 +981,7 @@ addValueDeclaration +make ImportHookDefault.res:6:0 path:+ImportHookDefault addRecordLabelDeclaration name ImportHookDefault.res:2:2 path:+ImportHookDefault.person addRecordLabelDeclaration age ImportHookDefault.res:3:2 path:+ImportHookDefault.person - addRecordLabelDeclaration person ImportHookDefault.res:8:2 path:+ImportHookDefault.props + addRecordLabelDeclaration person ImportHookDefault.res:7:15 path:+ImportHookDefault.props addRecordLabelDeclaration children ImportHookDefault.res:9:2 path:+ImportHookDefault.props addRecordLabelDeclaration renderMe ImportHookDefault.res:11:5 path:+ImportHookDefault.props Scanning ImportHooks.cmt Source:ImportHooks.res @@ -989,7 +989,7 @@ addValueDeclaration +foo ImportHooks.res:20:0 path:+ImportHooks addRecordLabelDeclaration name ImportHooks.res:3:2 path:+ImportHooks.person addRecordLabelDeclaration age ImportHooks.res:4:2 path:+ImportHooks.person - addRecordLabelDeclaration person ImportHooks.res:15:2 path:+ImportHooks.props + addRecordLabelDeclaration person ImportHooks.res:14:15 path:+ImportHooks.props addRecordLabelDeclaration children ImportHooks.res:16:2 path:+ImportHooks.props addRecordLabelDeclaration renderMe ImportHooks.res:18:5 path:+ImportHooks.props Scanning ImportIndex.cmt Source:ImportIndex.res @@ -1195,7 +1195,9 @@ addValueReference OptArg.res:1:4 --> OptArg.res:1:29 addValueReference OptArg.res:3:4 --> OptArg.res:3:17 addValueReference OptArg.res:3:4 --> OptArg.res:3:27 + DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: OptArg.res:5:7 addValueReference OptArg.res:5:7 --> OptArg.res:1:4 + DeadOptionalArgs.addReferences bar called with optional argNames: argNamesMaybe: OptArg.res:7:7 addValueReference OptArg.res:7:7 --> OptArg.res:3:4 addValueReference OptArg.res:9:4 --> OptArg.res:9:20 addValueReference OptArg.res:9:4 --> OptArg.res:9:26 @@ -1204,20 +1206,25 @@ addValueReference OptArg.res:9:4 --> OptArg.res:9:23 addValueReference OptArg.res:9:4 --> OptArg.res:9:29 addValueReference OptArg.res:9:4 --> OptArg.res:9:35 + DeadOptionalArgs.addReferences threeArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:11:7 addValueReference OptArg.res:11:7 --> OptArg.res:9:4 + DeadOptionalArgs.addReferences threeArgs called with optional argNames:a argNamesMaybe: OptArg.res:12:7 addValueReference OptArg.res:12:7 --> OptArg.res:9:4 addValueReference OptArg.res:14:4 --> OptArg.res:14:18 addValueReference OptArg.res:14:4 --> OptArg.res:14:24 addValueReference OptArg.res:14:4 --> OptArg.res:14:15 addValueReference OptArg.res:14:4 --> OptArg.res:14:21 addValueReference OptArg.res:14:4 --> OptArg.res:14:27 + DeadOptionalArgs.addReferences twoArgs called with optional argNames: argNamesMaybe: OptArg.res:16:7 addValueReference OptArg.res:16:12 --> OptArg.res:14:4 addValueReference OptArg.res:18:4 --> OptArg.res:18:17 addValueReference OptArg.res:18:4 --> OptArg.res:18:14 addValueReference OptArg.res:18:4 --> OptArg.res:18:24 + DeadOptionalArgs.addReferences oneArg called with optional argNames:a argNamesMaybe:a OptArg.res:20:30 addValueReference OptArg.res:20:4 --> OptArg.res:20:18 addValueReference OptArg.res:20:4 --> OptArg.res:20:24 addValueReference OptArg.res:20:4 --> OptArg.res:18:4 + DeadOptionalArgs.addReferences wrapOneArg called with optional argNames:a argNamesMaybe: OptArg.res:22:7 addValueReference OptArg.res:22:7 --> OptArg.res:20:4 addValueReference OptArg.res:24:4 --> OptArg.res:24:19 addValueReference OptArg.res:24:4 --> OptArg.res:24:25 @@ -1228,15 +1235,20 @@ addValueReference OptArg.res:24:4 --> OptArg.res:24:28 addValueReference OptArg.res:24:4 --> OptArg.res:24:34 addValueReference OptArg.res:24:4 --> OptArg.res:24:40 + DeadOptionalArgs.addReferences fourArgs called with optional argNames:c, b, a argNamesMaybe:c, b, a OptArg.res:26:44 addValueReference OptArg.res:26:4 --> OptArg.res:26:20 addValueReference OptArg.res:26:4 --> OptArg.res:26:26 addValueReference OptArg.res:26:4 --> OptArg.res:26:32 addValueReference OptArg.res:26:4 --> OptArg.res:26:38 addValueReference OptArg.res:26:4 --> OptArg.res:24:4 + DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:28:7 addValueReference OptArg.res:28:7 --> OptArg.res:26:4 + DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, b argNamesMaybe: OptArg.res:29:7 addValueReference OptArg.res:29:7 --> OptArg.res:26:4 addValueReference OptArg.resi:1:0 --> OptArg.res:1:4 + OptionalArgs.addFunctionReference OptArg.resi:1:0 OptArg.res:1:4 addValueReference OptArg.resi:2:0 --> OptArg.res:3:4 + OptionalArgs.addFunctionReference OptArg.resi:2:0 OptArg.res:3:4 Scanning OptArg.cmti Source:OptArg.resi addValueDeclaration +foo OptArg.resi:1:0 path:OptArg addValueDeclaration +bar OptArg.resi:2:0 path:OptArg @@ -1438,10 +1450,12 @@ addValueDeclaration +bar TestOptArg.res:5:4 path:+TestOptArg addValueDeclaration +notSuppressesOptArgs TestOptArg.res:9:4 path:+TestOptArg addValueDeclaration +liveSuppressesOptArgs TestOptArg.res:14:4 path:+TestOptArg + DeadOptionalArgs.addReferences OptArg.bar called with optional argNames:z argNamesMaybe: TestOptArg.res:1:7 addValueReference TestOptArg.res:1:7 --> OptArg.resi:2:0 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:14 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:11 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:17 + DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: TestOptArg.res:5:16 addValueReference TestOptArg.res:5:4 --> TestOptArg.res:3:4 addValueReference TestOptArg.res:7:7 --> TestOptArg.res:5:4 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:31 @@ -1451,6 +1465,7 @@ addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:34 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:40 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:46 + DeadOptionalArgs.addReferences notSuppressesOptArgs called with optional argNames: argNamesMaybe: TestOptArg.res:11:8 addValueReference TestOptArg.res:11:8 --> TestOptArg.res:9:4 addValueReference TestOptArg.res:14:4 --> TestOptArg.res:14:32 addValueReference TestOptArg.res:14:4 --> TestOptArg.res:14:38 @@ -1459,6 +1474,7 @@ addValueReference TestOptArg.res:14:4 --> TestOptArg.res:14:35 addValueReference TestOptArg.res:14:4 --> TestOptArg.res:14:41 addValueReference TestOptArg.res:14:4 --> TestOptArg.res:14:47 + DeadOptionalArgs.addReferences liveSuppressesOptArgs called with optional argNames:x argNamesMaybe: TestOptArg.res:16:8 addValueReference TestOptArg.res:16:8 --> TestOptArg.res:14:4 Scanning TestPromise.cmt Source:TestPromise.res addValueDeclaration +convert TestPromise.res:14:4 path:+TestPromise @@ -1667,11 +1683,13 @@ addTypeReference Unison.res:37:20 --> Unison.res:14:2 addValueReference Unison.res:37:0 --> Unison.res:26:8 addTypeReference Unison.res:38:20 --> Unison.res:15:2 + DeadOptionalArgs.addReferences group called with optional argNames:break argNamesMaybe: Unison.res:38:25 addTypeReference Unison.res:38:38 --> Unison.res:5:2 addValueReference Unison.res:38:25 --> Unison.res:17:4 addTypeReference Unison.res:38:53 --> Unison.res:14:2 addValueReference Unison.res:38:0 --> Unison.res:26:8 addTypeReference Unison.res:39:20 --> Unison.res:15:2 + DeadOptionalArgs.addReferences group called with optional argNames:break argNamesMaybe: Unison.res:39:25 addTypeReference Unison.res:39:38 --> Unison.res:6:2 addValueReference Unison.res:39:25 --> Unison.res:17:4 addTypeReference Unison.res:39:52 --> Unison.res:14:2 @@ -2501,6 +2519,70 @@ File References DeadTest.res:153:1-28 deadIncorrect is annotated @dead but is live + Warning Unused Argument + TestOptArg.res:9:1-65 + optional argument x of function notSuppressesOptArgs is never used + + Warning Unused Argument + TestOptArg.res:9:1-65 + optional argument y of function notSuppressesOptArgs is never used + + Warning Unused Argument + TestOptArg.res:9:1-65 + optional argument z of function notSuppressesOptArgs is never used + + Warning Redundant Optional Argument + TestOptArg.res:3:1-28 + optional argument x of function foo is always supplied (1 calls) + + Warning Redundant Optional Argument + Unison.res:17:1-60 + optional argument break of function group is always supplied (2 calls) + + Warning Unused Argument + OptArg.resi:2:1-50 + optional argument x of function bar is never used + + Warning Redundant Optional Argument + OptArg.res:26:1-70 + optional argument c of function wrapfourArgs is always supplied (2 calls) + + Warning Unused Argument + OptArg.res:24:1-63 + optional argument d of function fourArgs is never used + + Warning Redundant Optional Argument + OptArg.res:20:1-51 + optional argument a of function wrapOneArg is always supplied (1 calls) + + Warning Unused Argument + OptArg.res:14:1-42 + optional argument a of function twoArgs is never used + + Warning Unused Argument + OptArg.res:14:1-42 + optional argument b of function twoArgs is never used + + Warning Unused Argument + OptArg.res:9:1-54 + optional argument b of function threeArgs is never used + + Warning Redundant Optional Argument + OptArg.res:9:1-54 + optional argument a of function threeArgs is always supplied (2 calls) + + Warning Unused Argument + OptArg.res:3:1-38 + optional argument x of function bar is never used + + Warning Unused Argument + OptArg.res:1:1-48 + optional argument y of function foo is never used + + Warning Unused Argument + OptArg.res:1:1-48 + optional argument z of function foo is never used + Warning Dead Module AutoAnnotate.res:0:1 AutoAnnotate is a dead module as all its items are dead. @@ -4167,4 +4249,4 @@ File References <-- line 96 type variant1Object = | @dead("variant1Object.R") R(payload) - Analysis reported 286 issues (Incorrect Dead Annotation:1, Warning Dead Exception:2, Warning Dead Module:21, Warning Dead Type:87, Warning Dead Value:174, Warning Dead Value With Side Effects:1) + Analysis reported 302 issues (Incorrect Dead Annotation:1, Warning Dead Exception:2, Warning Dead Module:21, Warning Dead Type:87, Warning Dead Value:174, Warning Dead Value With Side Effects:1, Warning Redundant Optional Argument:5, Warning Unused Argument:11) diff --git a/tests/analysis_tests/tests/src/expected/SignatureHelp.res.txt b/tests/analysis_tests/tests/src/expected/SignatureHelp.res.txt index 09576665b9..1d86e2147d 100644 --- a/tests/analysis_tests/tests/src/expected/SignatureHelp.res.txt +++ b/tests/analysis_tests/tests/src/expected/SignatureHelp.res.txt @@ -9,11 +9,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: unlabelled<0> extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -31,11 +32,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: unlabelled<0> extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -53,11 +55,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: ~two extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -75,11 +78,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: ~two extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -97,11 +101,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: ~four extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -119,11 +124,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: ~four extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -141,11 +147,11 @@ ContextPath Value[otherFunc] Path otherFunc argAtCursor: unlabelled<0> extracted params: -[string, int, float] +[(string, int, float] { "signatures": [{ "label": "(string, int, float) => unit", - "parameters": [{"label": [1, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 0 @@ -162,11 +168,11 @@ ContextPath Value[otherFunc] Path otherFunc argAtCursor: unlabelled<0> extracted params: -[string, int, float] +[(string, int, float] { "signatures": [{ "label": "(string, int, float) => unit", - "parameters": [{"label": [1, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 0 @@ -183,11 +189,11 @@ ContextPath Value[otherFunc] Path otherFunc argAtCursor: unlabelled<2> extracted params: -[string, int, float] +[(string, int, float] { "signatures": [{ "label": "(string, int, float) => unit", - "parameters": [{"label": [1, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 2 @@ -204,11 +210,11 @@ ContextPath Value[Completion, Lib, foo] Path Completion.Lib.foo argAtCursor: ~age extracted params: -[~age: int, ~name: string] +[(~age: int, ~name: string] { "signatures": [{ "label": "(~age: int, ~name: string) => string", - "parameters": [{"label": [1, 10], "documentation": {"kind": "markdown", "value": ""}}, {"label": [12, 25], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 10], "documentation": {"kind": "markdown", "value": ""}}, {"label": [12, 25], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 0 @@ -247,11 +253,11 @@ ContextPath Value[otherFunc] Path otherFunc argAtCursor: unlabelled<1> extracted params: -[string, int, float] +[(string, int, float] { "signatures": [{ "label": "(string, int, float) => unit", - "parameters": [{"label": [1, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [9, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 19], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 1 @@ -268,11 +274,11 @@ ContextPath Value[fn] Path fn argAtCursor: unlabelled<1> extracted params: -[int, string, int] +[(int, string, int] { "signatures": [{ "label": "(int, string, int) => unit", - "parameters": [{"label": [1, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 1 @@ -289,11 +295,11 @@ ContextPath Value[fn] Path fn argAtCursor: unlabelled<1> extracted params: -[int, string, int] +[(int, string, int] { "signatures": [{ "label": "(int, string, int) => unit", - "parameters": [{"label": [1, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 1 @@ -310,11 +316,11 @@ ContextPath Value[fn] Path fn argAtCursor: unlabelled<2> extracted params: -[int, string, int] +[(int, string, int] { "signatures": [{ "label": "(int, string, int) => unit", - "parameters": [{"label": [1, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] + "parameters": [{"label": [0, 4], "documentation": {"kind": "markdown", "value": ""}}, {"label": [6, 12], "documentation": {"kind": "markdown", "value": ""}}, {"label": [14, 17], "documentation": {"kind": "markdown", "value": ""}}] }], "activeSignature": 0, "activeParameter": 2 @@ -358,11 +364,12 @@ ContextPath Value[someFunc] Path someFunc argAtCursor: unlabelled<0> extracted params: -[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] +[( + int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit] { "signatures": [{ "label": "(\n int,\n ~two: string=?,\n ~three: unit => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [4, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 7], "documentation": {"kind": "markdown", "value": ""}}, {"label": [11, 25], "documentation": {"kind": "markdown", "value": ""}}, {"label": [29, 49], "documentation": {"kind": "markdown", "value": ""}}, {"label": [53, 71], "documentation": {"kind": "markdown", "value": "```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C0%2C0%5D)"}}, {"label": [75, 79], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": " Does stuff. "} }], "activeSignature": 0, @@ -449,11 +456,11 @@ Signature help src/SignatureHelp.res 105:9 Signature help src/SignatureHelp.res 113:42 argAtCursor: unlabelled<1> extracted params: -[array, int => int] +[(array, int => int] { "signatures": [{ "label": "(array, int => int) => array", - "parameters": [{"label": [1, 11], "documentation": {"kind": "markdown", "value": ""}}, {"label": [13, 23], "documentation": {"kind": "markdown", "value": ""}}], + "parameters": [{"label": [0, 11], "documentation": {"kind": "markdown", "value": ""}}, {"label": [13, 23], "documentation": {"kind": "markdown", "value": ""}}], "documentation": {"kind": "markdown", "value": "\n`map(array, fn)` returns a new array with all elements from `array`, each element transformed using the provided `fn`.\n\nSee [`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on MDN.\n\n## Examples\n```rescript\nlet array = [\"Hello\", \"Hi\", \"Good bye\"]\nlet mappedArray = array->Array.map(greeting => greeting ++ \" to you\")\n\nConsole.log(mappedArray) // [\"Hello to you\", \"Hi to you\", \"Good bye to you\"]\n```\n"} }], "activeSignature": 0, @@ -463,11 +470,11 @@ extracted params: Signature help src/SignatureHelp.res 132:18 argAtCursor: unlabelled<0> extracted params: -[x, tt] +[(x, tt] { "signatures": [{ "label": "(x, tt) => string", - "parameters": [{"label": [1, 2], "documentation": {"kind": "markdown", "value": "```rescript\ntype x = {age?: int, name?: string}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C117%2C0%5D)"}}, {"label": [4, 6], "documentation": {"kind": "markdown", "value": "```rescript\ntype tt = One\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C123%2C0%5D)"}}], + "parameters": [{"label": [0, 2], "documentation": {"kind": "markdown", "value": "```rescript\ntype x = {age?: int, name?: string}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C117%2C0%5D)"}}, {"label": [4, 6], "documentation": {"kind": "markdown", "value": "```rescript\ntype tt = One\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C123%2C0%5D)"}}], "documentation": {"kind": "markdown", "value": " Some stuff "} }], "activeSignature": 0, @@ -477,11 +484,11 @@ extracted params: Signature help src/SignatureHelp.res 135:22 argAtCursor: unlabelled<1> extracted params: -[x, tt] +[(x, tt] { "signatures": [{ "label": "(x, tt) => string", - "parameters": [{"label": [1, 2], "documentation": {"kind": "markdown", "value": "```rescript\ntype x = {age?: int, name?: string}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C117%2C0%5D)"}}, {"label": [4, 6], "documentation": {"kind": "markdown", "value": "```rescript\ntype tt = One\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C123%2C0%5D)"}}], + "parameters": [{"label": [0, 2], "documentation": {"kind": "markdown", "value": "```rescript\ntype x = {age?: int, name?: string}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C117%2C0%5D)"}}, {"label": [4, 6], "documentation": {"kind": "markdown", "value": "```rescript\ntype tt = One\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelp.res%22%2C123%2C0%5D)"}}], "documentation": {"kind": "markdown", "value": " Some stuff "} }], "activeSignature": 0, diff --git a/tests/syntax_tests/data/parsing/errors/other/expected/labelledParameters.res.txt b/tests/syntax_tests/data/parsing/errors/other/expected/labelledParameters.res.txt index e054529696..06b15e81f8 100644 --- a/tests/syntax_tests/data/parsing/errors/other/expected/labelledParameters.res.txt +++ b/tests/syntax_tests/data/parsing/errors/other/expected/labelledParameters.res.txt @@ -34,4 +34,4 @@ let f [arity:3]x ?(y= 2) z = (x + y) + z let g [arity:3]~x:((x)[@res.namedArgLoc ]) ?y:(((y)[@res.namedArgLoc ])= 2) ~z:((z)[@res.namedArgLoc ]) = (x + y) + z -type nonrec f = (x:int -> y:int -> int (a:2)) function$ \ No newline at end of file +type nonrec f = x:int -> y:int -> int (a:2) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/other/expected/regionMissingComma.res.txt b/tests/syntax_tests/data/parsing/errors/other/expected/regionMissingComma.res.txt index 40a466d444..8cc3ca5763 100644 --- a/tests/syntax_tests/data/parsing/errors/other/expected/regionMissingComma.res.txt +++ b/tests/syntax_tests/data/parsing/errors/other/expected/regionMissingComma.res.txt @@ -23,9 +23,9 @@ Did you forget a `,` here? external make : - (?style:((ReactDOMRe.Style.t)[@res.namedArgLoc ]) -> - ?image:((bool)[@res.namedArgLoc ]) -> React.element (a:2)) - function$ = "ModalContent" + ?style:((ReactDOMRe.Style.t)[@res.namedArgLoc ]) -> + ?image:((bool)[@res.namedArgLoc ]) -> React.element (a:2) = + "ModalContent" type nonrec 'extraInfo student = { name: string ; diff --git a/tests/syntax_tests/data/parsing/errors/structure/expected/external.res.txt b/tests/syntax_tests/data/parsing/errors/structure/expected/external.res.txt index aef3cb83a4..42d4421955 100644 --- a/tests/syntax_tests/data/parsing/errors/structure/expected/external.res.txt +++ b/tests/syntax_tests/data/parsing/errors/structure/expected/external.res.txt @@ -8,5 +8,4 @@ An external requires the name of the JS value you're referring to, like "setTimeout". -external setTimeout : - ((unit -> unit (a:1)) function$ -> int -> float (a:2)) function$ \ No newline at end of file +external setTimeout : (unit -> unit (a:1)) -> int -> float (a:2) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/typeDef/expected/inlineRecord.res.txt b/tests/syntax_tests/data/parsing/errors/typeDef/expected/inlineRecord.res.txt index 1b559e5e21..872b3da415 100644 --- a/tests/syntax_tests/data/parsing/errors/typeDef/expected/inlineRecord.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typeDef/expected/inlineRecord.res.txt @@ -45,7 +45,5 @@ type nonrec user = address: < street: string ;country: string > } let make [arity:1](props : - < - handleClick: (Click.t -> unit (a:1)) function$ ;value: - string > ) + < handleClick: Click.t -> unit (a:1) ;value: string > ) = render props \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/typeDef/expected/namedParameters.res.txt b/tests/syntax_tests/data/parsing/errors/typeDef/expected/namedParameters.res.txt index ded012ea92..b6b90fb587 100644 --- a/tests/syntax_tests/data/parsing/errors/typeDef/expected/namedParameters.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typeDef/expected/namedParameters.res.txt @@ -7,4 +7,4 @@ A labeled parameter starts with a `~`. Did you mean: `~stroke`? -type nonrec draw = (stroke:pencil -> unit (a:1)) function$ \ No newline at end of file +type nonrec draw = stroke:pencil -> unit (a:1) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/typeDef/expected/typeParams.res.txt b/tests/syntax_tests/data/parsing/errors/typeDef/expected/typeParams.res.txt index 6c631c9719..c4024a1fac 100644 --- a/tests/syntax_tests/data/parsing/errors/typeDef/expected/typeParams.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typeDef/expected/typeParams.res.txt @@ -62,16 +62,16 @@ type nonrec 'a node = { type nonrec ('from, 'for) derivedNode = { mutable value: 'to_ ; - updateF: ('from -> 'to_ (a:1)) function$ } + updateF: 'from -> 'to_ (a:1) } type nonrec ('from, ') derivedNode = { mutable value: 'to_ ; - updateF: ('from -> 'to_ (a:1)) function$ } + updateF: 'from -> 'to_ (a:1) } type nonrec ('from, ') derivedNode = { mutable value: 'to_ ; - updateF: ('from -> 'to_ (a:1)) function$ } + updateF: 'from -> 'to_ (a:1) } type nonrec ('from, 'foo) derivedNode = { mutable value: 'to_ ; - updateF: ('from -> 'to_ (a:1)) function$ } \ No newline at end of file + updateF: 'from -> 'to_ (a:1) } \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/typexpr/expected/arrow.res.txt b/tests/syntax_tests/data/parsing/errors/typexpr/expected/arrow.res.txt index e5ccd919a6..4a76a16f95 100644 --- a/tests/syntax_tests/data/parsing/errors/typexpr/expected/arrow.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typexpr/expected/arrow.res.txt @@ -33,16 +33,15 @@ Did you forget a `:` here? It signals the start of a type -external add_nat : (nat -> int (a:1)) function$ = "add_nat_bytecode" +external add_nat : nat -> int (a:1) = "add_nat_bytecode" module Error2 = struct type nonrec observation = { observed: int ; onStep: - (currentValue:((unit)[@res.namedArgLoc ]) -> - [%rescript.typehole ] (a:1)) - function$ + currentValue:((unit)[@res.namedArgLoc ]) -> + [%rescript.typehole ] (a:1) } end module Error3 = diff --git a/tests/syntax_tests/data/parsing/errors/typexpr/expected/bsObjSugar.res.txt b/tests/syntax_tests/data/parsing/errors/typexpr/expected/bsObjSugar.res.txt index dfe23855db..ebb718e555 100644 --- a/tests/syntax_tests/data/parsing/errors/typexpr/expected/bsObjSugar.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typexpr/expected/bsObjSugar.res.txt @@ -142,7 +142,7 @@ type nonrec state = > type nonrec state = < url: string ;protocols: [%rescript.typehole ] > type nonrec state = - < send: (string -> [%rescript.typehole ] (a:1)) function$ [@meth ] > + < send: string -> [%rescript.typehole ] (a:1) [@meth ] > type nonrec state = < age: [%rescript.typehole ] ;name: string > type nonrec state = < age: [%rescript.typehole ] [@set ] ;name: string > type nonrec state = < age: [%rescript.typehole ] ;.. > diff --git a/tests/syntax_tests/data/parsing/errors/typexpr/expected/garbage.res.txt b/tests/syntax_tests/data/parsing/errors/typexpr/expected/garbage.res.txt index a4e8c44541..bce429c7f3 100644 --- a/tests/syntax_tests/data/parsing/errors/typexpr/expected/garbage.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typexpr/expected/garbage.res.txt @@ -9,5 +9,5 @@ I'm not sure what to parse here when looking at "?". external printName : - (name:((unit)[@res.namedArgLoc ]) -> unit (a:1)) function$ = "printName" -[@@module {js|moduleName|js}] \ No newline at end of file + name:((unit)[@res.namedArgLoc ]) -> unit (a:1) = "printName"[@@module + {js|moduleName|js}] \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt index 679e19d559..873c89937e 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedByDefault.res.txt @@ -6,42 +6,36 @@ let mixFun [arity:3]a b c [arity:3]d e f [arity:2]g h = 4 let bracesFun [arity:1]x [arity:1]y = x + y let cFun2 [arity:2]x y = 3 let uFun2 [arity:2]x y = 3 -type nonrec cTyp = (string -> int (a:1)) function$ -type nonrec uTyp = (string -> int (a:1)) function$ +type nonrec cTyp = string -> int (a:1) +type nonrec uTyp = string -> int (a:1) type nonrec mixTyp = - (string -> - string -> - string -> - (string -> - string -> string -> (string -> string -> int (a:2)) function$ (a:3)) - function$ (a:3)) - function$ -type nonrec bTyp = - (string -> (string -> int (a:1)) function$ (a:1)) function$ -type nonrec cTyp2 = (string -> string -> int (a:2)) function$ -type nonrec uTyp2 = (string -> string -> int (a:2)) function$ -type nonrec cu = (unit -> int (a:1)) function$ -type nonrec cp = (unit -> int (a:1)) function$ -type nonrec cuu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cpu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cup = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cpp = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cu2 = (unit -> unit -> unit (a:2)) function$ -type nonrec cp2 = (unit -> unit -> unit (a:2)) function$ -type nonrec uu = (unit -> int (a:1)) function$ -type nonrec up = (unit -> int (a:1)) function$ -type nonrec uuu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec upu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec uup = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec upp = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec uu2 = (unit -> unit -> unit (a:2)) function$ -type nonrec up2 = (unit -> unit -> unit (a:2)) function$ -type nonrec cnested = - ((string -> unit (a:1)) function$ -> unit (a:1)) function$ -type nonrec unested = - ((string -> unit (a:1)) function$ -> unit (a:1)) function$ -let (uannpoly : ('a -> string (a:1)) function$) = xx -let (uannint : (int -> string (a:1)) function$) = xx + string -> + string -> + string -> + string -> string -> string -> string -> string -> int (a:2) (a:3) (a:3) +type nonrec bTyp = string -> string -> int (a:1) (a:1) +type nonrec cTyp2 = string -> string -> int (a:2) +type nonrec uTyp2 = string -> string -> int (a:2) +type nonrec cu = unit -> int (a:1) +type nonrec cp = unit -> int (a:1) +type nonrec cuu = unit -> unit -> int (a:1) (a:1) +type nonrec cpu = unit -> unit -> int (a:1) (a:1) +type nonrec cup = unit -> unit -> int (a:1) (a:1) +type nonrec cpp = unit -> unit -> int (a:1) (a:1) +type nonrec cu2 = unit -> unit -> unit (a:2) +type nonrec cp2 = unit -> unit -> unit (a:2) +type nonrec uu = unit -> int (a:1) +type nonrec up = unit -> int (a:1) +type nonrec uuu = unit -> unit -> int (a:1) (a:1) +type nonrec upu = unit -> unit -> int (a:1) (a:1) +type nonrec uup = unit -> unit -> int (a:1) (a:1) +type nonrec upp = unit -> unit -> int (a:1) (a:1) +type nonrec uu2 = unit -> unit -> unit (a:2) +type nonrec up2 = unit -> unit -> unit (a:2) +type nonrec cnested = (string -> unit (a:1)) -> unit (a:1) +type nonrec unested = (string -> unit (a:1)) -> unit (a:1) +let (uannpoly : 'a -> string (a:1)) = xx +let (uannint : int -> string (a:1)) = xx let _ = ((fun [arity:1]x -> 34)[@att ]) let _ = ((fun [arity:1]x -> 34)[@res.async ][@att ]) let _ = preserveAttr ((fun [arity:1]x -> 34)[@att ]) @@ -53,15 +47,13 @@ let t3 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t4 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t5 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t6 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l -type nonrec arrowPath1 = (int -> string (a:1)) function$ -type nonrec arrowPath2 = (I.t -> string (a:1)) function$ -type nonrec arrowPath3 = (int -> string (a:1)) function$ -type nonrec arrowPath4 = (I.t -> string (a:1)) function$ -type nonrec callback1 = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback -type nonrec callback2 = (ReactEvent.Mouse.t -> unit as 'u (a:1)) function$ -type nonrec callback3 = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback +type nonrec arrowPath1 = int -> string (a:1) +type nonrec arrowPath2 = I.t -> string (a:1) +type nonrec arrowPath3 = int -> string (a:1) +type nonrec arrowPath4 = I.t -> string (a:1) +type nonrec callback1 = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback +type nonrec callback2 = ReactEvent.Mouse.t -> unit as 'u (a:1) +type nonrec callback3 = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback let cApp = foo 3 let uApp = foo 3 let cFun [arity:1]x = 3 @@ -71,44 +63,37 @@ let bracesFun [arity:1]x [arity:1]y = x + y let cFun2 [arity:2]x y = 3 let uFun2 [arity:2]x y = 3 let cFun2Dots [arity:2]x y = 3 -type nonrec cTyp = (string -> int (a:1)) function$ -type nonrec uTyp = (string -> int (a:1)) function$ +type nonrec cTyp = string -> int (a:1) +type nonrec uTyp = string -> int (a:1) type nonrec mixTyp = - (string -> - (string -> - string -> - (string -> - string -> string -> string -> (string -> int (a:1)) function$ (a:4)) - function$ (a:2)) - function$ (a:1)) - function$ -type nonrec bTyp = - (string -> (string -> int (a:1)) function$ (a:1)) function$ -type nonrec cTyp2 = (string -> string -> int (a:2)) function$ -type nonrec uTyp2 = (string -> string -> int (a:2)) function$ -type nonrec cu = (unit -> int (a:1)) function$ -type nonrec cp = (unit -> int (a:1)) function$ -type nonrec cuu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cpu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cup = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cpp = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec cu2 = (unit -> unit -> unit (a:2)) function$ -type nonrec cp2 = (unit -> unit -> unit (a:2)) function$ -type nonrec uu = (unit -> int (a:1)) function$ -type nonrec up = (unit -> int (a:1)) function$ -type nonrec uuu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec upu = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec uup = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec upp = (unit -> (unit -> int (a:1)) function$ (a:1)) function$ -type nonrec uu2 = (unit -> unit -> unit (a:2)) function$ -type nonrec up2 = (unit -> unit -> unit (a:2)) function$ -type nonrec cnested = - ((string -> unit (a:1)) function$ -> unit (a:1)) function$ -type nonrec unested = - ((string -> unit (a:1)) function$ -> unit (a:1)) function$ + string -> + string -> + string -> + string -> string -> string -> string -> string -> int (a:1) (a:4) (a:2) (a:1) +type nonrec bTyp = string -> string -> int (a:1) (a:1) +type nonrec cTyp2 = string -> string -> int (a:2) +type nonrec uTyp2 = string -> string -> int (a:2) +type nonrec cu = unit -> int (a:1) +type nonrec cp = unit -> int (a:1) +type nonrec cuu = unit -> unit -> int (a:1) (a:1) +type nonrec cpu = unit -> unit -> int (a:1) (a:1) +type nonrec cup = unit -> unit -> int (a:1) (a:1) +type nonrec cpp = unit -> unit -> int (a:1) (a:1) +type nonrec cu2 = unit -> unit -> unit (a:2) +type nonrec cp2 = unit -> unit -> unit (a:2) +type nonrec uu = unit -> int (a:1) +type nonrec up = unit -> int (a:1) +type nonrec uuu = unit -> unit -> int (a:1) (a:1) +type nonrec upu = unit -> unit -> int (a:1) (a:1) +type nonrec uup = unit -> unit -> int (a:1) (a:1) +type nonrec upp = unit -> unit -> int (a:1) (a:1) +type nonrec uu2 = unit -> unit -> unit (a:2) +type nonrec up2 = unit -> unit -> unit (a:2) +type nonrec cnested = (string -> unit (a:1)) -> unit (a:1) +type nonrec unested = (string -> unit (a:1)) -> unit (a:1) let pipe1 = 3 |.u f -let (uannpoly : ('a -> string (a:1)) function$) = xx -let (uannint : (int -> string (a:1)) function$) = xx +let (uannpoly : 'a -> string (a:1)) = xx +let (uannint : int -> string (a:1)) = xx let _ = ((fun [arity:1]x -> 34)[@att ]) let _ = ((fun [arity:1]x -> 34)[@res.async ][@att ]) let _ = preserveAttr ((fun [arity:1]x -> 34)[@att ]) @@ -117,12 +102,10 @@ let t0 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t1 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t2 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l let t3 (type a) (type b) [arity:2](l : a list) (x : a) = x :: l -type nonrec arrowPath1 = (int -> string (a:1)) function$ -type nonrec arrowPath2 = (I.t -> string (a:1)) function$ -type nonrec arrowPath3 = (int -> string (a:1)) function$ -type nonrec arrowPath4 = (I.t -> string (a:1)) function$ -type nonrec callback1 = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback -type nonrec callback2 = (ReactEvent.Mouse.t -> unit as 'u (a:1)) function$ -type nonrec callback3 = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback \ No newline at end of file +type nonrec arrowPath1 = int -> string (a:1) +type nonrec arrowPath2 = I.t -> string (a:1) +type nonrec arrowPath3 = int -> string (a:1) +type nonrec arrowPath4 = I.t -> string (a:1) +type nonrec callback1 = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback +type nonrec callback2 = ReactEvent.Mouse.t -> unit as 'u (a:1) +type nonrec callback3 = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/arrow.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/arrow.res.txt index eef2983731..08267a2656 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/arrow.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/arrow.res.txt @@ -83,5 +83,5 @@ let un = (() : u) type nonrec ('a, 'b) d = ('a * 'b) let c [arity:1]() = ((1, 2) : ('a, 'b) d) let fn [arity:1]f = f -type nonrec f = (int -> unit (a:1)) function$ +type nonrec f = int -> unit (a:1) let a = fn (fun [arity:1]_ -> () : f) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt index 9035f13ee8..4c6941882b 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/block.res.txt @@ -53,8 +53,7 @@ let reifyStyle (type a) [arity:1](x : 'a) = let instanceOf = ([%raw (({js|function(x,y) {return +(x instanceof y)}|js}) - [@res.template ])] : ('a -> constructor -> bool (a:2)) - function$) + [@res.template ])] : 'a -> constructor -> bool (a:2)) end in ((if (Js.typeof x) = {js|string|js} then Obj.magic String diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt index 132e76632f..21ac8611c1 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/locallyAbstractTypes.res.txt @@ -13,8 +13,7 @@ let f = ((fun (type t) -> ((fun (type s) -> [@attr ]))[@attr ]) let cancel_and_collect_callbacks : 'a 'u 'c . - (packed_callbacks list -> - ('a, 'u, 'c) promise -> packed_callbacks list (a:2)) - function$ + packed_callbacks list -> + ('a, 'u, 'c) promise -> packed_callbacks list (a:2) = fun (type x) -> fun [arity:2]callbacks_accumulator -> fun (p : (_, _, c) promise) -> () \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/functor.res.txt b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/functor.res.txt index 8e18c0f55b..834302dc14 100644 --- a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/functor.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/functor.res.txt @@ -14,13 +14,12 @@ module F() = Map module F = ((functor () -> Map)[@functorAttr ]) include functor () -> Map include ((functor () -> Map)[@functorAttr ]) -module Make(Cmp:sig type nonrec t val eq : (t -> t -> bool (a:2)) function$ - end) : +module Make(Cmp:sig type nonrec t val eq : t -> t -> bool (a:2) end) : sig type nonrec key = Cmp.t type nonrec coll val empty : coll - val add : (coll -> key -> coll (a:2)) function$ + val add : coll -> key -> coll (a:2) end = struct open Cmp diff --git a/tests/syntax_tests/data/parsing/grammar/modtype/expected/parenthesized.res.txt b/tests/syntax_tests/data/parsing/grammar/modtype/expected/parenthesized.res.txt index 051ed166ba..7a409bd420 100644 --- a/tests/syntax_tests/data/parsing/grammar/modtype/expected/parenthesized.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modtype/expected/parenthesized.res.txt @@ -4,11 +4,11 @@ module type Bt = ((Btree)[@attrIdent ][@attrParens ]) module type MyHash = sig include module type of struct include Hashtbl end - val replace : (('a, 'b) t -> 'a -> 'b -> unit (a:3)) function$ + val replace : ('a, 'b) t -> 'a -> 'b -> unit (a:3) end module type MyHash = sig include ((module type of struct include Hashtbl end)[@onModTypeOf ][@onParens ]) - val replace : (('a, 'b) t -> 'a -> 'b -> unit (a:3)) function$ + val replace : ('a, 'b) t -> 'a -> 'b -> unit (a:3) end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/modtype/expected/typeof.res.txt b/tests/syntax_tests/data/parsing/grammar/modtype/expected/typeof.res.txt index 616d14735d..7cf210a905 100644 --- a/tests/syntax_tests/data/parsing/grammar/modtype/expected/typeof.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modtype/expected/typeof.res.txt @@ -1,10 +1,10 @@ module type MyHash = sig include module type of struct include Hashtbl end - val replace : (('a, 'b) t -> 'a -> 'b -> unit (a:3)) function$ + val replace : ('a, 'b) t -> 'a -> 'b -> unit (a:3) end module type MyHash = sig include ((module type of struct include Hashtbl end)[@onModuleTypeOf ]) - val replace : (('a, 'b) t -> 'a -> 'b -> unit (a:3)) function$ + val replace : ('a, 'b) t -> 'a -> 'b -> unit (a:3) end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/modtype/expected/with.res.txt b/tests/syntax_tests/data/parsing/grammar/modtype/expected/with.res.txt index e139cf5be9..24bd049351 100644 --- a/tests/syntax_tests/data/parsing/grammar/modtype/expected/with.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modtype/expected/with.res.txt @@ -29,11 +29,8 @@ module type A = (Foo with module X.Bar := Belt.Array and module X.Bar := Belt.Array and module X.Bar := Belt.Array) module type Printable = - sig - type nonrec t - val print : (Format.formatter -> t -> unit (a:2)) function$ - end + sig type nonrec t val print : Format.formatter -> t -> unit (a:2) end module type Comparable = - sig type nonrec t val compare : (t -> t -> int (a:2)) function$ end + sig type nonrec t val compare : t -> t -> int (a:2) end module type PrintableComparable = sig include Printable include (Comparable with type t := t) end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/signature/expected/external.res.txt b/tests/syntax_tests/data/parsing/grammar/signature/expected/external.res.txt index fdd4cf2d6f..196499d2a1 100644 --- a/tests/syntax_tests/data/parsing/grammar/signature/expected/external.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/signature/expected/external.res.txt @@ -2,10 +2,9 @@ module type Signature = sig type nonrec t external linkProgram : - (t -> program:((webGlProgram)[@res.namedArgLoc ]) -> unit (a:2)) - function$ = "linkProgram"[@@send ] - external add_nat : - (nat -> int -> int -> int (a:3)) function$ = "add_nat_bytecode" - external svg : (unit -> React.element (a:1)) function$ = "svg" - external svg : (unit -> React.element (a:1)) function$ = "svg" + t -> program:((webGlProgram)[@res.namedArgLoc ]) -> unit (a:2) = + "linkProgram"[@@send ] + external add_nat : nat -> int -> int -> int (a:3) = "add_nat_bytecode" + external svg : unit -> React.element (a:1) = "svg" + external svg : unit -> React.element (a:1) = "svg" end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/signature/expected/recModule.res.txt b/tests/syntax_tests/data/parsing/grammar/signature/expected/recModule.res.txt index 189a6fdf7a..07e1700d8c 100644 --- a/tests/syntax_tests/data/parsing/grammar/signature/expected/recModule.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/signature/expected/recModule.res.txt @@ -5,7 +5,7 @@ module type Signature = type nonrec t = | Leaf of string | Node of ASet.t - val compare : (t -> t -> int (a:2)) function$ + val compare : t -> t -> int (a:2) end and ASet: (Set.S with type elt = A.t) and BTree: (Btree.S with type elt = A.t) @@ -14,7 +14,7 @@ module type Signature = type nonrec t = | Leaf of string | Node of ASet.t - val compare : (t -> t -> int (a:2)) function$ + val compare : t -> t -> int (a:2) end[@@onFirstAttr ] and ASet: (Set.S with type elt = A.t)[@@onSecondAttr ] module rec A: Btree[@@parsableOnNext ] diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/externalDefinition.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/externalDefinition.res.txt index f711d90b41..94f22ade32 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/externalDefinition.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/externalDefinition.res.txt @@ -1,12 +1,11 @@ -external clear : (t -> int -> unit (a:2)) function$ = "clear" -external add_nat : (nat -> int (a:1)) function$ = "add_nat_bytecode" +external clear : t -> int -> unit (a:2) = "clear" +external add_nat : nat -> int (a:1) = "add_nat_bytecode" external attachShader : - (t -> - program:((webGlProgram)[@res.namedArgLoc ]) -> - shader:((webGlShader)[@res.namedArgLoc ]) -> unit (a:3)) - function$ = "attachShader"[@@send ] -external svg : (unit -> React.element (a:1)) function$ = "svg" -external svg : (unit -> React.element (a:1)) function$ = "svg" -external createDate : (unit -> unit -> date (a:2)) function$ = "Date" -[@@new ] + t -> + program:((webGlProgram)[@res.namedArgLoc ]) -> + shader:((webGlShader)[@res.namedArgLoc ]) -> unit (a:3) = + "attachShader"[@@send ] +external svg : unit -> React.element (a:1) = "svg" +external svg : unit -> React.element (a:1) = "svg" +external createDate : unit -> unit -> date (a:2) = "Date"[@@new ] let foobar = (createDate ()) () \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt index 7cc204d5cf..e2396030d8 100644 --- a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/constructorDeclaration.res.txt @@ -83,11 +83,11 @@ type nonrec (_, 'value) node = mutable cachedValue: 'value ; parent: (_, 'value) node ; root: (root, 'value) node ; - updateF: ('value -> 'value (a:1)) function$ ; + updateF: 'value -> 'value (a:1) ; mutable updatedTime: float } -> (derived, 'value) node type nonrec delta = - | Compute of (< blocked_ids: unit > -> unit (a:1)) function$ + | Compute of (< blocked_ids: unit > -> unit (a:1)) type nonrec queryDelta = - | Compute of (< blocked_ids: unit > -> unit (a:1)) function$ - | Compute of (< blocked_ids: unit > -> unit (a:1)) function$ * - (< allowed_ids: unit > -> unit (a:1)) function$ \ No newline at end of file + | Compute of (< blocked_ids: unit > -> unit (a:1)) + | Compute of (< blocked_ids: unit > -> unit (a:1)) * + (< allowed_ids: unit > -> unit (a:1)) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt index 92f00566f2..1bc71f372b 100644 --- a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/privateTypeEquation.res.txt @@ -2,11 +2,11 @@ type nonrec t = private 'a type nonrec t = private string type nonrec t = private _ type nonrec t = private int -type nonrec t = private (int -> int (a:1)) function$ -type nonrec t = private (int -> int (a:1)) function$ -type nonrec t = private (int -> (int -> int (a:1)) function$ (a:1)) function$ +type nonrec t = private int -> int (a:1) +type nonrec t = private int -> int (a:1) +type nonrec t = private int -> int -> int (a:1) (a:1) type nonrec t = private - (int -> x:((string)[@res.namedArgLoc ]) -> float -> unit (a:3)) function$ + int -> x:((string)[@res.namedArgLoc ]) -> float -> unit (a:3) type nonrec t = private string as 'x type nonrec t = private [%ext ] type nonrec t = private [%ext {js|console.log|js}] diff --git a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/typeInformation.res.txt b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/typeInformation.res.txt index b802141178..82373a51cd 100644 --- a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/typeInformation.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/typeInformation.res.txt @@ -70,8 +70,6 @@ type nonrec t = private type nonrec t = { x: int ; y: int } -type nonrec callback = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback -type nonrec callback = (ReactEvent.Mouse.t -> unit as 'u (a:1)) function$ -type nonrec callback = - (ReactEvent.Mouse.t -> unit (a:1)) function$ as 'callback \ No newline at end of file +type nonrec callback = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback +type nonrec callback = ReactEvent.Mouse.t -> unit as 'u (a:1) +type nonrec callback = (ReactEvent.Mouse.t -> unit (a:1)) as 'callback \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/alias.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/alias.res.txt index b5d5ea85e6..5c9e904bf5 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/alias.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/alias.res.txt @@ -1,10 +1,10 @@ type nonrec t = string as 's type nonrec t = _ as 'underscore type nonrec t = parenthesizedType as 'parens -type nonrec t = (int -> unit (a:1)) function$ as 'arrow -type nonrec t = (int -> unit as 'unitAlias (a:1)) function$ -type nonrec t = (int -> float -> unit (a:2)) function$ as 'arrowAlias -type nonrec t = (int -> float -> unit as 'unitAlias (a:2)) function$ +type nonrec t = (int -> unit (a:1)) as 'arrow +type nonrec t = int -> unit as 'unitAlias (a:1) +type nonrec t = (int -> float -> unit (a:2)) as 'arrowAlias +type nonrec t = int -> float -> unit as 'unitAlias (a:2) type nonrec t = int as 'myNumber type nonrec t = Mod.Sub.t as 'longidentAlias type nonrec t = (int as 'r, int as 'g, int as 'b) color as 'rgb @@ -16,10 +16,10 @@ type nonrec tup = ((int as 'x) * (int as 'y)) as 'tupleAlias let (t : string as 's) = () let (t : _ as 'underscore) = () let (t : parenthesizedType as 'parens) = () -let (t : (int -> unit (a:1)) function$ as 'arrow) = () -let (t : (int -> unit as 'unitAlias (a:1)) function$) = () -let (t : (int -> float -> unit (a:2)) function$ as 'arrowAlias) = () -let (t : (int -> float -> unit as 'unitAlias (a:2)) function$) = () +let (t : (int -> unit (a:1)) as 'arrow) = () +let (t : int -> unit as 'unitAlias (a:1)) = () +let (t : (int -> float -> unit (a:2)) as 'arrowAlias) = () +let (t : int -> float -> unit as 'unitAlias (a:2)) = () let (t : int as 'myNumber) = () let (t : Mod.Sub.t as 'longidentAlias) = () let (t : (int as 'r, int as 'g, int as 'b) color as 'rgb) = () diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/es6Arrow.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/es6Arrow.res.txt index 4320d463c7..1caf71d444 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/es6Arrow.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/es6Arrow.res.txt @@ -1,71 +1,49 @@ -type nonrec t = (x -> unit (a:1)) function$ -type nonrec t = (x -> unit (a:1)) function$ -type nonrec t = (int -> string -> unit (a:2)) function$ +type nonrec t = x -> unit (a:1) +type nonrec t = x -> unit (a:1) +type nonrec t = int -> string -> unit (a:2) type nonrec t = - (a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int (a:2)) - function$ + a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int (a:2) type nonrec t = - (?a:((int)[@res.namedArgLoc ]) -> - ?b:((int)[@res.namedArgLoc ]) -> int (a:2)) - function$ + ?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int (a:2) +type nonrec t = int -> int -> int -> int (a:1) (a:1) (a:1) type nonrec t = - (int -> (int -> (int -> int (a:1)) function$ (a:1)) function$ (a:1)) - function$ -type nonrec t = - (a:((int)[@res.namedArgLoc ]) -> - (b:((int)[@res.namedArgLoc ]) -> - (c:((int)[@res.namedArgLoc ]) -> int (a:1)) function$ (a:1)) - function$ (a:1)) - function$ -let (f : (x -> unit (a:1)) function$) = xf -let (f : (x -> unit (a:1)) function$) = xf -let (f : (int -> string -> unit (a:2)) function$) = xf -let (t : - (a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int (a:2)) - function$) - = xf + a:((int)[@res.namedArgLoc ]) -> + b:((int)[@res.namedArgLoc ]) -> + c:((int)[@res.namedArgLoc ]) -> int (a:1) (a:1) (a:1) +let (f : x -> unit (a:1)) = xf +let (f : x -> unit (a:1)) = xf +let (f : int -> string -> unit (a:2)) = xf let (t : - (?a:((int)[@res.namedArgLoc ]) -> - ?b:((int)[@res.namedArgLoc ]) -> int (a:2)) - function$) + a:((int)[@res.namedArgLoc ]) -> b:((int)[@res.namedArgLoc ]) -> int (a:2)) = xf let (t : - (int -> (int -> (int -> int (a:1)) function$ (a:1)) function$ (a:1)) - function$) + ?a:((int)[@res.namedArgLoc ]) -> ?b:((int)[@res.namedArgLoc ]) -> int (a:2)) = xf +let (t : int -> int -> int -> int (a:1) (a:1) (a:1)) = xf let (t : - (a:((int)[@res.namedArgLoc ]) -> - (b:((int)[@res.namedArgLoc ]) -> - (c:((int)[@res.namedArgLoc ]) -> int (a:1)) function$ (a:1)) - function$ (a:1)) - function$) + a:((int)[@res.namedArgLoc ]) -> + b:((int)[@res.namedArgLoc ]) -> + c:((int)[@res.namedArgLoc ]) -> int (a:1) (a:1) (a:1)) = xf type nonrec t = f:((int)[@res.namedArgLoc ]) -> string type nonrec t = ?f:((int)[@res.namedArgLoc ]) -> string let (f : f:((int)[@res.namedArgLoc ]) -> string) = fx let (f : ?f:((int)[@res.namedArgLoc ]) -> string) = fx -type nonrec t = (f:((int)[@res.namedArgLoc ]) -> string (a:1)) function$ +type nonrec t = f:((int)[@res.namedArgLoc ]) -> string (a:1) type nonrec t = f:((int)[@res.namedArgLoc ]) -> string -type nonrec t = - (f:(((int -> string (a:1)) function$)[@res.namedArgLoc ]) -> float (a:1)) - function$ -type nonrec t = - f:(((int -> string (a:1)) function$)[@res.namedArgLoc ]) -> float -type nonrec t = - f:((int)[@res.namedArgLoc ]) -> (string -> float (a:1)) function$ +type nonrec t = f:((int -> string (a:1))[@res.namedArgLoc ]) -> float (a:1) +type nonrec t = f:((int -> string (a:1))[@res.namedArgLoc ]) -> float +type nonrec t = f:((int)[@res.namedArgLoc ]) -> string -> float (a:1) type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> ((b:((int)[@res.namedArgLoc ]) -> ((float)[@attr ]) -> unit)[@attrBeforeLblB ]) (a:3)) - [@attrBeforeLblA ]) function$ + [@attrBeforeLblA ]) type nonrec t = - (((a:((int)[@res.namedArgLoc ]) -> - (((b:((int)[@res.namedArgLoc ]) -> - (((float)[@attr ]) -> unit (a:1)) function$ (a:1)) - function$)[@attrBeforeLblB ]) (a:1)) - function$)[@attrBeforeLblA ]) + ((a:((int)[@res.namedArgLoc ]) -> + ((b:((int)[@res.namedArgLoc ]) -> ((float)[@attr ]) -> unit (a:1) (a:1)) + [@attrBeforeLblB ]) (a:1))[@attrBeforeLblA ]) type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> unit)[@attr ]) type nonrec 'a getInitialPropsFn = - (< query: string dict ;req: 'a Js.t Js.Nullable.t > -> - 'a Js.t Js.Promise.t (a:1)) - function$ \ No newline at end of file + < query: string dict ;req: 'a Js.t Js.Nullable.t > -> + 'a Js.t Js.Promise.t (a:1) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/firstClassModules.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/firstClassModules.res.txt index 105320cdf3..10dc94f361 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/firstClassModules.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/firstClassModules.res.txt @@ -2,7 +2,7 @@ type nonrec t = (module Hashmap) type nonrec t = (module Hashmap with type key = string) type nonrec t = (module Hashmap with type key = string and type value = int) type nonrec toValueLikeInstance = - ('a t -> (module RxValueLikeInstance.S with type a = 'a) (a:1)) function$ + 'a t -> (module RxValueLikeInstance.S with type a = 'a) (a:1) type nonrec 'a t = (module Test with type a = 'a) type nonrec t = (module Console) ref let (devices : (string, (module DEVICE)) Hastbl.t) = Hashtbl.creat 17 \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt index eb2c9f1c7a..bfe62dd69d 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/objectTypeSpreading.res.txt @@ -3,10 +3,9 @@ type nonrec u = < a ;u: int > type nonrec v = < v: int ;a > type nonrec w = < j: int ;a ;k: int ;v > type nonrec t = < a ;u: int > as 'a -type nonrec t = (< a ;u: int > -> unit (a:1)) function$ -type nonrec t = ((< a ;u: int > as 'a) -> unit (a:1)) function$ -type nonrec t = - (< a ;u: int > -> < a ;v: int > -> unit (a:2)) function$ +type nonrec t = < a ;u: int > -> unit (a:1) +type nonrec t = (< a ;u: int > as 'a) -> unit (a:1) +type nonrec t = < a ;u: int > -> < a ;v: int > -> unit (a:2) type nonrec user = < name: string > let (steve : < user ;age: int > ) = [%obj { name = {js|Steve|js}; age = 30 }] diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/parenthesized.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/parenthesized.res.txt index 566d9ac548..67be279695 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/parenthesized.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/parenthesized.res.txt @@ -1,2 +1 @@ -type nonrec t = - (((a:((int)[@res.namedArgLoc ]) -> unit (a:1)) function$)[@attr ]) \ No newline at end of file +type nonrec t = ((a:((int)[@res.namedArgLoc ]) -> unit (a:1))[@attr ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/poly.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/poly.res.txt index 65b49722d1..cca42fdbb7 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/poly.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/poly.res.txt @@ -1,12 +1,8 @@ external getLogger : - (unit -> - < - log: ('a -> unit (a:1)) function$ ;log2: 'a . - (int -> int (a:1)) - function$ ;log3: - 'a 'b . - ('a -> - 'b -> int (a:2)) - function$ - > (a:1)) - function$ = "./src/logger.mock.js" \ No newline at end of file + unit -> + < + log: 'a -> unit (a:1) ;log2: 'a . int -> int (a:1) ;log3: 'a 'b . + 'a -> + 'b -> int (a:2) + > (a:1) = + "./src/logger.mock.js" \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/polyVariant.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/polyVariant.res.txt index de6fd665c0..a60c0bbb66 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/polyVariant.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/polyVariant.res.txt @@ -3,13 +3,11 @@ module type Conjunctive = sig type nonrec u1 = [ `A | `B ] type nonrec u2 = [ `A | `B | `C ] - val f : ([< `T of [< u2]&[< u2]&[< u1] ] -> unit (a:1)) function$ - val g : ([< `S of [< u2]&[< u2]&[< u1] ] -> unit (a:1)) function$ + val f : [< `T of [< u2]&[< u2]&[< u1] ] -> unit (a:1) + val g : [< `S of [< u2]&[< u2]&[< u1] ] -> unit (a:1) val g : - ([< - `Exotic-S+ of [< `Exotic-u2+ ]&[< `Exotic-u2- ]&[< `Exotic-u1+++ ] ] - -> unit (a:1)) - function$ + [< `Exotic-S+ of [< `Exotic-u2+ ]&[< `Exotic-u2- ]&[< `Exotic-u1+++ ] ] + -> unit (a:1) end type nonrec t = [ s] type nonrec t = [ ListStyleType.t] diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/uncurried.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/uncurried.res.txt index 5f9275519c..94510d9656 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/uncurried.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/uncurried.res.txt @@ -1,25 +1,18 @@ +type nonrec t = { + mutable field: float -> int -> bool -> unit (a:3) } +type nonrec t = float -> int -> bool -> unit (a:3) type nonrec t = - { - mutable field: (float -> int -> bool -> unit (a:3)) function$ } -type nonrec t = (float -> int -> bool -> unit (a:3)) function$ + ((float)[@attr ]) -> + ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit (a:4) type nonrec t = - (((float)[@attr ]) -> - ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit (a:4)) - function$ + ((float -> + ((int)[@attr2 ]) -> + ((bool -> ((string)[@attr4 ]) -> unit (a:1) (a:1))[@attr3 ]) (a:1) (a:1)) + [@attr ]) type nonrec t = - (((float -> - (((int)[@attr2 ]) -> - (((bool -> (((string)[@attr4 ]) -> unit (a:1)) function$ (a:1)) - function$)[@attr3 ]) (a:1)) - function$ (a:1)) - function$)[@attr ]) -type nonrec t = - (((float)[@attr ]) -> - ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit (a:4)) - function$ + ((float)[@attr ]) -> + ((int)[@attr2 ]) -> ((bool)[@attr3 ]) -> ((string)[@attr4 ]) -> unit (a:4) external setTimeout : - ((unit -> unit (a:1)) function$ -> int -> timerId (a:2)) function$ = - "setTimeout"[@@val ] + (unit -> unit (a:1)) -> int -> timerId (a:2) = "setTimeout"[@@val ] external setTimeout : - ((unit -> unit (a:1)) function$ -> int -> timerId (a:2)) function$ = - "setTimeout" \ No newline at end of file + (unit -> unit (a:1)) -> int -> timerId (a:2) = "setTimeout" \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/unit.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/unit.res.txt index 9f8e5effc3..9a676f8bea 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/unit.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/unit.res.txt @@ -1,9 +1,9 @@ type nonrec t = unit -type nonrec t = (unit -> unit (a:1)) function$ -type nonrec t = (unit -> unit -> unit (a:2)) function$ -type nonrec t = (unit -> unit (a:1)) function$ -let f [arity:1](f : (unit -> unit (a:1)) function$) = f () -let f [arity:1](f : (unit -> unit (a:1)) function$) = f () -let f [arity:1](f : (unit -> unit -> unit (a:2)) function$) = f () () -external svg : (unit -> React.element (a:1)) function$ = "svg" -external thing : (unit -> unit (a:1)) function$ = "svg" \ No newline at end of file +type nonrec t = unit -> unit (a:1) +type nonrec t = unit -> unit -> unit (a:2) +type nonrec t = unit -> unit (a:1) +let f [arity:1](f : unit -> unit (a:1)) = f () +let f [arity:1](f : unit -> unit (a:1)) = f () +let f [arity:1](f : unit -> unit -> unit (a:2)) = f () () +external svg : unit -> React.element (a:1) = "svg" +external thing : unit -> unit (a:1) = "svg" \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt b/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt index 68389b0146..c15c53f0c6 100644 --- a/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt +++ b/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt @@ -88,29 +88,27 @@ include ;;int ;;(t value) = {js||js} ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0#\0\0\0\r\0\0\0&\0\0\0#\x91\xa0\xa0A\xa0$size@\xa0\xa0A\xa0$root@\xa0\xa0A\xa0'compare@@|js} - external sizeSet : ('value t -> int -> unit (a:2)) function$ = "size" + external sizeSet : 'value t -> int -> unit (a:2) = "size" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$size@|js} ;;[|(({js|use sizeGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] - external size : ('value t -> int (a:1)) function$ = "" + external size : 'value t -> int (a:1) = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} - external sizeGet : ('value t -> int (a:1)) function$ = "" + external sizeGet : 'value t -> int (a:1) = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$size@|js} external rootSet : - ('value t -> 'value node option -> unit (a:2)) function$ = "root" + 'value t -> 'value node option -> unit (a:2) = "root" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x15\0\0\0\t\0\0\0\x1a\0\0\0\x19\xb0\xa0\xa0A\x91@\xa0\xa0A\x04\x03@E\x97\xa0$root@|js} ;;[|(({js|use rootGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] - external root : ('value t -> 'value node option (a:1)) function$ = "" + external root : 'value t -> 'value node option (a:1) = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} - external rootGet : - ('value t -> 'value node option (a:1)) function$ = "" + external rootGet : 'value t -> 'value node option (a:1) = "" ;;{js|BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x10\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0$root@|js} ;;[|(({js|use compareGet instead or use {abstract = light} explicitly|js}) [@ocaml.deprecated ])|] external compare : - ('value t -> [ [%rescript.typehole ]] Js.Internal.fn (a:1)) - function$ + 'value t -> [ [%rescript.typehole ]] Js.Internal.fn (a:1) ;;(({js|Arity_2('value, 'value)], int) = "" "BS:6.0.1\x84\x95\xa6\xbe\0\0\0\x13\0\0\0\x07\0\0\0\x14\0\0\0\x13\xb0\xa0\xa0A\x91@@A\x98\xa0'compare@"; diff --git a/tests/syntax_tests/data/parsing/recovery/pattern/expected/constrained.res.txt b/tests/syntax_tests/data/parsing/recovery/pattern/expected/constrained.res.txt index 3ec1fdf0e8..1f05add130 100644 --- a/tests/syntax_tests/data/parsing/recovery/pattern/expected/constrained.res.txt +++ b/tests/syntax_tests/data/parsing/recovery/pattern/expected/constrained.res.txt @@ -10,4 +10,4 @@ Did you forget a `)` here? -;;match x with | (a : (int -> unit (a:1)) function$) -> [%rescript.exprhole ] \ No newline at end of file +;;match x with | (a : int -> unit (a:1)) -> [%rescript.exprhole ] \ No newline at end of file diff --git a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.res.txt b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.res.txt index 934880c83a..6d4c3beee9 100644 --- a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.res.txt @@ -50,7 +50,7 @@ module External = { props< module(T with type t = 'a and type key = 'key), option<'key>, - option<'key> => unit, + (option<'key> => unit), array<'a>, >, React.element, diff --git a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt index 556f6b9f0e..54bfc7895c 100644 --- a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt +++ b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt @@ -17,7 +17,7 @@ module Select: { props< module(T with type t = 'a and type key = 'key), option<'key>, - option<'key> => unit, + (option<'key> => unit), array<'a>, >, React.element, diff --git a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt index cd0180e929..0392485cb0 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt @@ -132,7 +132,7 @@ type t = @attr (foo, @attr2 ~f: bar, @attr3 ~f: baz) => unit type t = @attr (string => @attr (int => unit)) type t = @attr (string, int) => @attr (int, float) => unit type t = @attr (int => @attr (int, float) => @attr (unit => unit => unit)) -type t = @attr (@attr2 ~f: int, @attr3 ~g: float) => unit +type t = (@attr @attr2 ~f: int, @attr3 ~g: float) => unit type f = ( @attr @attr @attr @attr @attr @attr @attr @attr @attr ~f: superLong, diff --git a/tests/tests/src/gpr_2614_test.mjs b/tests/tests/src/gpr_2614_test.mjs index 29ee32cd3d..27235a950b 100644 --- a/tests/tests/src/gpr_2614_test.mjs +++ b/tests/tests/src/gpr_2614_test.mjs @@ -17,16 +17,11 @@ function ff() { v.l = 2; } -let partial_arg = "x"; - -function h0(param) { - let tmp = { +function h0(extra) { + return { + "lo-x": "x", hi: 2 }; - if (partial_arg !== undefined) { - tmp["lo-x"] = Primitive_option.valFromOption(partial_arg); - } - return tmp; } let h1 = {