diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f7a2739b0..664930cbb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - AST cleanup: Remove `Function$` entirely for function definitions. https://github.com/rescript-lang/rescript/pull/7200 - AST cleanup: store arity in function type https://github.com/rescript-lang/rescript/pull/7195 - AST cleanup: remove explicit uses of `function$` in preparation for removing the type entirely. https://github.com/rescript-lang/rescript/pull/7206 +- AST cleanup: remove `function$` entirely. https://github.com/rescript-lang/rescript/pull/7208 # 12.0.0-alpha.5 diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index f8d52255c2..20e24c4349 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -1358,7 +1358,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens in (* Find all functions in the module that returns type t *) let rec fnReturnsTypeT t = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.Types.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> fnReturnsTypeT t1 | Tarrow _ -> ( match TypeUtils.extractFunctionType ~env ~package:full.package t with diff --git a/analysis/src/CompletionJsx.ml b/analysis/src/CompletionJsx.ml index 14a241b81d..b68c06ad1a 100644 --- a/analysis/src/CompletionJsx.ml +++ b/analysis/src/CompletionJsx.ml @@ -234,7 +234,7 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package = | _ -> [] in let rec getLabels (t : Types.type_expr) = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> getLabels t1 | Tconstr (p, [propsType], _) when Path.name p = "React.component" -> ( let rec getPropsType (t : Types.type_expr) = diff --git a/analysis/src/CreateInterface.ml b/analysis/src/CreateInterface.ml index 23af97d4ce..962ea4469c 100644 --- a/analysis/src/CreateInterface.ml +++ b/analysis/src/CreateInterface.ml @@ -122,7 +122,7 @@ let printSignature ~extractor ~signature = let reactElement = Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) [] in - match (Ast_uncurried.remove_function_dollar typ).desc with + match typ.desc with | Tarrow (_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _, _) when Ident.name propsId = "props" -> diff --git a/analysis/src/SignatureHelp.ml b/analysis/src/SignatureHelp.ml index 57aed0fcd9..6aacb342c4 100644 --- a/analysis/src/SignatureHelp.ml +++ b/analysis/src/SignatureHelp.ml @@ -105,12 +105,9 @@ let findFunctionType ~currentFile ~debug ~path ~pos = let extractParameters ~signature ~typeStrForParser ~labelPrefixLen = match signature with | [{Parsetree.psig_desc = Psig_value {pval_type = expr}}] - when match - (Ast_uncurried.core_type_remove_function_dollar expr).ptyp_desc - with + when match expr.ptyp_desc with | Ptyp_arrow _ -> true | _ -> false -> - let expr = Ast_uncurried.core_type_remove_function_dollar expr in let rec extractParams expr params = match expr with | { diff --git a/analysis/src/TypeUtils.ml b/analysis/src/TypeUtils.ml index beca404835..b6613d875c 100644 --- a/analysis/src/TypeUtils.ml +++ b/analysis/src/TypeUtils.ml @@ -35,7 +35,7 @@ let findTypeViaLoc ~full ~debug (loc : Location.t) = | _ -> None let pathFromTypeExpr (t : Types.type_expr) = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tconstr (path, _typeArgs, _) | Tlink {desc = Tconstr (path, _typeArgs, _)} | Tsubst {desc = Tconstr (path, _typeArgs, _)} @@ -239,7 +239,7 @@ let rec extractObjectType ~env ~package (t : Types.type_expr) = let extractFunctionType ~env ~package typ = let rec loop ~env acc (t : Types.type_expr) = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ~env acc t1 | Tarrow (label, tArg, tRet, _, _) -> loop ~env ((label, tArg) :: acc) tRet | Tconstr (path, typeArgs, _) -> ( @@ -276,7 +276,7 @@ let maybeSetTypeArgCtx ?typeArgContextFromTypeManifest ~typeParams ~typeArgs env (* TODO(env-stuff) Maybe this could be removed entirely if we can guarantee that we don't have to look up functions from in here. *) let extractFunctionType2 ?typeArgContext ~env ~package typ = let rec loop ?typeArgContext ~env acc (t : Types.type_expr) = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> loop ?typeArgContext ~env acc t1 | Tarrow (label, tArg, tRet, _, _) -> loop ?typeArgContext ~env ((label, tArg) :: acc) tRet @@ -312,7 +312,7 @@ let rec extractType ?(printOpeningDebug = true) Printf.printf "[extract_type]--> %s" (debugLogTypeArgContext typeArgContext)); let instantiateType = instantiateType2 in - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> extractType ?typeArgContext ~printOpeningDebug:false ~env ~package t1 | Tconstr (Path.Pident {name = "option"}, [payloadTypeExpr], _) -> @@ -894,7 +894,7 @@ let rec resolveNestedPatternPath (typ : innerType) ~env ~full ~nested = let getArgs ~env (t : Types.type_expr) ~full = let rec getArgsLoop ~env (t : Types.type_expr) ~full ~currentArgumentPosition = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> getArgsLoop ~full ~env ~currentArgumentPosition t1 | Tarrow (Labelled l, tArg, tRet, _, _) -> diff --git a/compiler/frontend/ast_core_type.ml b/compiler/frontend/ast_core_type.ml index 9d3c7e05f2..3dcd465e1b 100644 --- a/compiler/frontend/ast_core_type.ml +++ b/compiler/frontend/ast_core_type.ml @@ -124,8 +124,8 @@ let get_uncurry_arity (ty : t) = | _ -> None let get_curry_arity (ty : t) = - match Ast_uncurried.core_type_remove_function_dollar ty with - | {ptyp_desc = Ptyp_arrow (_, _, _, Some arity)} -> arity + match ty.ptyp_desc with + | Ptyp_arrow (_, _, _, Some arity) -> arity | _ -> get_uncurry_arity_aux ty 0 let is_arity_one ty = get_curry_arity ty = 1 @@ -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_core_type_class_type.ml b/compiler/frontend/ast_core_type_class_type.ml index 3496203b44..eb55e017cb 100644 --- a/compiler/frontend/ast_core_type_class_type.ml +++ b/compiler/frontend/ast_core_type_class_type.ml @@ -66,7 +66,7 @@ let default_typ_mapper = Bs_ast_mapper.default_mapper.typ let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) = let loc = ty.ptyp_loc in - match (Ast_uncurried.core_type_remove_function_dollar ty).ptyp_desc with + match ty.ptyp_desc with | Ptyp_arrow (label, args, body, _) (* let it go without regard label names, it will report error later when the label is not empty diff --git a/compiler/frontend/ast_derive_js_mapper.ml b/compiler/frontend/ast_derive_js_mapper.ml index 7596e970a5..dfd2694dbb 100644 --- a/compiler/frontend/ast_derive_js_mapper.ml +++ b/compiler/frontend/ast_derive_js_mapper.ml @@ -129,9 +129,7 @@ let app1 = Ast_compatible.app1 let app2 = Ast_compatible.app2 -let ( ->~ ) a b = - Ast_uncurried.uncurried_type ~loc:Location.none ~arity:1 - (Ast_compatible.arrow ~arity:(Some 1) a b) +let ( ->~ ) a b = Ast_compatible.arrow ~arity:(Some 1) a b let raise_when_not_found_ident = Longident.Ldot (Lident Primitive_modules.util, "raiseWhenNotFound") @@ -295,8 +293,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_compatible.arrow ~arity:(Some 1) core_type result)) + (Ast_compatible.arrow ~arity:(Some 1) core_type result) in let new_type, new_tdcl = U.new_type_of_type_declaration tdcl ("abs_" ^ name) diff --git a/compiler/frontend/ast_derive_projector.ml b/compiler/frontend/ast_derive_projector.ml index a35972018e..8f36bc576b 100644 --- a/compiler/frontend/ast_derive_projector.ml +++ b/compiler/frontend/ast_derive_projector.ml @@ -120,10 +120,6 @@ 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 - in let handle_tdcl tdcl = let core_type = Ast_derive_util.core_type_of_type_declaration tdcl @@ -140,10 +136,9 @@ let init () = | Ptype_record label_declarations -> Ext_list.map label_declarations (fun {pld_name; pld_type} -> 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)) + (Ast_compatible.arrow ~arity:(Some 1) core_type + pld_type + (*arity will alwys be 1 since these are single param functions*))) | Ptype_variant constructor_declarations -> Ext_list.map constructor_declarations (fun @@ -166,11 +161,15 @@ let init () = | Some x -> x | None -> core_type in + let add_arity ~arity t = + if arity > 0 then Ast_uncurried.uncurried_type ~arity t + else t + in Ast_comb.single_non_rec_val ?attrs:gentype_attrs {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)) + |> add_arity ~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..54d39e3683 100644 --- a/compiler/frontend/ast_external_process.ml +++ b/compiler/frontend/ast_external_process.ml @@ -934,11 +934,11 @@ let handle_attributes (loc : Bs_loc.t) (type_annotation : Parsetree.core_type) Parsetree.core_type * External_ffi_types.t * Parsetree.attributes * bool = let prim_name_with_source = {name = prim_name; source = External} in let type_annotation, build_uncurried_type = - match Ast_uncurried.core_type_remove_function_dollar type_annotation with + match type_annotation with | {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/gentype/TranslateCoreType.ml b/compiler/gentype/TranslateCoreType.ml index efa11ae6f2..f2486af0b3 100644 --- a/compiler/gentype/TranslateCoreType.ml +++ b/compiler/gentype/TranslateCoreType.ml @@ -52,7 +52,8 @@ let rec translate_arrow_type ~config ~type_vars_gen ~no_function_return_dependencies ~type_env ~rev_arg_deps ~rev_args (core_type : Typedtree.core_type) = match core_type.ctyp_desc with - | Ttyp_arrow (Nolabel, core_type1, core_type2, _) -> + | Ttyp_arrow (Nolabel, core_type1, core_type2, arity) + when arity = None || rev_args = [] -> let {dependencies; type_} = core_type1 |> fun __x -> translateCoreType_ ~config ~type_vars_gen ~type_env __x @@ -63,7 +64,8 @@ let rec translate_arrow_type ~config ~type_vars_gen ~no_function_return_dependencies ~type_env ~rev_arg_deps:next_rev_deps ~rev_args:((Nolabel, type_) :: rev_args) | Ttyp_arrow - (((Labelled lbl | Optional lbl) as label), core_type1, core_type2, _) -> ( + (((Labelled lbl | Optional lbl) as label), core_type1, core_type2, arity) + when arity = None || rev_args = [] -> ( let as_label = match core_type.ctyp_attributes |> Annotation.get_gentype_as_renaming with | Some s -> s @@ -114,7 +116,6 @@ let rec translate_arrow_type ~config ~type_vars_gen and translateCoreType_ ~config ~type_vars_gen ?(no_function_return_dependencies = false) ~type_env (core_type : Typedtree.core_type) = - let core_type = Ast_uncurried.tcore_type_remove_function_dollar core_type in match core_type.ctyp_desc with | Ttyp_alias (ct, _) -> ct diff --git a/compiler/gentype/TranslateTypeExprFromTypes.ml b/compiler/gentype/TranslateTypeExprFromTypes.ml index 5f9eff9c42..100c42dc2a 100644 --- a/compiler/gentype/TranslateTypeExprFromTypes.ml +++ b/compiler/gentype/TranslateTypeExprFromTypes.ml @@ -268,7 +268,8 @@ let rec translate_arrow_type ~config ~type_vars_gen ~type_env ~rev_arg_deps | Tlink t -> translate_arrow_type ~config ~type_vars_gen ~type_env ~rev_arg_deps ~rev_args t - | Tarrow (Nolabel, type_expr1, type_expr2, _, _) -> + | Tarrow (Nolabel, type_expr1, type_expr2, _, arity) + when arity = None || rev_args = [] -> let {dependencies; type_} = type_expr1 |> fun __x -> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env __x @@ -279,8 +280,12 @@ let rec translate_arrow_type ~config ~type_vars_gen ~type_env ~rev_arg_deps ~rev_arg_deps:next_rev_deps ~rev_args:((Nolabel, type_) :: rev_args) | Tarrow - (((Labelled lbl | Optional lbl) as label), type_expr1, type_expr2, _, _) - -> ( + ( ((Labelled lbl | Optional lbl) as label), + type_expr1, + type_expr2, + _, + arity ) + when arity = None || rev_args = [] -> ( match type_expr1 |> remove_option ~label with | None -> let {dependencies; type_ = type1} = @@ -312,8 +317,7 @@ let rec translate_arrow_type ~config ~type_vars_gen ~type_env ~rev_arg_deps {dependencies = all_deps; type_ = function_type} and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env - (type_expr_ : Types.type_expr) = - let type_expr = Ast_uncurried.remove_function_dollar type_expr_ in + (type_expr : Types.type_expr) = match type_expr.desc with | Tvar None -> let type_name = 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..ae1b82696e 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 = @@ -27,61 +24,3 @@ let expr_extract_uncurried_fun (expr : Parsetree.expression) = match expr.pexp_desc with | Pexp_fun (_, _, _, _, Some _) -> expr | _ -> assert false - -(* Typed AST *) - -let tarrow_to_arity (t_arity : Types.type_expr) = - match (Ctype.repr t_arity).desc with - | Tarrow (_, _, _, _, Some arity) -> arity - | Tarrow _ -> assert false - | _ -> - Format.eprintf "t: %a@." Printtyp.raw_type_expr t_arity; - assert false - -let tarrow_to_arity_opt (t_arity : Types.type_expr) = - match (Ctype.repr t_arity).desc with - | Tarrow (_, _, _, _, arity) -> arity - | _ -> 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 t = - match t.desc with - | Tarrow (l, t1, t2, c, _) -> - {t with desc = Tarrow (l, t1, t2, c, Some arity)} - | Tconstr _ -> assert false - | Tvar _ -> t - | _ -> assert false - in - Ctype.newconstr path [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 - -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 - -let remove_function_dollar ?env typ = - match - (match env with - | Some env -> Ctype.expand_head 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/ast_untagged_variants.ml b/compiler/ml/ast_untagged_variants.ml index 61c58282f3..253791acf1 100644 --- a/compiler/ml/ast_untagged_variants.ml +++ b/compiler/ml/ast_untagged_variants.ml @@ -188,7 +188,6 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) = let get_block_type_from_typ ~env (t : Types.type_expr) : block_type option = let t = !expand_head env t in - let t = Tmp_uncurried.remove_function_dollar t in match t with | {desc = Tconstr (path, _, _)} when Path.same path Predef.path_string -> Some StringType diff --git a/compiler/ml/ctype.ml b/compiler/ml/ctype.ml index 88c78b7a13..9605e37279 100644 --- a/compiler/ml/ctype.ml +++ b/compiler/ml/ctype.ml @@ -4280,3 +4280,8 @@ let maybe_pointer_type env typ = | _ -> false) row.row_fields | _ -> true + +let get_arity env typ = + match (expand_head env typ).desc with + | Tarrow (_, _, _, _, arity) -> arity + | _ -> None diff --git a/compiler/ml/ctype.mli b/compiler/ml/ctype.mli index 207b54b6db..d7d3a1bc4f 100644 --- a/compiler/ml/ctype.mli +++ b/compiler/ml/ctype.mli @@ -324,3 +324,5 @@ val package_subtype : val variant_is_subtype : (Env.t -> Types.row_desc -> Types.type_expr -> bool) ref + +val get_arity : Env.t -> type_expr -> int option 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/tmp_uncurried.ml b/compiler/ml/tmp_uncurried.ml deleted file mode 100644 index dfa84c9631..0000000000 --- a/compiler/ml/tmp_uncurried.ml +++ /dev/null @@ -1,4 +0,0 @@ -let remove_function_dollar (typ : Types.type_expr) = - match typ.desc with - | Tconstr (Pident {name = "function$"}, [t], _) -> t - | _ -> typ diff --git a/compiler/ml/transl_recmodule.ml b/compiler/ml/transl_recmodule.ml index 5740047f35..17aa511aa2 100644 --- a/compiler/ml/transl_recmodule.ml +++ b/compiler/ml/transl_recmodule.ml @@ -50,7 +50,7 @@ let init_shape modl = | [] -> [] | Sig_value (id, {val_kind = Val_reg; val_type = ty}) :: rem -> let is_function t = - match (Ast_uncurried.remove_function_dollar t).desc with + match t.desc with | Tarrow _ -> true | _ -> false in diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index e484d20054..1f34b5fde9 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -700,8 +700,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Some arity -> let prim = let expanded = Ctype.expand_head e.exp_env e.exp_type in - let extracted = Ast_uncurried.remove_function_dollar expanded in - match (Btype.repr extracted).desc with + match (Btype.repr expanded).desc with | Tarrow (Nolabel, t, _, _, _) -> ( match (Ctype.expand_head e.exp_env t).desc with | Tconstr (Pident {name = "unit"}, [], _) -> Pjs_fn_make_unit @@ -771,10 +770,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = Ext_list.exists e.exp_attributes (fun ({txt}, _) -> txt = "res.partial") in if uncurried_partial_app then - let arity_opt = - Ast_uncurried.uncurried_type_get_arity_opt ~env:funct.exp_env - funct.exp_type - in + let arity_opt = Ctype.get_arity funct.exp_env funct.exp_type in match arity_opt with | Some arity -> let real_args = List.filter (fun (_, x) -> Option.is_some x) oargs in diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 8ef3fbfa89..6f42d5597d 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 @@ -289,7 +288,6 @@ let extract_concrete_record env ty = | _ -> raise Not_found let extract_concrete_variant env ty = - let ty = Ast_uncurried.remove_function_dollar ty in match extract_concrete_typedecl env ty with | p0, p, {type_kind = Type_variant cstrs} -> (p0, p, cstrs) | p0, p, {type_kind = Type_open} -> (p0, p, []) @@ -725,7 +723,7 @@ let show_extra_help ppf _env trace = | _ -> () let rec collect_missing_arguments env type1 type2 = - match Ast_uncurried.remove_function_dollar type1 with + match type1 with (* why do we use Ctype.matches here? Please see https://github.com/rescript-lang/rescript-compiler/pull/2554 *) | {Types.desc = Tarrow (label, argtype, typ, _, _)} when Ctype.matches env typ type2 -> @@ -1907,12 +1905,9 @@ let rec approx_type env sty = let rec type_approx env sexp = match sexp.pexp_desc with | Pexp_let (_, _, e) -> type_approx env e - | Pexp_fun (p, _, _, e, arity) -> ( + | Pexp_fun (p, _, _, e, arity) -> let ty = if is_optional p then type_option (newvar ()) else newvar () in - let t = newty (Tarrow (p, ty, type_approx env e, Cok, arity)) in - match arity with - | None -> t - | Some arity -> Ast_uncurried.make_uncurried_type ~env ~arity t) + newty (Tarrow (p, ty, type_approx env e, Cok, arity)) | Pexp_match (_, {pc_rhs = e} :: _) -> type_approx env e | Pexp_try (e, _) -> type_approx env e | Pexp_tuple l -> newty (Ttuple (List.map (type_approx env) l)) @@ -1945,7 +1940,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) @@ -3262,8 +3257,7 @@ and type_function ?in_function ~arity loc attrs env ty_expected_ l caselist = | None -> ty_expected_ | Some arity -> let fun_t = newty (Tarrow (l, newvar (), newvar (), Cok, Some arity)) in - let uncurried_typ = Ast_uncurried.make_uncurried_type ~env ~arity fun_t in - unify_exp_types loc env uncurried_typ ty_expected_; + unify_exp_types loc env fun_t ty_expected_; fun_t in let loc_fun, ty_fun = @@ -3306,11 +3300,6 @@ and type_function ?in_function ~arity loc attrs env ty_expected_ l caselist = let exp_type = instance env (newgenty (Tarrow (l, ty_arg, ty_res, Cok, arity))) in - let exp_type = - match arity with - | None -> exp_type - | Some arity -> Ast_uncurried.make_uncurried_type ~env ~arity exp_type - in Warnings.restore state; re { @@ -3522,49 +3511,39 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : | Tvar _ when total_app -> true | _ -> false in - let has_uncurried_type funct = + let has_arity funct = let t = funct.exp_type in - let inner_t = Ast_uncurried.remove_function_dollar ~env t in - if force_tvar then Some (List.length sargs, inner_t) + if force_tvar then Some (List.length sargs) else - match (Ctype.repr inner_t).desc with - | Tarrow (_, _, _, _, Some arity) -> Some (arity, inner_t) + match (Ctype.repr t).desc with + | Tarrow (_, _, _, _, Some arity) -> Some arity | _ -> None in let force_uncurried_type funct = - if force_tvar then - let arity = List.length sargs in - let uncurried_typ = - Ast_uncurried.make_uncurried_type ~env ~arity (newvar ()) - in - unify_exp env funct uncurried_typ - else if - Ast_uncurried.tarrow_to_arity_opt - (Ast_uncurried.remove_function_dollar ~env funct.exp_type) - = None - then + if force_tvar then () + else if Ctype.get_arity env funct.exp_type = None then raise (Error ( funct.exp_loc, env, Apply_non_function (expand_head env funct.exp_type) )) in - let extract_uncurried_type funct = - let t = funct.exp_type in - match has_uncurried_type funct with - | Some (arity, t1) -> + let get_max_arity funct = + match has_arity funct with + | Some arity -> if List.length sargs > arity then raise (Error ( funct.exp_loc, env, - Uncurried_arity_mismatch (t, arity, List.length sargs) )); - (t1, arity) - | None -> (t, max_int) + Uncurried_arity_mismatch + (funct.exp_type, arity, List.length sargs) )); + arity + | None -> max_int in let update_uncurried_arity ~nargs funct new_t = - match has_uncurried_type funct with - | Some (arity, _) -> + match has_arity funct with + | Some arity -> let newarity = arity - nargs in let fully_applied = newarity <= 0 in if total_app && not fully_applied then @@ -3576,7 +3555,11 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : (funct.exp_type, arity, List.length sargs) )); let new_t = if fully_applied then new_t - else Ast_uncurried.make_uncurried_type ~env ~arity:newarity new_t + else + match new_t.desc with + | Tarrow (l, t1, t2, c, _) -> + {new_t with desc = Tarrow (l, t1, t2, c, Some newarity)} + | _ -> new_t in (fully_applied, new_t) | _ -> (false, new_t) @@ -3700,25 +3683,8 @@ 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 max_arity = get_max_arity funct in let top_arity = if total_app then Some max_arity else None in match sargs with (* Special case for ignore: avoid discarding warning *) @@ -3728,7 +3694,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 () -> @@ -3737,7 +3703,8 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : ([(Nolabel, Some exp)], ty_res, false) | _ -> let targs, ret_t = - type_args ?type_clash_context max_arity [] [] ~ty_fun:ty (instance env ty) + type_args ?type_clash_context max_arity [] [] ~ty_fun:funct.exp_type + (instance env funct.exp_type) ~sargs ~top_arity in let fully_applied, ret_t = @@ -4273,16 +4240,6 @@ let type_expr ppf typ = Printtyp.type_expr ppf typ let report_error env ppf error = - let error = - match error with - | Expr_type_clash ((t1, s1) :: (t2, s2) :: trace, type_clash_context) -> - let s1 = Ast_uncurried.remove_function_dollar s1 in - let s2 = Ast_uncurried.remove_function_dollar s2 in - let t1 = Ast_uncurried.remove_function_dollar t1 in - let t2 = Ast_uncurried.remove_function_dollar t2 in - Expr_type_clash ((t1, s1) :: (t2, s2) :: trace, type_clash_context) - | _ -> error - in match error with | Polymorphic_label lid -> fprintf ppf "@[The record field %a is polymorphic.@ %s@]" longident lid @@ -4345,23 +4302,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 +4484,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/typedecl.ml b/compiler/ml/typedecl.ml index 1fa6f403c2..2ee75b062a 100644 --- a/compiler/ml/typedecl.ml +++ b/compiler/ml/typedecl.ml @@ -1796,10 +1796,10 @@ let rec arity_from_arrow_type env core_type ty = | _ -> 0 let parse_arity env core_type ty = - match Ast_uncurried.uncurried_type_get_arity_opt ~env ty with + match Ctype.get_arity env ty with | Some arity -> let from_constructor = - match (Ast_uncurried.remove_function_dollar ty).desc with + match ty.desc with | Tconstr (_, _, _) -> true | _ -> false in 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/jsx_v4.ml b/compiler/syntax/src/jsx_v4.ml index ad2f7ad5fd..62a1d3eb85 100644 --- a/compiler/syntax/src/jsx_v4.ml +++ b/compiler/syntax/src/jsx_v4.ml @@ -1309,9 +1309,6 @@ let transform_structure_item ~config item = check_multiple_components ~config ~loc:pstr_loc; check_string_int_attribute_iter.structure_item check_string_int_attribute_iter item; - let pval_type = - Ast_uncurried.core_type_remove_function_dollar pval_type - in let core_type_of_attr = Jsx_common.core_type_of_attrs pval_attributes in let typ_vars_of_core_type = core_type_of_attr @@ -1414,9 +1411,6 @@ let transform_signature_item ~config item = | [] -> [item] | [_] -> check_multiple_components ~config ~loc:psig_loc; - let pval_type = - Ast_uncurried.core_type_remove_function_dollar pval_type - in check_string_int_attribute_iter.signature_item check_string_int_attribute_iter item; let core_type_of_attr = Jsx_common.core_type_of_attrs pval_attributes in diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index b7428e53c3..db73f913e0 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -1831,7 +1831,6 @@ and walk_row_field (row_field : Parsetree.row_field) t comments = | Rinherit _ -> () and walk_core_type typ t comments = - let typ = Ast_uncurried.core_type_remove_function_dollar typ in match typ.Parsetree.ptyp_desc with | _ when comments = [] -> () | Ptyp_tuple typexprs -> diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index e678dd9092..02c660b9d3 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -4071,10 +4071,8 @@ and parse_poly_type_expr p = let typ = Ast_helper.Typ.var ~loc:var.loc var.txt in let return_type = parse_typ_expr ~alias:false p in let loc = mk_loc typ.Parsetree.ptyp_loc.loc_start p.prev_end_pos in - 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_helper.Typ.arrow ~loc ~arity:(Some 1) Asttypes.Nolabel typ + return_type | _ -> Ast_helper.Typ.var ~loc:var.loc var.txt) | _ -> assert false) | _ -> parse_typ_expr p @@ -4429,7 +4427,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) @@ -4486,10 +4484,7 @@ and parse_arrow_type_rest ~es6_arrow ~start_pos typ p = Parser.next p; let return_type = parse_typ_expr ~alias:false p in let loc = mk_loc start_pos p.prev_end_pos in - 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_helper.Typ.arrow ~loc ~arity:(Some 1) Asttypes.Nolabel typ return_type | _ -> typ and parse_typ_expr_region p = @@ -5096,12 +5091,9 @@ and parse_type_equation_or_constr_decl p = let return_type = parse_typ_expr ~alias:false p in let loc = mk_loc uident_start_pos p.prev_end_pos in let arrow_type = - Ast_helper.Typ.arrow ~loc ~arity:None Asttypes.Nolabel typ return_type + Ast_helper.Typ.arrow ~loc ~arity:(Some 1) Asttypes.Nolabel typ + return_type in - let arrow_type = - Ast_uncurried.uncurried_type ~loc ~arity:1 arrow_type - in - let typ = parse_type_alias p arrow_type in (Some typ, Asttypes.Public, Parsetree.Ptype_abstract) | _ -> (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_parens.ml b/compiler/syntax/src/res_parens.ml index c12bc4c959..786afca935 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -454,7 +454,7 @@ let mod_expr_parens mod_expr = | _ -> false let arrow_return_typ_expr typ_expr = - match (Ast_uncurried.core_type_remove_function_dollar typ_expr).ptyp_desc with + match typ_expr.Parsetree.ptyp_desc with | Ptyp_arrow _ -> true | _ -> false 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..d8e7626948 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 @@ -1620,7 +1617,7 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = in let typ_doc = let doc = print_typ_expr ~state n cmt_tbl in - match (Ast_uncurried.core_type_remove_function_dollar n).ptyp_desc with + match n.ptyp_desc with | Ptyp_arrow _ | Ptyp_tuple _ | Ptyp_alias _ -> add_parens doc | _ -> doc in @@ -1666,7 +1663,6 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = Doc.group (Doc.concat [rendered_args; Doc.text " => "; return_doc]) in let rendered_type = - let typ_expr = Ast_uncurried.core_type_remove_function_dollar typ_expr in match typ_expr.ptyp_desc with | Ptyp_any -> Doc.text "_" | Ptyp_var var -> @@ -1680,9 +1676,7 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = * Is the "as" part of "unit" or "(string, float) => unit". By printing * parens we guide the user towards its meaning.*) let needs_parens = - match - (Ast_uncurried.core_type_remove_function_dollar typ).ptyp_desc - with + match typ.ptyp_desc with | Ptyp_arrow _ -> true | _ -> false in @@ -1839,9 +1833,7 @@ and print_typ_expr ~(state : State.t) (typ_expr : Parsetree.core_type) cmt_tbl = ]) in let should_print_its_own_attributes = - match - (Ast_uncurried.core_type_remove_function_dollar typ_expr).ptyp_desc - with + match typ_expr.ptyp_desc with | Ptyp_arrow _ (* es6 arrow types print their own attributes *) -> true | _ -> false in 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 = { diff --git a/tools/src/tools.ml b/tools/src/tools.ml index 160b0ae19c..e0bdc28c37 100644 --- a/tools/src/tools.ml +++ b/tools/src/tools.ml @@ -380,7 +380,7 @@ let path_to_string path = let valueDetail (typ : Types.type_expr) = let rec collectSignatureTypes (typ : Types.type_expr) = - match (Ast_uncurried.remove_function_dollar typ).desc with + match typ.desc with | Tlink t | Tsubst t | Tpoly (t, []) -> collectSignatureTypes t | Tconstr (path, ts, _) -> ( let p = path_to_string path in