From e7e9562e7f61f3b6d2d61fdfba9afe65760056d4 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 12 Dec 2024 10:52:27 +0100 Subject: [PATCH 01/17] wip remove Function$ --- compiler/frontend/ast_derive_js_mapper.ml | 6 +-- compiler/frontend/ast_derive_projector.ml | 8 ++-- compiler/ml/ast_uncurried.ml | 16 ++----- compiler/ml/translcore.ml | 44 +++++++++---------- compiler/ml/typecore.ml | 52 +++++++++++++---------- compiler/syntax/src/jsx_v4.ml | 3 +- compiler/syntax/src/res_comments_table.ml | 2 - compiler/syntax/src/res_core.ml | 6 +-- 8 files changed, 64 insertions(+), 73 deletions(-) diff --git a/compiler/frontend/ast_derive_js_mapper.ml b/compiler/frontend/ast_derive_js_mapper.ml index ca10a03da1..cb2f7385b7 100644 --- a/compiler/frontend/ast_derive_js_mapper.ml +++ b/compiler/frontend/ast_derive_js_mapper.ml @@ -169,7 +169,7 @@ let init () = in let to_js_body body = Ast_comb.single_non_rec_value pat_to_js - (Ast_uncurried.uncurried_fun ~loc:Location.none ~arity:1 + (Ast_uncurried.uncurried_fun ~arity:1 (Ast_compatible.fun_ ~arity:None (Pat.constraint_ (Pat.var pat_param) core_type) body)) @@ -214,7 +214,7 @@ let init () = in let from_js = Ast_comb.single_non_rec_value pat_from_js - (Ast_uncurried.uncurried_fun ~loc:Location.none ~arity:1 + (Ast_uncurried.uncurried_fun ~arity:1 (Ast_compatible.fun_ ~arity:(Some 1) (Pat.var pat_param) (if create_type then Exp.let_ Nonrecursive @@ -260,7 +260,7 @@ let init () = app2 unsafe_index_get_exp exp_map exp_param else app1 erase_type_exp exp_param); Ast_comb.single_non_rec_value pat_from_js - (Ast_uncurried.uncurried_fun ~loc:Location.none ~arity:1 + (Ast_uncurried.uncurried_fun ~arity:1 (Ast_compatible.fun_ ~arity:(Some 1) (Pat.var pat_param) (let result = diff --git a/compiler/frontend/ast_derive_projector.ml b/compiler/frontend/ast_derive_projector.ml index 86514c4ef0..2fab2e2a3b 100644 --- a/compiler/frontend/ast_derive_projector.ml +++ b/compiler/frontend/ast_derive_projector.ml @@ -20,9 +20,9 @@ let init () = { structure_gen = (fun (tdcls : tdcls) _explict_nonrec -> - let handle_uncurried_accessor_tranform ~loc ~arity accessor = + let handle_uncurried_accessor_tranform ~arity accessor = (* Accessors with no params (arity of 0) are simply values and not functions *) - if arity > 0 then Ast_uncurried.uncurried_fun ~loc ~arity accessor + if arity > 0 then Ast_uncurried.uncurried_fun ~arity accessor else accessor in let handle_tdcl tdcl = @@ -52,7 +52,7 @@ let init () = (Exp.ident {txt = Lident txt; loc}) {txt = Longident.Lident pld_label; loc}) (*arity will alwys be 1 since these are single param functions*) - |> handle_uncurried_accessor_tranform ~arity:1 ~loc)) + |> handle_uncurried_accessor_tranform ~arity:1)) | Ptype_variant constructor_declarations -> Ext_list.map constructor_declarations (fun @@ -111,7 +111,7 @@ let init () = Ast_compatible.fun_ ~arity:(Some 1) (Pat.var {loc; txt = var}) b) - |> handle_uncurried_accessor_tranform ~loc ~arity)) + |> handle_uncurried_accessor_tranform ~arity)) | Ptype_abstract | Ptype_open -> Ast_derive_util.not_applicable tdcl.ptype_loc deriving_name; [] diff --git a/compiler/ml/ast_uncurried.ml b/compiler/ml/ast_uncurried.ml index 09cfc1046d..4f4c271d45 100644 --- a/compiler/ml/ast_uncurried.ml +++ b/compiler/ml/ast_uncurried.ml @@ -19,31 +19,23 @@ let uncurried_type ~loc ~arity t_arg = let t_arity = arity_type ~loc arity in Ast_helper.Typ.constr ~loc {txt = Lident "function$"; loc} [t_arg; t_arity] -let uncurried_fun ~loc ~arity fun_expr = +let uncurried_fun ~arity fun_expr = let fun_expr = match fun_expr.Parsetree.pexp_desc with | Pexp_fun (l, eo, p, e, _) -> {fun_expr with pexp_desc = Pexp_fun (l, eo, p, e, Some arity)} | _ -> assert false in - Ast_helper.Exp.construct ~loc - (Location.mknoloc (Longident.Lident "Function$")) - (Some fun_expr) + fun_expr let expr_is_uncurried_fun (expr : Parsetree.expression) = match expr.pexp_desc with - | Pexp_construct ({txt = Lident "Function$"}, Some _) -> true + | Pexp_fun (_, _, _, _, Some _) -> true | _ -> false let expr_extract_uncurried_fun (expr : Parsetree.expression) = match expr.pexp_desc with - | Pexp_construct ({txt = Lident "Function$"}, Some e) -> - let () = - match e.pexp_desc with - | Pexp_fun (_, _, _, _, Some _arity) -> () - | _ -> assert false - in - e + | Pexp_fun (_, _, _, _, Some _) -> expr | _ -> assert false let remove_fun (expr : Parsetree.expression) = diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 59febcda45..9460b1f681 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -674,7 +674,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Texp_constant cst -> Lconst (Const_base cst) | Texp_let (rec_flag, pat_expr_list, body) -> transl_let rec_flag pat_expr_list (transl_exp body) - | Texp_function {arg_label = _; param; case; partial} -> + | Texp_function {arg_label = _; arity; param; case; partial} -> ( let async = has_async_attribute e in let directive = match extract_directive_for_fn e with @@ -695,7 +695,26 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = } in let loc = e.exp_loc in - Lfunction {params; body; attr; loc} + let lambda = Lfunction {params; body; attr; loc} in + match arity with + | Some arity -> + let prim = + match + (Ast_uncurried.type_extract_uncurried_fun + (Ctype.expand_head e.exp_env e.exp_type)) + .desc + with + | Tarrow (Nolabel, t, _, _) -> ( + match (Ctype.expand_head e.exp_env t).desc with + | Tconstr (Pident {name = "unit"}, [], _) -> Pjs_fn_make_unit + | _ -> Pjs_fn_make arity) + | _ -> Pjs_fn_make arity + in + Lprim + ( prim (* could be replaced with Opaque in the future except arity 0*), + [lambda], + loc ) + | None -> lambda) | Texp_apply ( ({ exp_desc = Texp_ident (_, _, {val_kind = Val_prim p}); @@ -781,27 +800,6 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = with Not_constant -> Lprim (Pmakeblock Blk_tuple, ll, e.exp_loc)) | Texp_construct ({txt = Lident "false"}, _, []) -> Lconst Const_false | Texp_construct ({txt = Lident "true"}, _, []) -> Lconst Const_true - | Texp_construct - ({txt = Lident "Function$"}, _, [({exp_desc = Texp_function _} as expr)]) - -> - (* ReScript uncurried encoding *) - let loc = expr.exp_loc in - let lambda = transl_exp expr in - let arity = - Ast_uncurried.uncurried_type_get_arity ~env:e.exp_env e.exp_type - in - let prim = - match (Ctype.expand_head expr.exp_env expr.exp_type).desc with - | Tarrow (Nolabel, t, _, _) -> ( - match (Ctype.expand_head expr.exp_env t).desc with - | Tconstr (Pident {name = "unit"}, [], _) -> Pjs_fn_make_unit - | _ -> Pjs_fn_make arity) - | _ -> Pjs_fn_make arity - in - Lprim - ( prim (* could be replaced with Opaque in the future except arity 0*), - [lambda], - loc ) | Texp_construct (lid, cstr, args) -> ( let ll = transl_list args in if cstr.cstr_inlined <> None then diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 992e64403d..8af809c5c8 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -1913,9 +1913,12 @@ 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 - newty (Tarrow (p, ty, type_approx env e, Cok)) + let t = newty (Tarrow (p, ty, type_approx env e, Cok)) in + match arity with + | None -> t + | Some arity -> Ast_uncurried.make_uncurried_type ~env ~arity t) | 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)) @@ -2525,25 +2528,6 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp exp_attributes = sexp.pexp_attributes; exp_env = env; } - | Pexp_construct - ( ({txt = Lident "Function$"} as lid), - (Some {pexp_desc = Pexp_fun (_, _, _, _, Some arity)} as sarg) ) -> - let state = Warnings.backup () in - let uncurried_typ = - Ast_uncurried.make_uncurried_type ~env ~arity (newvar ()) - in - unify_exp_types loc env uncurried_typ ty_expected; - (* Disable Unerasable_optional_argument for uncurried functions *) - let unerasable_optional_argument = - Warnings.number Unerasable_optional_argument - in - Warnings.parse_options false - ("-" ^ string_of_int unerasable_optional_argument); - let exp = - type_construct env loc lid sarg uncurried_typ sexp.pexp_attributes - in - Warnings.restore state; - exp | Pexp_construct (lid, sarg) -> type_construct env loc lid sarg ty_expected sexp.pexp_attributes | Pexp_variant (l, sarg) -> ( @@ -3273,7 +3257,22 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp | Pexp_extension ext -> raise (Error_forward (Builtin_attributes.error_of_extension ext)) -and type_function ?in_function ~arity loc attrs env ty_expected l caselist = +and type_function ?in_function ~arity loc attrs env ty_expected_ l caselist = + let state = Warnings.backup () in + (* Disable Unerasable_optional_argument for uncurried functions *) + let unerasable_optional_argument = + Warnings.number Unerasable_optional_argument + in + Warnings.parse_options false ("-" ^ string_of_int unerasable_optional_argument); + let ty_expected = + match arity with + | None -> ty_expected_ + | Some arity -> + let fun_t = newvar () in + let uncurried_typ = Ast_uncurried.make_uncurried_type ~env ~arity fun_t in + unify_exp_types loc env uncurried_typ ty_expected_; + fun_t + in let loc_fun, ty_fun = match in_function with | Some p -> p @@ -3311,12 +3310,19 @@ and type_function ?in_function ~arity loc attrs env ty_expected l caselist = Location.prerr_warning case.c_lhs.pat_loc Warnings.Unerasable_optional_argument; let param = name_pattern "param" cases in + let exp_type = instance env (newgenty (Tarrow (l, ty_arg, ty_res, Cok))) 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 { exp_desc = Texp_function {arg_label = l; arity; param; case; partial}; exp_loc = loc; exp_extra = []; - exp_type = instance env (newgenty (Tarrow (l, ty_arg, ty_res, Cok))); + exp_type; exp_attributes = attrs; exp_env = env; } diff --git a/compiler/syntax/src/jsx_v4.ml b/compiler/syntax/src/jsx_v4.ml index e8fe6defd4..86bbc5ee0f 100644 --- a/compiler/syntax/src/jsx_v4.ml +++ b/compiler/syntax/src/jsx_v4.ml @@ -1028,8 +1028,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding = in let full_expression = full_expression - |> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc - ~arity:(if has_forward_ref then 2 else 1) + |> Ast_uncurried.uncurried_fun ~arity:(if has_forward_ref then 2 else 1) in let full_expression = match full_module_name with diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index ac168be7fb..fc8c104944 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -1451,8 +1451,6 @@ and walk_expression expr t comments = attach t.leading expr.pexp_loc leading; walk_expression expr t inside; attach t.trailing expr.pexp_loc trailing - | Pexp_construct ({txt = Longident.Lident "Function$"}, Some return_expr) -> - walk_expression return_expr t comments | _ -> if is_block_expr return_expr then walk_expression return_expr t comments else diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index e99a4ec156..676df152e5 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -528,7 +528,7 @@ let process_underscore_application args = let fun_expr = Ast_helper.Exp.fun_ ~loc ~arity:(Some 1) Nolabel None pattern exp_apply in - Ast_uncurried.uncurried_fun ~loc ~arity:1 fun_expr + Ast_uncurried.uncurried_fun ~arity:1 fun_expr | None -> exp_apply in (args, wrap) @@ -1600,9 +1600,7 @@ and parse_es6_arrow_expression ?(arrow_attrs = []) ?(arrow_start_pos = None) expr in if term_param_num = 1 then - ( term_param_num - 1, - Ast_uncurried.uncurried_fun ~loc ~arity fun_expr, - 1 ) + (term_param_num - 1, Ast_uncurried.uncurried_fun ~arity fun_expr, 1) else (term_param_num - 1, fun_expr, arity + 1) | TypeParameter {attrs; locs = newtypes; pos = start_pos} -> ( term_param_num, From 5a3234aab45a0ffd27cb00c4a7fca567e67c71d6 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 12 Dec 2024 21:06:18 +0100 Subject: [PATCH 02/17] printer --- compiler/ml/pprintast.ml | 2 +- compiler/syntax/src/res_parens.ml | 2 +- compiler/syntax/src/res_parsetree_viewer.ml | 29 +- compiler/syntax/src/res_parsetree_viewer.mli | 2 +- compiler/syntax/src/res_printer.ml | 10 +- .../reason/expected/fastPipe.res.txt | 2 +- .../reason/expected/underscoreSugar.res.txt | 2 +- .../errors/expressions/expected/array.res.txt | 2 +- .../errors/expressions/expected/arrow.res.txt | 5 +- .../errors/expressions/expected/block.res.txt | 35 +- .../expressions/expected/consecutive.res.txt | 4 +- .../expressions/expected/emptyBlock.res.txt | 2 +- .../expected/implementation.res.txt | 4 +- .../other/expected/labelledParameters.res.txt | 9 +- .../errors/structure/expected/gh16B.res.txt | 22 +- .../structure/expected/letBinding.res.txt | 3 +- .../typeDef/expected/inlineRecord.res.txt | 14 +- .../typexpr/expected/objectSpread.res.txt | 2 +- .../expected/UncurriedAlways.res.txt | 4 +- .../expected/UncurriedByDefault.res.txt | 95 +-- .../expressions/expected/apply.res.txt | 14 +- .../expressions/expected/argument.res.txt | 11 +- .../expressions/expected/arrow.res.txt | 172 ++--- .../expressions/expected/async.res.txt | 36 +- .../expressions/expected/await.res.txt | 18 +- .../expressions/expected/binary.res.txt | 2 +- .../expected/binaryNoEs6Arrow.res.txt | 18 +- .../expressions/expected/block.res.txt | 84 +- .../expected/bracedOrRecord.res.txt | 18 +- .../expressions/expected/coerce.res.txt | 4 +- .../expressions/expected/extension.res.txt | 2 +- .../expected/firstClassModule.res.txt | 82 +- .../grammar/expressions/expected/jsx.res.txt | 293 ++++--- .../expected/locallyAbstractTypes.res.txt | 28 +- .../expressions/expected/record.res.txt | 8 +- .../expected/tupleVsDivision.res.txt | 6 +- .../expressions/expected/uncurried.res.txt | 36 +- .../expected/underscoreApply.res.txt | 48 +- .../grammar/modexpr/expected/apply.res.txt | 6 +- .../expected/firstClassModules.res.txt | 19 +- .../grammar/modexpr/expected/functor.res.txt | 23 +- .../grammar/pattern/expected/any.res.txt | 14 +- .../grammar/pattern/expected/array.res.txt | 10 +- .../grammar/pattern/expected/constant.res.txt | 40 +- .../pattern/expected/constructor.res.txt | 33 +- .../grammar/pattern/expected/dict.res.txt | 39 +- .../pattern/expected/exception.res.txt | 16 +- .../pattern/expected/extension.res.txt | 15 +- .../expected/firstClassModules.res.txt | 27 +- .../grammar/pattern/expected/list.res.txt | 34 +- .../pattern/expected/polyvariants.res.txt | 60 +- .../grammar/pattern/expected/record.res.txt | 37 +- .../grammar/pattern/expected/tuple.res.txt | 15 +- .../grammar/pattern/expected/unit.res.txt | 20 +- .../pattern/expected/variantSpreads.res.txt | 82 +- .../grammar/pattern/expected/variants.res.txt | 31 +- .../signature/expected/itemExtension.res.txt | 2 +- .../expected/standAloneAttribute.res.txt | 2 +- .../structure/expected/itemExtension.res.txt | 2 +- .../structure/expected/letBinding.res.txt | 11 +- .../expected/modExprExtension.res.txt | 2 +- .../expected/moduleTypeExtension.res.txt | 3 +- .../expected/standaloneAttribute.res.txt | 2 +- .../expected/polyvariant.res.txt | 2 +- .../expected/objectTypeSpreading.res.txt | 28 +- .../typexpr/expected/typeconstr.res.txt | 2 +- .../grammar/typexpr/expected/unit.res.txt | 14 +- .../expected/equalAfterBinaryExpr.res.txt | 290 ++++--- .../expected/nonRecTypes.res.txt | 723 ++++++++---------- .../expected/templateEof.res.txt | 5 +- .../expression/expected/emptyBlock.res.txt | 2 +- .../recovery/expression/expected/list.res.txt | 17 +- .../ppx/react/expected/typeConstraint.res.txt | 12 +- .../printer/expr/expected/asyncAwait.res.txt | 4 +- .../printer/expr/expected/callback.res.txt | 8 +- .../data/printer/expr/expected/record.res.txt | 2 +- .../expr/expected/underscoreApply.res.txt | 22 +- 77 files changed, 1193 insertions(+), 1613 deletions(-) diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index 2f3de443c7..f78c40db9b 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -954,7 +954,7 @@ and binding ctxt f {pvb_pat=p; pvb_expr=x; _} = | Pexp_fun (label, eo, p, e, arity) -> let arity_str = match arity with | None -> "" - | Some arity -> "arity:" ^ string_of_int arity + | Some arity -> "[arity:" ^ string_of_int arity ^ "]" in if label=Nolabel then pp f "%s%a@ %a" arity_str (simple_pattern ctxt) p pp_print_pexp_function e diff --git a/compiler/syntax/src/res_parens.ml b/compiler/syntax/src/res_parens.ml index f8d8cc1bb5..ad6256d9ea 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -304,7 +304,7 @@ let ternary_operand expr = Nothing | {pexp_desc = Pexp_constraint _} -> Parenthesized | _ when Res_parsetree_viewer.is_fun_newtype expr -> ( - let _uncurried, _attrsOnArrow, _parameters, return_expr = + let _attrsOnArrow, _parameters, return_expr = ParsetreeViewer.fun_expr expr in match return_expr.pexp_desc with diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index aa74b0992b..5c55feb51a 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -178,7 +178,7 @@ let fun_expr expr = collect_new_types (string_loc :: acc) return_expr | return_expr -> (List.rev acc, return_expr) in - let rec collect ~uncurried ~n_fun attrs_before acc expr = + let rec collect ~n_fun attrs_before acc expr = match expr with | { pexp_desc = @@ -189,37 +189,32 @@ let fun_expr expr = {pexp_desc = Pexp_apply _}, _ ); } -> - (uncurried, attrs_before, List.rev acc, rewrite_underscore_apply expr) + (attrs_before, List.rev acc, rewrite_underscore_apply expr) | {pexp_desc = Pexp_newtype (string_loc, rest); pexp_attributes = attrs} -> let string_locs, return_expr = collect_new_types [string_loc] rest in let param = NewTypes {attrs; locs = string_locs} in - collect ~uncurried ~n_fun attrs_before (param :: acc) return_expr + collect ~n_fun attrs_before (param :: acc) return_expr | { - pexp_desc = Pexp_fun (lbl, default_expr, pattern, return_expr, _); + pexp_desc = Pexp_fun (lbl, default_expr, pattern, return_expr, arity); pexp_attributes = []; - } -> + } + when arity = None || n_fun = 0 -> let parameter = Parameter {attrs = []; lbl; default_expr; pat = pattern} in - collect ~uncurried ~n_fun:(n_fun + 1) attrs_before (parameter :: acc) - return_expr + collect ~n_fun:(n_fun + 1) attrs_before (parameter :: acc) return_expr (* If a fun has an attribute, then it stops here and makes currying. i.e attributes outside of (...), uncurried `(.)` and `async` make currying *) - | {pexp_desc = Pexp_fun _} -> (uncurried, attrs_before, List.rev acc, expr) + | {pexp_desc = Pexp_fun _} -> (attrs_before, List.rev acc, expr) | expr when n_fun = 0 && Ast_uncurried.expr_is_uncurried_fun expr -> let expr = Ast_uncurried.expr_extract_uncurried_fun expr in - collect ~uncurried:true ~n_fun attrs_before acc expr - | expr -> (uncurried, attrs_before, List.rev acc, expr) + collect ~n_fun attrs_before acc expr + | expr -> (attrs_before, List.rev acc, expr) in match expr with | {pexp_desc = Pexp_fun _ | Pexp_newtype _} -> - collect ~uncurried:false ~n_fun:0 expr.pexp_attributes [] - {expr with pexp_attributes = []} - | _ when Ast_uncurried.expr_is_uncurried_fun expr -> - let expr = Ast_uncurried.expr_extract_uncurried_fun expr in - collect ~uncurried:true ~n_fun:0 expr.pexp_attributes [] - {expr with pexp_attributes = []} - | _ -> collect ~uncurried:false ~n_fun:0 [] [] expr + collect ~n_fun:0 expr.pexp_attributes [] {expr with pexp_attributes = []} + | _ -> collect ~n_fun:0 [] [] expr let process_braces_attr expr = match expr.pexp_attributes with diff --git a/compiler/syntax/src/res_parsetree_viewer.mli b/compiler/syntax/src/res_parsetree_viewer.mli index 01af15733f..e24e497bd6 100644 --- a/compiler/syntax/src/res_parsetree_viewer.mli +++ b/compiler/syntax/src/res_parsetree_viewer.mli @@ -61,7 +61,7 @@ type fun_param_kind = val fun_expr : Parsetree.expression -> - bool * Parsetree.attributes * fun_param_kind list * Parsetree.expression + Parsetree.attributes * fun_param_kind list * Parsetree.expression (* example: * `makeCoordinate({ diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 9c0328f1be..855f6f6d45 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -1988,9 +1988,7 @@ and print_value_binding ~state ~rec_flag (vb : Parsetree.value_binding) cmt_tbl }; pvb_expr = {pexp_desc = Pexp_newtype _} as expr; } -> ( - let _uncurried, _attrs, parameters, return_expr = - ParsetreeViewer.fun_expr expr - in + let _attrs, parameters, return_expr = ParsetreeViewer.fun_expr expr in let abstract_type = match parameters with | [NewTypes {locs = vars}] -> @@ -2703,9 +2701,7 @@ and print_if_chain ~state pexp_attributes ifs else_expr cmt_tbl = and print_expression ~state (e : Parsetree.expression) cmt_tbl = let print_arrow e = - let _, attrs_on_arrow, parameters, return_expr = - ParsetreeViewer.fun_expr e - in + let attrs_on_arrow, parameters, return_expr = ParsetreeViewer.fun_expr e in let ParsetreeViewer.{async; attributes = attrs} = ParsetreeViewer.process_function_attributes attrs_on_arrow in @@ -3447,7 +3443,7 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = | _ -> expr_with_await and print_pexp_fun ~state ~in_callback e cmt_tbl = - let _, attrs_on_arrow, parameters, return_expr = ParsetreeViewer.fun_expr e in + let attrs_on_arrow, parameters, return_expr = ParsetreeViewer.fun_expr e in let ParsetreeViewer.{async; attributes = attrs} = ParsetreeViewer.process_function_attributes attrs_on_arrow in diff --git a/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt b/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt index 4855435431..a7007b68b5 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt @@ -7,7 +7,7 @@ Element.querySelectorAll(selector, element) let x = @attr ((@attr2 a)->f(b)->c(d)) -5->(doStuff(3, _, 7)) +5->doStuff(3, _, 7) (event->target)["value"] diff --git a/tests/syntax_tests/data/conversion/reason/expected/underscoreSugar.res.txt b/tests/syntax_tests/data/conversion/reason/expected/underscoreSugar.res.txt index 9590b1d1fc..a67f171f48 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/underscoreSugar.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/underscoreSugar.res.txt @@ -1 +1 @@ -let photo = (Array.get(_, 0))(filterNone(pricedRoom["room"]["photos"])) +let photo = Array.get(_, 0)(filterNone(pricedRoom["room"]["photos"])) diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/array.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/array.res.txt index 31dbf702e0..ba40ab2a3c 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/array.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/array.res.txt @@ -8,4 +8,4 @@ Did you forget a `]` here? -let xs = x.map (Function$ (fun [arity:1]key -> [|key;(predicates.(key))|])) \ No newline at end of file +let xs = x.map (fun [arity:1]key -> [|key;(predicates.(key))|]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/arrow.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/arrow.res.txt index c21d3abef2..1cf97a8773 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/arrow.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/arrow.res.txt @@ -9,6 +9,5 @@ Did you forget a `,` here? ;;(Object.keys providers).reduce - (Function$ - (fun [arity:2]elements -> - fun providerId -> ((let x = 1 in let b = 2 in x + b)[@res.braces ]))) \ No newline at end of file + (fun [arity:2]elements -> + fun providerId -> ((let x = 1 in let b = 2 in x + b)[@res.braces ])) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/block.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/block.res.txt index 13d6efcccf..516cddbc73 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/block.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/block.res.txt @@ -63,26 +63,21 @@ Looks like there might be an expression missing here -let findThreadByIdLinearScan = - Function$ - (fun [arity:2]~threads:((threads)[@res.namedArgLoc ]) -> - fun ~id:((id)[@res.namedArgLoc ]) -> - ((Js.Array2.findi ThreadsModel.threads - (Function$ - (fun [arity:2]thread -> - fun i -> - ((let thisId = - match thread with - | ServerData.OneToOne - { otherPersonIDWhichIsAlsoThreadID } -> - otherPersonIDWhichIsAlsoThreadID - | Group { id } -> id - | Unknown { id } -> - (unknown.id |.u Js.String.make) |.u - FBID.ofStringUnsafe in - thisId == id) - [@res.braces ])))) - [@res.braces ])) +let findThreadByIdLinearScan [arity:2]~threads:((threads)[@res.namedArgLoc ]) + ~id:((id)[@res.namedArgLoc ]) = + ((Js.Array2.findi ThreadsModel.threads + (fun [arity:2]thread -> + fun i -> + ((let thisId = + match thread with + | ServerData.OneToOne { otherPersonIDWhichIsAlsoThreadID } -> + otherPersonIDWhichIsAlsoThreadID + | Group { id } -> id + | Unknown { id } -> + (unknown.id |.u Js.String.make) |.u FBID.ofStringUnsafe in + thisId == id) + [@res.braces ]))) + [@res.braces ]) let x = ((loop 0 (Nil |.u (push doc)))[@res.braces ]) ;;match stack with | Empty -> [%rescript.exprhole ] diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/consecutive.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/consecutive.res.txt index 431ca31f84..c4d304c837 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/consecutive.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/consecutive.res.txt @@ -44,8 +44,8 @@ consecutive expressions on a line must be separated by ';' or a newline -let f = Function$ (fun [arity:2]a -> fun b -> a + 3) +let f [arity:2]a b = a + 3 ;;b -let f = Function$ (fun [arity:2]g -> fun h -> ((a + 3; b)[@res.braces ])) +let f [arity:2]g h = ((a + 3; b)[@res.braces ]) let () = ((sideEffect1 (); sideEffect2 ())[@res.braces ]) let () = ((let open Foo in let exception End in x ())[@res.braces ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/emptyBlock.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/emptyBlock.res.txt index fca8935cc9..6316a44ebd 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/emptyBlock.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/emptyBlock.res.txt @@ -1,2 +1,2 @@ let x = { } -let f = Function$ (fun [arity:2]a -> fun b -> { }) \ No newline at end of file +let f [arity:2]a b = { } \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/expressions/expected/implementation.res.txt b/tests/syntax_tests/data/parsing/errors/expressions/expected/implementation.res.txt index cb8406f831..76dd17499a 100644 --- a/tests/syntax_tests/data/parsing/errors/expressions/expected/implementation.res.txt +++ b/tests/syntax_tests/data/parsing/errors/expressions/expected/implementation.res.txt @@ -12,9 +12,7 @@ module InstallerDownload = struct - let make = - Function$ - (fun [arity:1]() -> ((div ~children:[] ())[@res.braces ][@JSX ])) + let make [arity:1]() = ((div ~children:[] ())[@res.braces ][@JSX ]) [@@react.component ] end module LicenseList = struct end \ No newline at end of file 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 d42c21ede3..3417147d94 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 @@ -31,10 +31,7 @@ A labeled parameter starts with a `~`. Did you mean: `~x`? -let f = Function$ (fun [arity:3]x -> fun ?(y= 2) -> fun z -> (x + y) + z) -let g = - Function$ - (fun [arity:3]~x:((x)[@res.namedArgLoc ]) -> - fun ?y:(((y)[@res.namedArgLoc ])= 2) -> - fun ~z:((z)[@res.namedArgLoc ]) -> (x + y) + z) +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, [ `Has_arity2 ]) function$ \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/structure/expected/gh16B.res.txt b/tests/syntax_tests/data/parsing/errors/structure/expected/gh16B.res.txt index 39d03805ec..4303618ce3 100644 --- a/tests/syntax_tests/data/parsing/errors/structure/expected/gh16B.res.txt +++ b/tests/syntax_tests/data/parsing/errors/structure/expected/gh16B.res.txt @@ -14,12 +14,10 @@ open Ws let wss = Server.make { port = 82 } let address = wss |.u Server.address -let log = - Function$ - (fun [arity:1]msg -> - Js.log - (((((({js|> Server: |js})[@res.template ]) ^ msg)[@res.template ]) ^ - (({js||js})[@res.template ]))[@res.template ])) +let log [arity:1]msg = + Js.log + (((((({js|> Server: |js})[@res.template ]) ^ msg)[@res.template ]) ^ + (({js||js})[@res.template ]))[@res.template ]) ;;log (((((((((((((({js|Running on: |js})[@res.template ]) ^ address.address) [@res.template ]) ^ (({js|:|js})[@res.template ])) @@ -32,14 +30,10 @@ module ClientSet = module T = (Belt.Id.MakeComparable)(struct type nonrec t = Client.t - let cmp = - Function$ - (fun [arity:2]a -> - fun b -> - ((compare - (a |.u Client.getUniqueId) - (b |.u Client.getUniqueId)) - [@res.braces ])) + let cmp [arity:2]a b = + ((compare (a |.u Client.getUniqueId) + (b |.u Client.getUniqueId)) + [@res.braces ]) end) let empty = Belt.Set.make ~id:(((module T))[@res.namedArgLoc ]) end diff --git a/tests/syntax_tests/data/parsing/errors/structure/expected/letBinding.res.txt b/tests/syntax_tests/data/parsing/errors/structure/expected/letBinding.res.txt index 6d99a83fc5..6208a830cd 100644 --- a/tests/syntax_tests/data/parsing/errors/structure/expected/letBinding.res.txt +++ b/tests/syntax_tests/data/parsing/errors/structure/expected/letBinding.res.txt @@ -99,8 +99,7 @@ let rightResource = (ur.resources).find - (Function$ - (fun [arity:1]r -> r.account_id == ((connection.left).account).id)) + (fun [arity:1]r -> r.account_id == ((connection.left).account).id) let x = ((let field = p |.u parseFieldDeclaration in field)[@res.braces ]) let t = ((let (_, _, token) = scanner |.u scan in token)[@res.braces ]) let (keyTable : int Belt.Map.String.t) = [%rescript.exprhole ] 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 85834693c6..24a0fc8dbb 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 @@ -43,11 +43,9 @@ type nonrec user = { name: string ; address: < street: string ;country: string > } -let make = - Function$ - (fun - [arity:1](props : - < - handleClick: (Click.t -> unit, [ `Has_arity1 ]) function$ - ;value: string > ) - -> render props) \ No newline at end of file +let make + [arity:1](props : + < + handleClick: (Click.t -> unit, [ `Has_arity1 ]) function$ ; + value: string > ) + = render props \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/errors/typexpr/expected/objectSpread.res.txt b/tests/syntax_tests/data/parsing/errors/typexpr/expected/objectSpread.res.txt index d429e17985..9772fd07a0 100644 --- a/tests/syntax_tests/data/parsing/errors/typexpr/expected/objectSpread.res.txt +++ b/tests/syntax_tests/data/parsing/errors/typexpr/expected/objectSpread.res.txt @@ -30,4 +30,4 @@ type nonrec u = private { type nonrec x = | Type of < a ;u: int > type nonrec u = < a ;u: int ;v: int > -let f = Function$ (fun [arity:1](x : < a: int ;b: int > ) -> ()) \ No newline at end of file +let f [arity:1](x : < a: int ;b: int > ) = () \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedAlways.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedAlways.res.txt index cd268cd8a5..a306f3cad4 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedAlways.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/UncurriedAlways.res.txt @@ -1,7 +1,7 @@ [@@@uncurried ] -let foo = Function$ (fun [arity:2]x -> fun y -> x + y) +let foo [arity:2]x y = x + y let z = foo 3 4 -let bar = Function$ (fun [arity:2]x -> fun y -> x + y) +let bar [arity:2]x y = x + y let b = bar 3 4 let w = 3 |.u (foo 4) let a = 3 |.u (foo 4) \ 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 1d60dbec09..35e991f435 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 @@ -1,19 +1,11 @@ let cApp = foo 3 let uApp = foo 3 -let cFun = Function$ (fun [arity:1]x -> 3) -let uFun = Function$ (fun [arity:1]x -> 3) -let mixFun = - Function$ - (fun [arity:3]a -> - fun b -> - fun c -> - Function$ - (fun [arity:3]d -> - fun e -> fun f -> Function$ (fun [arity:2]g -> fun h -> 4))) -let bracesFun = - Function$ (fun [arity:1]x -> Function$ (fun [arity:1]y -> x + y)) -let cFun2 = Function$ (fun [arity:2]x -> fun y -> 3) -let uFun2 = Function$ (fun [arity:2]x -> fun y -> 3) +let cFun [arity:1]x = 3 +let uFun [arity:1]x = 3 +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, [ `Has_arity1 ]) function$ type nonrec uTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec mixTyp = @@ -70,24 +62,17 @@ type nonrec unested = function$ let (uannpoly : ('a -> string, [ `Has_arity1 ]) function$) = xx let (uannint : (int -> string, [ `Has_arity1 ]) function$) = xx -let _ = Function$ ((fun [arity:1]x -> 34)[@att ]) -let _ = Function$ ((fun [arity:1]x -> 34)[@res.async ][@att ]) -let _ = preserveAttr (Function$ ((fun [arity:1]x -> 34)[@att ])) -let _ = preserveAttr (Function$ ((fun [arity:1]x -> 34)[@res.async ][@att ])) -let t0 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t1 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t2 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t3 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t4 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t5 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t6 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) +let _ = ((fun [arity:1]x -> 34)[@att ]) +let _ = ((fun [arity:1]x -> 34)[@res.async ][@att ]) +let _ = preserveAttr ((fun [arity:1]x -> 34)[@att ]) +let _ = preserveAttr ((fun [arity:1]x -> 34)[@res.async ][@att ]) +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 +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, [ `Has_arity1 ]) function$ type nonrec arrowPath2 = (I.t -> string, [ `Has_arity1 ]) function$ type nonrec arrowPath3 = (int -> string, [ `Has_arity1 ]) function$ @@ -100,25 +85,13 @@ type nonrec callback3 = (ReactEvent.Mouse.t -> unit, [ `Has_arity1 ]) function$ as 'callback let cApp = foo 3 let uApp = foo 3 -let cFun = Function$ (fun [arity:1]x -> 3) -let uFun = Function$ (fun [arity:1]x -> 3) -let mixFun = - Function$ - (fun [arity:1]a -> - Function$ - (fun [arity:2]b -> - fun c -> - Function$ - (fun [arity:3]d -> - fun e -> - fun f -> - Function$ - (fun [arity:1]g -> Function$ (fun [arity:1]h -> 4))))) -let bracesFun = - Function$ (fun [arity:1]x -> Function$ (fun [arity:1]y -> x + y)) -let cFun2 = Function$ (fun [arity:2]x -> fun y -> 3) -let uFun2 = Function$ (fun [arity:2]x -> fun y -> 3) -let cFun2Dots = Function$ (fun [arity:2]x -> fun y -> 3) +let cFun [arity:1]x = 3 +let uFun [arity:1]x = 3 +let mixFun [arity:1]a [arity:2]b c [arity:3]d e f [arity:1]g [arity:1]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 +let cFun2Dots [arity:2]x y = 3 type nonrec cTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec uTyp = (string -> int, [ `Has_arity1 ]) function$ type nonrec mixTyp = @@ -177,18 +150,14 @@ type nonrec unested = let pipe1 = 3 |.u f let (uannpoly : ('a -> string, [ `Has_arity1 ]) function$) = xx let (uannint : (int -> string, [ `Has_arity1 ]) function$) = xx -let _ = Function$ ((fun [arity:1]x -> 34)[@att ]) -let _ = Function$ ((fun [arity:1]x -> 34)[@res.async ][@att ]) -let _ = preserveAttr (Function$ ((fun [arity:1]x -> 34)[@att ])) -let _ = preserveAttr (Function$ ((fun [arity:1]x -> 34)[@res.async ][@att ])) -let t0 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t1 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t2 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) -let t3 (type a) (type b) = - Function$ (fun [arity:2](l : a list) -> fun (x : a) -> x :: l) +let _ = ((fun [arity:1]x -> 34)[@att ]) +let _ = ((fun [arity:1]x -> 34)[@res.async ][@att ]) +let _ = preserveAttr ((fun [arity:1]x -> 34)[@att ]) +let _ = preserveAttr ((fun [arity:1]x -> 34)[@res.async ][@att ]) +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, [ `Has_arity1 ]) function$ type nonrec arrowPath2 = (I.t -> string, [ `Has_arity1 ]) function$ type nonrec arrowPath3 = (int -> string, [ `Has_arity1 ]) function$ diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt index 1a0f7fdc0e..d3a2e0fdc1 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt @@ -1,10 +1,8 @@ -;;foo (Function$ (fun [arity:1]_ -> bla)) blaz -;;foo (Function$ (fun [arity:1]_ -> bla)) blaz -;;foo (Function$ (fun [arity:1]_ -> bla)) blaz -;;foo (Function$ (fun [arity:1]_ -> bla)) - (Function$ (fun [arity:1]_ -> blaz)) -;;List.map (Function$ (fun [arity:1]x -> x + 1)) myList -;;List.reduce (Function$ (fun [arity:2]acc -> fun curr -> acc + curr)) 0 - myList +;;foo (fun [arity:1]_ -> bla) blaz +;;foo (fun [arity:1]_ -> bla) blaz +;;foo (fun [arity:1]_ -> bla) blaz +;;foo (fun [arity:1]_ -> bla) (fun [arity:1]_ -> blaz) +;;List.map (fun [arity:1]x -> x + 1) myList +;;List.reduce (fun [arity:2]acc -> fun curr -> acc + curr) 0 myList let unitUncurried = apply () ;;call ~a:(((((a)[@res.namedArgLoc ]) : int))[@res.namedArgLoc ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/argument.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/argument.res.txt index 267d3cb084..d2820b878e 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/argument.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/argument.res.txt @@ -1,15 +1,12 @@ -let foo = - Function$ - (fun [arity:1]~a:((a)[@res.namedArgLoc ]) -> - (a (let __res_unit = () in __res_unit)) +. 1.) -let a = Function$ (fun [arity:1]() -> 2) +let foo [arity:1]~a:((a)[@res.namedArgLoc ]) = + (a (let __res_unit = () in __res_unit)) +. 1. +let a [arity:1]() = 2 let bar = foo ~a:((a)[@res.namedArgLoc ]) let comparisonResult = compare currentNode.value ~targetValue:((targetValue)[@res.namedArgLoc ]) ;;callback firstNode ~y:((y)[@res.namedArgLoc ]) ;;document.createElementWithOptions {js|div|js} - (elementProps - ~onClick:((Function$ (fun [arity:1]_ -> Js.log {js|hello world|js})) + (elementProps ~onClick:((fun [arity:1]_ -> Js.log {js|hello world|js}) [@res.namedArgLoc ])) ;;resolve () ;;resolve (let __res_unit = () in __res_unit) \ 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 36cc7d1c18..ee09e1ad09 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 @@ -1,88 +1,55 @@ -let f = Function$ (fun [arity:1]x -> x + 1) -let f = Function$ (fun [arity:1]_ -> Js.log {js|test|js}) -let f = Function$ (fun [arity:1]() -> Js.log {js|unit|js}) -let f = Function$ (fun [arity:1](Reducer (inst, comp)) -> inst.render comp) -let f = Function$ (fun [arity:1](Instance) -> ()) -let f = Function$ (fun [arity:2]a -> fun b -> a + b) -let f = Function$ (fun [arity:2]1 -> fun 2 -> ()) -let f = Function$ (fun [arity:1]{js|stringPattern|js} -> ()) -let f = - Function$ - (fun [arity:2]{js|stringPattern|js} -> fun {js|stringPattern|js} -> ()) -let f = Function$ (fun [arity:1]() -> ()) -let f = Function$ (fun [arity:2](a : int) -> fun (b : int) -> a + b) -let f = Function$ (fun [arity:2]_ -> fun _ -> ()) -let f = Function$ (fun [arity:2][|a;b|] -> fun [|c;d|] -> ((a + b) + c) + d) -let f = Function$ (fun [arity:1]{ a } -> a + 1) -let f = - Function$ (fun [arity:2]{ a; b } -> fun { c; d } -> ((a + b) + c) + d) -let f = Function$ (fun [arity:1](a, b) -> a + b) -let f = Function$ (fun [arity:2](a, b) -> fun (c, d) -> ((a + b) + c) + d) -let f = Function$ (fun [arity:1]exception Terminate -> ()) -let f = - Function$ (fun [arity:2]exception Terminate -> fun exception Exit -> ()) -let f = Function$ (fun [arity:1][] -> ()) -let f = Function$ (fun [arity:1](x::xs) -> x + (xs |.u Belt.List.length)) -let f = Function$ (fun [arity:2](x : int) -> fun (y : int) -> x + y) -let f = - Function$ - (fun [arity:2]~a:((a)[@res.namedArgLoc ]) -> - fun ~b:((b)[@res.namedArgLoc ]) -> a + b) -let f = - Function$ - (fun [arity:2]~a:((x)[@res.namedArgLoc ]) -> - fun ~b:((y)[@res.namedArgLoc ]) -> x + y) -let f = - Function$ - (fun [arity:2]~a:(((x : int))[@res.namedArgLoc ]) -> - fun ~b:(((y : int))[@res.namedArgLoc ]) -> x + y) -let f = - Function$ - (fun [arity:3]?a:(((a)[@res.namedArgLoc ])= 1) -> - fun ?b:(((b)[@res.namedArgLoc ])= 2) -> fun c -> (a + b) + c) -let f = - Function$ - (fun [arity:3]?a:(((x)[@res.namedArgLoc ])= 1) -> - fun ?b:(((y)[@res.namedArgLoc ])= 2) -> fun c -> (x + y) + c) -let f = - Function$ - (fun [arity:3]?a:((((x : int))[@res.namedArgLoc ])= 1) -> - fun ?b:((((y : int))[@res.namedArgLoc ])= 2) -> fun c -> (x + y) + c) -let f = - Function$ - (fun [arity:3]?a:((a)[@res.namedArgLoc ]) -> - fun ?b:((b)[@res.namedArgLoc ]) -> - fun c -> - match (a, b) with | (Some a, Some b) -> (a + b) + c | _ -> 3) -let f = - Function$ - (fun [arity:3]?a:((x)[@res.namedArgLoc ]) -> - fun ?b:((y)[@res.namedArgLoc ]) -> - fun c -> - match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3) -let f = - Function$ - (fun [arity:3]?a:(((x : int option))[@res.namedArgLoc ]) -> - fun ?b:(((y : int option))[@res.namedArgLoc ]) -> - fun c -> - match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3) -let f = Function$ (fun [arity:2]a -> fun b -> a + b) -let f = Function$ (fun [arity:1]() -> ()) -let f = Function$ (fun [arity:1]() -> ()) -let f = Function$ (fun [arity:3]a -> fun b -> fun c -> ()) -let f = Function$ (fun [arity:4]a -> fun b -> fun c -> fun d -> ()) -let f = Function$ (fun [arity:3]a -> fun b -> fun c -> ()) -let f = - Function$ - (fun [arity:4]~a:((a)[@res.namedArgLoc ][@attr ]) -> - fun b -> fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> fun d -> ()) -let f = - Function$ - (fun [arity:4]~a:((a)[@res.namedArgLoc ][@attr ]) -> - fun ((b)[@attrOnB ]) -> - fun ~c:((c)[@res.namedArgLoc ][@attr ]) -> - fun ((d)[@attrOnD ]) -> ()) -let f = Function$ (fun [arity:1]list -> list ()) +let f [arity:1]x = x + 1 +let f [arity:1]_ = Js.log {js|test|js} +let f [arity:1]() = Js.log {js|unit|js} +let f [arity:1](Reducer (inst, comp)) = inst.render comp +let f [arity:1](Instance) = () +let f [arity:2]a b = a + b +let f [arity:2]1 2 = () +let f [arity:1]{js|stringPattern|js} = () +let f [arity:2]{js|stringPattern|js} {js|stringPattern|js} = () +let f [arity:1]() = () +let f [arity:2](a : int) (b : int) = a + b +let f [arity:2]_ _ = () +let f [arity:2][|a;b|] [|c;d|] = ((a + b) + c) + d +let f [arity:1]{ a } = a + 1 +let f [arity:2]{ a; b } { c; d } = ((a + b) + c) + d +let f [arity:1](a, b) = a + b +let f [arity:2](a, b) (c, d) = ((a + b) + c) + d +let f [arity:1]exception Terminate = () +let f [arity:2]exception Terminate exception Exit = () +let f [arity:1][] = () +let f [arity:1](x::xs) = x + (xs |.u Belt.List.length) +let f [arity:2](x : int) (y : int) = x + y +let f [arity:2]~a:((a)[@res.namedArgLoc ]) ~b:((b)[@res.namedArgLoc ]) = + a + b +let f [arity:2]~a:((x)[@res.namedArgLoc ]) ~b:((y)[@res.namedArgLoc ]) = + x + y +let f [arity:2]~a:(((x : int))[@res.namedArgLoc ]) + ~b:(((y : int))[@res.namedArgLoc ]) = x + y +let f [arity:3]?a:(((a)[@res.namedArgLoc ])= 1) + ?b:(((b)[@res.namedArgLoc ])= 2) c = (a + b) + c +let f [arity:3]?a:(((x)[@res.namedArgLoc ])= 1) + ?b:(((y)[@res.namedArgLoc ])= 2) c = (x + y) + c +let f [arity:3]?a:((((x : int))[@res.namedArgLoc ])= 1) + ?b:((((y : int))[@res.namedArgLoc ])= 2) c = (x + y) + c +let f [arity:3]?a:((a)[@res.namedArgLoc ]) ?b:((b)[@res.namedArgLoc ]) c = + match (a, b) with | (Some a, Some b) -> (a + b) + c | _ -> 3 +let f [arity:3]?a:((x)[@res.namedArgLoc ]) ?b:((y)[@res.namedArgLoc ]) c = + match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3 +let f [arity:3]?a:(((x : int option))[@res.namedArgLoc ]) + ?b:(((y : int option))[@res.namedArgLoc ]) c = + match (x, y) with | (Some a, Some b) -> (a + b) + c | _ -> 3 +let f [arity:2]a b = a + b +let f [arity:1]() = () +let f [arity:1]() = () +let f [arity:3]a b c = () +let f [arity:4]a b c d = () +let f [arity:3]a b c = () +let f [arity:4]~a:((a)[@res.namedArgLoc ][@attr ]) b + ~c:((c)[@res.namedArgLoc ][@attr ]) d = () +let f [arity:4]~a:((a)[@res.namedArgLoc ][@attr ]) ((b)[@attrOnB ]) + ~c:((c)[@res.namedArgLoc ][@attr ]) ((d)[@attrOnD ]) = () +let f [arity:1]list = list () ;;match colour with | Red when (l = l') || @@ -91,33 +58,30 @@ let f = Function$ (fun [arity:1]list -> list ()) -> (t1, t2) | _ -> () let arr = - [|(Function$ ((fun [arity:1]_ -> doThings ())));(Function$ - ((fun [arity:1]_ -> - doThings ())));( - Function$ ((fun [arity:1]_ -> doThings ())))|] + [|((fun [arity:1]_ -> doThings ()));((fun [arity:1]_ -> doThings ()));(( + fun [arity:1]_ -> doThings ()))|] let list = - [Function$ ((fun [arity:1]_ -> doThings ())); - Function$ ((fun [arity:1]_ -> doThings ())); - Function$ ((fun [arity:1]_ -> doThings ()))] + [(fun [arity:1]_ -> doThings ()); + (fun [arity:1]_ -> doThings ()); + (fun [arity:1]_ -> doThings ())] let tuple = - ((Function$ (fun [arity:1]_ -> doThings ())), - (Function$ (fun [arity:1]_ -> doThings ())), - (Function$ (fun [arity:1]_ -> doThings ()))) -;;Function$ (fun [arity:1]_ -> doThings ()) + ((fun [arity:1]_ -> doThings ()), (fun [arity:1]_ -> doThings ()), + (fun [arity:1]_ -> doThings ())) +;;fun [arity:1]_ -> doThings () let x = Constructore - ((Function$ (fun [arity:1]_ -> copyChecklistItemCB ())), - (Function$ (fun [arity:1]_ -> copyChecklistItemCB ()))) + ((fun [arity:1]_ -> copyChecklistItemCB ()), + (fun [arity:1]_ -> copyChecklistItemCB ())) let y = `Constructore - ((Function$ (fun [arity:1]_ -> copyChecklistItemCB ())), - (Function$ (fun [arity:1]_ -> copyChecklistItemCB ()))) -let f = Function$ (fun [arity:1]list -> list + 1) + ((fun [arity:1]_ -> copyChecklistItemCB ()), + (fun [arity:1]_ -> copyChecklistItemCB ())) +let f [arity:1]list = list + 1 let foo = (() : unit) type nonrec u = unit let un = (() : u) type nonrec ('a, 'b) d = ('a * 'b) -let c = Function$ (fun [arity:1]() -> ((1, 2) : ('a, 'b) d)) -let fn = Function$ (fun [arity:1]f -> f) +let c [arity:1]() = ((1, 2) : ('a, 'b) d) +let fn [arity:1]f = f type nonrec f = (int -> unit, [ `Has_arity1 ]) function$ -let a = fn (Function$ (fun [arity:1]_ -> ()) : f) \ No newline at end of file +let a = fn (fun [arity:1]_ -> () : f) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt index 245e144a22..8e560c579a 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/async.res.txt @@ -1,17 +1,17 @@ let greetUser = - Function$ - ((fun [arity:1]userId -> - ((let name = ((getUserName userId)[@res.await ]) in - ({js|Hello |js} ^ name) ^ {js|!|js}) - [@res.braces ])) - [@res.async ]) -;;Function$ ((fun [arity:1]() -> 123)[@res.async ]) -let fetch = - ((Function$ ((fun [arity:1]url -> browserFetch url)[@res.async ])) - [@res.braces ]) + ((fun [arity:1]userId -> + ((let name = ((getUserName userId)[@res.await ]) in + ({js|Hello |js} ^ name) ^ {js|!|js}) + [@res.braces ])) + [@res.async ]) +;;((fun [arity:1]() -> 123)[@res.async ]) +let fetch = ((fun [arity:1]url -> browserFetch url) + [@res.braces ][@res.async ]) let fetch2 = - ((Function$ (((fun [arity:1]url -> browserFetch url))[@res.async ]); - Function$ (((fun [arity:1]url -> browserFetch2 url))[@res.async ])) + (((((fun [arity:1]url -> browserFetch url)) + [@res.async ]); + (((fun [arity:1]url -> browserFetch2 url)) + [@res.async ])) [@res.braces ]) let async = ((let f = async () in @@ -19,19 +19,15 @@ let async = async (); async.async; { async = (async.(async)) }; - (result |.u async) |.u - (mapAsync (Function$ (fun [arity:1]a -> doStuff a)))) + (result |.u async) |.u (mapAsync (fun [arity:1]a -> doStuff a))) [@res.braces ]) let f = ((if isPositive - then Function$ ((fun [arity:2]a -> fun b -> (a + b : int))[@res.async ]) - else - Function$ (((fun [arity:2]c -> fun d -> (c - d : int)))[@res.async ])) + then ((fun [arity:2]a -> fun b -> (a + b : int))[@res.async ]) + else (((fun [arity:2]c -> fun d -> (c - d : int)))[@res.async ])) [@res.ternary ]) let foo = async ~a:((34)[@res.namedArgLoc ]) -let bar = - Function$ ((fun [arity:1]~a:((a)[@res.namedArgLoc ]) -> a + 1) - [@res.async ]) +let bar = ((fun [arity:1]~a:((a)[@res.namedArgLoc ]) -> a + 1)[@res.async ]) let ex1 = ((3)[@res.await ]) + ((4)[@res.await ]) let ex2 = ((3)[@res.await ]) ** ((4)[@res.await ]) let ex3 = ((foo |.u (bar ~arg:((arg)[@res.namedArgLoc ])))[@res.await ]) diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/await.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/await.res.txt index 12c2c1810f..e43414fdf0 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/await.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/await.res.txt @@ -18,20 +18,16 @@ let () = ((((delay 10)[@res.await ]); ((delay 20)[@res.await ])) [@res.braces ]) let forEach = ((Js.Import Belt.List.forEach)[@res.await ][@a ][@b ]) module M = ((Belt.List)[@res.await ][@a ][@b ]) -let f = - Function$ - (fun [arity:1]() -> - ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) - [@res.braces ])) +let f [arity:1]() = + ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) + [@res.braces ]) let () = ((let module M = ((Belt.List)[@res.await ][@a ][@b ]) in M.forEach) [@res.braces ]) module type BeltList = module type of Belt.List -let f = - Function$ - (fun [arity:1]() -> - ((let module M = (((Belt.List : BeltList))[@res.await ][@a ][@b ]) in - M.forEach) - [@res.braces ])) +let f [arity:1]() = + ((let module M = (((Belt.List : BeltList))[@res.await ][@a ][@b ]) in + M.forEach) + [@res.braces ]) let () = ((let module M = (((Belt.List : BeltList))[@res.await ][@a ][@b ]) in M.forEach) diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt index 7c2881e167..7627d666d6 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binary.res.txt @@ -21,4 +21,4 @@ let x = a -. b let _ = ((Constructor (a, b); `Constructor (a, b))[@res.braces ]) ;;(library.getBalance account) |.u (Promise.Js.catch - (Function$ (fun [arity:1]_ -> ((Promise.resolved None)[@res.braces ])))) \ No newline at end of file + (fun [arity:1]_ -> ((Promise.resolved None)[@res.braces ]))) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt index 9e4fb25ad9..99d0925970 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/binaryNoEs6Arrow.res.txt @@ -22,15 +22,13 @@ ((sibling == None) || (parent == None)) do () done ;;((div - ~onClick:((Function$ - (fun [arity:1]event -> - ((match videoContainerRect with - | Some videoContainerRect -> - let newChapter = - ({ startTime = (percent *. duration) } : - Video.chapter) in - { a; b } |.u onChange - | _ -> ()) - [@res.braces ])))[@res.namedArgLoc ][@res.braces ]) + ~onClick:((fun [arity:1]event -> + ((match videoContainerRect with + | Some videoContainerRect -> + let newChapter = + ({ startTime = (percent *. duration) } : Video.chapter) in + { a; b } |.u onChange + | _ -> ()) + [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) ~children:[] ())[@JSX ]) ;;if inclusions.(index) <- (uid, url) then onChange inclusions \ 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 2e9038568e..83cbea1dee 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 @@ -1,11 +1,10 @@ let b = ((let module Array = Belt.Array in - ([|1;2|] |.u (Array.map (Function$ (fun [arity:1]x -> x + 1)))) |.u - Js.log) + ([|1;2|] |.u (Array.map (fun [arity:1]x -> x + 1))) |.u Js.log) [@res.braces ]) let b = ((let open Belt.Array in - ([|1;2|] |.u (map (Function$ (fun [arity:1]x -> x + 1)))) |.u Js.log) + ([|1;2|] |.u (map (fun [arity:1]x -> x + 1))) |.u Js.log) [@res.braces ]) let b = ((let exception QuitEarly in raise QuitEarly)[@res.braces ]) let b = ((let a = 1 in let b = 2 in a + b)[@res.braces ]) @@ -21,7 +20,7 @@ let b = let a = 1 in let b = 2 in sideEffect (); - (let x = (1 + 2) |.u (Function$ (fun [arity:1]x -> x + 1)) in + (let x = (1 + 2) |.u (fun [arity:1]x -> x + 1) in raise (Terminate x))) [@res.braces ]) let b = ((f (); g (); h (); (let arr = [|1;2;3|] in ()))[@res.braces ]) @@ -41,48 +40,35 @@ let res = [@res.braces ]) let nestedLet = ((let _ = 1 in ())[@res.braces ]) let nestedLet = ((let _ = 1 in 2)[@res.braces ]) -let init = - Function$ - (fun [arity:1]() -> ((foo (1 == 1); [%assert 1 == 2])[@res.braces ])) -let init = - Function$ - (fun [arity:1]() -> (([%assert 1 == 2]; foo (1 == 1); [%assert 1 == 2]) - [@res.braces ])) -let f = - Function$ - (fun [arity:1]() -> ((let x = 1 in Function$ (fun [arity:1]_ -> ())) - [@res.braces ])) -let reifyStyle (type a) = - Function$ - (fun [arity:1](x : 'a) -> - (((let module Internal = - struct - type constructor - external canvasGradient : constructor = "CanvasGradient" - [@@val ] - external canvasPattern : constructor = "CanvasPattern"[@@val ] - let instanceOf = - ([%raw - (({js|function(x,y) {return +(x instanceof y)}|js}) - [@res.template ])] : ('a -> constructor -> bool, - [ `Has_arity2 ]) function$) - end in - ((if (Js.typeof x) = {js|string|js} - then Obj.magic String - else - if Internal.instanceOf x Internal.canvasGradient - then Obj.magic Gradient - else - if Internal.instanceOf x Internal.canvasPattern - then Obj.magic Pattern - else - raise - (Invalid_argument - {js|Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern|js})), - (Obj.magic x))) - [@res.braces ]) : (a style * a))) -let calc_fps = - Function$ - (fun [arity:2]t0 -> - fun t1 -> ((let delta = (t1 -. t0) /. 1000. in 1. /. delta) - [@res.braces ])) \ No newline at end of file +let init [arity:1]() = ((foo (1 == 1); [%assert 1 == 2])[@res.braces ]) +let init [arity:1]() = (([%assert 1 == 2]; foo (1 == 1); [%assert 1 == 2]) + [@res.braces ]) +let f [arity:1]() = ((let x = 1 in fun [arity:1]_ -> ())[@res.braces ]) +let reifyStyle (type a) [arity:1](x : 'a) = + (((let module Internal = + struct + type constructor + external canvasGradient : constructor = "CanvasGradient"[@@val ] + external canvasPattern : constructor = "CanvasPattern"[@@val ] + let instanceOf = + ([%raw + (({js|function(x,y) {return +(x instanceof y)}|js}) + [@res.template ])] : ('a -> constructor -> bool, + [ `Has_arity2 ]) function$) + end in + ((if (Js.typeof x) = {js|string|js} + then Obj.magic String + else + if Internal.instanceOf x Internal.canvasGradient + then Obj.magic Gradient + else + if Internal.instanceOf x Internal.canvasPattern + then Obj.magic Pattern + else + raise + (Invalid_argument + {js|Unknown canvas style kind. Known values are: String, CanvasGradient, CanvasPattern|js})), + (Obj.magic x))) + [@res.braces ]) : (a style * a)) +let calc_fps [arity:2]t0 t1 = + ((let delta = (t1 -. t0) /. 1000. in 1. /. delta)[@res.braces ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/bracedOrRecord.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/bracedOrRecord.res.txt index 11388ed021..4ce05031bb 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/bracedOrRecord.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/bracedOrRecord.res.txt @@ -3,7 +3,7 @@ let r = { a } let r = { a = expr } let r = { a = expr } let r = { a = expr; b = expr2 } -let r = { f = (Function$ (fun [arity:1]x -> x + b)) } +let r = { f = (fun [arity:1]x -> x + b) } let e = ((a)[@res.braces ]) let e = ((a)[@res.braces ]) let e = ((a; b ())[@res.braces ]) @@ -16,18 +16,14 @@ let e = ((a.(0))[@res.braces ]) let e = ((f b)[@res.braces ]) let e = (((a.b).c)[@res.braces ]) let e = ((arr.(x) <- 20)[@res.braces ]) -let e = ((Function$ (fun [arity:1]x -> doStuff config (x + 1))) - [@res.braces ]) -let e = ((doStuff config (Function$ (fun [arity:1]x -> x + 1))) - [@res.braces ]) -let e = ((if Function$ (fun [arity:1]x -> x + 1) then true else false) +let e = ((fun [arity:1]x -> doStuff config (x + 1))[@res.braces ]) +let e = ((doStuff config (fun [arity:1]x -> x + 1))[@res.braces ]) +let e = ((if fun [arity:1]x -> x + 1 then true else false) [@res.braces ][@res.ternary ]) -let e = - ((sideEffect (Function$ (fun [arity:1]x -> x + 1)); logToAnalytics Shady.ml) - [@res.braces ]) -let f = ((Function$ (fun [arity:1]event -> (event.target).value)) +let e = ((sideEffect (fun [arity:1]x -> x + 1); logToAnalytics Shady.ml) [@res.braces ]) -let f = ((Function$ (fun [arity:1]event -> ((event.target).value : string))) +let f = ((fun [arity:1]event -> (event.target).value)[@res.braces ]) +let f = ((fun [arity:1]event -> ((event.target).value : string)) [@res.braces ]) let x = ((let a = 1 in let b = 2 in a + b)[@res.braces ]) ;;(([(({js|\n|js} |.u React.string)[@res.braces ])])[@JSX ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/coerce.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/coerce.res.txt index 493f8badeb..1e56ec2b42 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/coerce.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/coerce.res.txt @@ -1,5 +1,5 @@ -let foo = Function$ (fun [arity:1](x : int) -> (x :> int)) -let foo = Function$ (fun [arity:1]x -> ((x : t) :> int)) +let foo [arity:1](x : int) = (x :> int) +let foo [arity:1]x = ((x : t) :> int) let _ = (x : int) let foo = ((x : int), (y :> float)) let foo = ((x : int), (y :> float), (z :> int)) diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/extension.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/extension.res.txt index 137deda8e9..f65d9bfc85 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/extension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/extension.res.txt @@ -1,5 +1,5 @@ ;;[%expr ] ;;[%expr.extension ] ;;[%expr.extension.with.args {js|argument|js}] -;;[%expr.extension.with.args Function$ (fun [arity:1]x -> f x)] +;;[%expr.extension.with.args fun [arity:1]x -> f x] let x = ([%raw {js|1|js}]) + ([%raw {js|2|js}]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/firstClassModule.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/firstClassModule.res.txt index 7769f2dbe1..cdccb7e78f 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/firstClassModule.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/firstClassModule.res.txt @@ -1,11 +1,8 @@ -let makeSet (type s) = - Function$ - (fun [arity:1]cmp -> - ((let module S = - (Set.Make)(struct type nonrec t = s - let compare = cmp end) in ((module - S) : (module Set.S with type elt = s))) - [@res.braces ])) +let makeSet (type s) [arity:1]cmp = + ((let module S = (Set.Make)(struct type nonrec t = s + let compare = cmp end) in ((module + S) : (module Set.S with type elt = s))) + [@res.braces ]) let three = ((module Three) : (module X_int)) let numbers = [|three;(module Four)|] let numbers = (three, (module Four)) @@ -13,52 +10,37 @@ let numbers = [three; (module Four)] let numbers = [|three;(module struct let x = 4 end)|] let numbers = (three, (module struct let x = 4 end)) let numbers = [three; (module struct let x = 4 end)] -let plus = - Function$ - (fun [arity:2]m1 -> - fun m2 -> ((((module - struct let x = (to_int m1) + (to_int m2) end) : (module X_int))) - [@res.braces ])) -let plus = - Function$ - (fun [arity:2]m1 -> - fun m2 -> ((module - struct let x = (to_int m1) + (to_int m2) end) : (module X_int))) +let plus [arity:2]m1 m2 = ((((module + struct let x = (to_int m1) + (to_int m2) end) : (module X_int))) + [@res.braces ]) +let plus [arity:2]m1 m2 = ((module + struct let x = (to_int m1) + (to_int m2) end) : (module X_int)) let unique_instance = ((module struct module Query_handler = Unique let this = Unique.create 0 end) : (module Query_handler_instance)) -let build_instance (type a) = - Function$ - (fun [arity:2]((module Q) : (module Query_handler with type config = a)) - -> - fun config -> ((module - struct module Query_handler = Q - let this = Q.create config end) : (module - Query_handler_instance))) -let build_instance (type a) = - Function$ - (fun [arity:2]((module Q) : (module Query_handler with type config = a)) - -> - fun config -> ((((module - struct module Query_handler = Q - let this = Q.create config end) : (module - Query_handler_instance))) - [@res.braces ])) +let build_instance (type a) + [arity:2]((module Q) : (module Query_handler with type config = a)) config + = ((module + struct module Query_handler = Q + let this = Q.create config end) : (module Query_handler_instance)) +let build_instance (type a) + [arity:2]((module Q) : (module Query_handler with type config = a)) config + = ((((module + struct module Query_handler = Q + let this = Q.create config end) : (module Query_handler_instance))) + [@res.braces ]) let unique_instance = build_instance (module Unique) 0 -let build_dispatch_table = - Function$ - (fun [arity:1]handlers -> - ((let table = Hashtbl.create (module String) in - List.iter handlers - ~f:((Function$ - (fun - [arity:1](((module I) : - (module Query_handler_instance)) as instance) - -> - Hashtbl.set table ~key:((I.Query_handler.name) - [@res.namedArgLoc ]) ~data:((instance) - [@res.namedArgLoc ])))[@res.namedArgLoc ]) table) - [@res.braces ])) +let build_dispatch_table [arity:1]handlers = + ((let table = Hashtbl.create (module String) in + List.iter handlers + ~f:((fun + [arity:1](((module I) : (module Query_handler_instance)) as + instance) + -> + Hashtbl.set table ~key:((I.Query_handler.name) + [@res.namedArgLoc ]) ~data:((instance)[@res.namedArgLoc ])) + [@res.namedArgLoc ]) table) + [@res.braces ]) ;;(module Three) ;;((module Three) : (module X_int)) ;;(module Teenager).(0) diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/jsx.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/jsx.res.txt index ebbbcb723f..fca943b922 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/jsx.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/jsx.res.txt @@ -10,12 +10,12 @@ let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) ~children:[] ()) [@JSX ]) let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) - ~onClick:((Function$ (fun [arity:1]_ -> Js.log {js|click|js})) + ~onClick:((fun [arity:1]_ -> Js.log {js|click|js}) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div ~className:(({js|menu|js})[@res.namedArgLoc ]) - ~onClick:((Function$ (fun [arity:1]_ -> Js.log {js|click|js})) + ~onClick:((fun [arity:1]_ -> Js.log {js|click|js}) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((Navbar.createElement ~children:[] ())[@JSX ]) @@ -82,8 +82,7 @@ let _ = [@JSX ])] ()) [@JSX ]) let _ = ((div ~children:child ())[@JSX ]) -let _ = ((Foo.createElement ~children:(Function$ (fun [arity:1]a -> 1)) ()) - [@JSX ]) +let _ = ((Foo.createElement ~children:(fun [arity:1]a -> 1) ())[@JSX ]) let _ = ((Foo.createElement ~children:((Foo2.createElement ~children:[] ()) [@JSX ]) ()) @@ -149,30 +148,26 @@ let _ = ((a ~children:[] ())[@JSX ]) > ((b ~children:[] ())[@JSX ]) let y = ((Routes.createElement ~path:((Routes.stateToPath state) [@res.namedArgLoc ]) ~isHistorical:((true)[@res.namedArgLoc ]) - ~onHashChange:((Function$ - (fun [arity:3]_oldPath -> - fun _oldUrl -> - fun newUrl -> - updater - (Function$ - (fun [arity:2]latestComponentBag -> - fun _ -> - ((let currentActualPath = - Routes.hashOfUri newUrl in - let pathFromState = - Routes.stateToPath - latestComponentBag.state in - ((if - currentActualPath = - pathFromState - then None - else - dispatchEventless - (State.UriNavigated - currentActualPath) - latestComponentBag ()) - [@res.ternary ])) - [@res.braces ]))) ())) + ~onHashChange:((fun [arity:3]_oldPath -> + fun _oldUrl -> + fun newUrl -> + updater + (fun [arity:2]latestComponentBag -> + fun _ -> + ((let currentActualPath = + Routes.hashOfUri newUrl in + let pathFromState = + Routes.stateToPath + latestComponentBag.state in + ((if currentActualPath = pathFromState + then None + else + dispatchEventless + (State.UriNavigated + currentActualPath) + latestComponentBag ()) + [@res.ternary ])) + [@res.braces ])) ()) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let z = @@ -324,95 +319,85 @@ let _ = ~children:[child] ()) [@JSX ]) let _ = - ((div ~onClick:((Function$ (fun [arity:1]event -> handleChange event)) + ((div ~onClick:((fun [arity:1]event -> handleChange event) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:1]eventWithLongIdent -> - handleChange eventWithLongIdent)) + ~onClick:((fun [arity:1]eventWithLongIdent -> + handleChange eventWithLongIdent) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:1]event -> ((Js.log event; handleChange event) - [@res.braces ])))[@res.namedArgLoc ][@res.braces ]) + ~onClick:((fun [arity:1]event -> ((Js.log event; handleChange event) + [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((StaticDiv.createElement - ~onClick:((Function$ - (fun [arity:5]foo -> - fun bar -> - fun baz -> - fun lineBreak -> - fun identifier -> - ((doStuff foo bar baz; bar lineBreak identifier) - [@res.braces ]))) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + ~onClick:((fun [arity:5]foo -> + fun bar -> + fun baz -> + fun lineBreak -> + fun identifier -> + ((doStuff foo bar baz; bar lineBreak identifier) + [@res.braces ]))[@res.namedArgLoc ][@res.braces ]) + ~children:[] ()) [@JSX ]) let _ = ((AttrDiv.createElement - ~onClick:((Function$ (fun [arity:1]event -> handleChange event)) + ~onClick:((fun [arity:1]event -> handleChange event) [@res.namedArgLoc ][@res.braces ][@bar ]) ~children:[] ()) [@JSX ]) let _ = ((AttrDiv.createElement - ~onClick:((Function$ - (fun [arity:1]eventLongIdentifier -> - handleChange eventLongIdentifier)) + ~onClick:((fun [arity:1]eventLongIdentifier -> + handleChange eventLongIdentifier) [@res.namedArgLoc ][@res.braces ][@bar ]) ~children:[] ()) [@JSX ]) let _ = ((StaticDivNamed.createElement - ~onClick:((Function$ - (fun [arity:6]~foo:((foo)[@res.namedArgLoc ]) -> - fun ~bar:((bar)[@res.namedArgLoc ]) -> - fun ~baz:((baz)[@res.namedArgLoc ]) -> - fun ~lineBreak:((lineBreak)[@res.namedArgLoc ]) -> - fun ~identifier:((identifier)[@res.namedArgLoc ]) - -> fun () -> bar lineBreak identifier)) + ~onClick:((fun [arity:6]~foo:((foo)[@res.namedArgLoc ]) -> + fun ~bar:((bar)[@res.namedArgLoc ]) -> + fun ~baz:((baz)[@res.namedArgLoc ]) -> + fun ~lineBreak:((lineBreak)[@res.namedArgLoc ]) -> + fun ~identifier:((identifier)[@res.namedArgLoc ]) -> + fun () -> bar lineBreak identifier) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:1]e -> (((doStuff (); bar foo) - [@res.braces ]) : event))) + ~onClick:((fun [arity:1]e -> (((doStuff (); bar foo) + [@res.braces ]) : event)) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:2]e -> - fun e2 -> (((doStuff (); bar foo) - [@res.braces ]) : event))) + ~onClick:((fun [arity:2]e -> + fun e2 -> (((doStuff (); bar foo)[@res.braces ]) : event)) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:5]foo -> - fun bar -> - fun baz -> - fun superLongIdent -> - fun breakLine -> (((doStuff (); bar foo) - [@res.braces ]) : (event * event2 * event3 * - event4 * event5)))) + ~onClick:((fun [arity:5]foo -> + fun bar -> + fun baz -> + fun superLongIdent -> + fun breakLine -> (((doStuff (); bar foo) + [@res.braces ]) : (event * event2 * event3 * + event4 * event5))) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = ((div - ~onClick:((Function$ - (fun [arity:5]foo -> - fun bar -> - fun baz -> - fun superLongIdent -> - fun breakLine -> - (doStuff () : (event * event2 * event3 * event4 - * event5)))) + ~onClick:((fun [arity:5]foo -> + fun bar -> + fun baz -> + fun superLongIdent -> + fun breakLine -> + (doStuff () : (event * event2 * event3 * event4 * + event5))) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = @@ -443,80 +428,72 @@ let _ = let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((Function$ - (fun [arity:1]value -> - ((div - ~style:((ReactDOMRe.Style.make - ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@JSX ])))[@res.braces ]) ()) + ~children:((fun [arity:1]value -> + ((div + ~style:((ReactDOMRe.Style.make ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + [@JSX ]))[@res.braces ]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((Function$ - (fun [arity:1]value -> - (((div - ~style:((ReactDOMRe.Style.make - ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] - ()) - [@JSX ]) : ReasonReact.element)))[@res.braces ]) ()) + ~children:((fun [arity:1]value -> + (((div + ~style:((ReactDOMRe.Style.make + ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + [@JSX ]) : ReasonReact.element))[@res.braces ]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((Function$ - (fun [arity:1]value -> - ((div - ~style:((ReactDOMRe.Style.make - ~width:(({js|20px|js}) - [@res.namedArgLoc ]) - ~height:(({js|20px|js}) - [@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) - [@res.braces ][@JSX ])))[@res.braces ][@foo ]) ()) + ~children:((fun [arity:1]value -> + ((div + ~style:((ReactDOMRe.Style.make ~width:(({js|20px|js}) + [@res.namedArgLoc ]) + ~height:(({js|20px|js}) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + [@res.braces ][@JSX ]))[@res.braces ][@foo ]) ()) [@JSX ]) let _ = ((Animated.createElement ~initialValue:((0.0)[@res.namedArgLoc ]) ~value:((value)[@res.namedArgLoc ]) - ~children:((Function$ - (fun [arity:1]value -> - ((let width = {js|20px|js} in - let height = {js|20px|js} in - ((div - ~style:((ReactDOMRe.Style.make ~width:((width) - [@res.namedArgLoc ]) - ~height:((height)[@res.namedArgLoc ]) - ~borderRadius:(({js|100%|js}) - [@res.namedArgLoc ]) - ~backgroundColor:(({js|red|js}) - [@res.namedArgLoc ])) - [@res.namedArgLoc ][@res.braces ]) ~children:[] - ()) - [@JSX ])) - [@res.braces ])))[@res.braces ]) ()) - [@JSX ]) -let _ = - ((div ~callback:((reduce (Function$ (fun [arity:1]() -> not state))) + ~children:((fun [arity:1]value -> + ((let width = {js|20px|js} in + let height = {js|20px|js} in + ((div + ~style:((ReactDOMRe.Style.make ~width:((width) + [@res.namedArgLoc ]) ~height:((height) + [@res.namedArgLoc ]) + ~borderRadius:(({js|100%|js}) + [@res.namedArgLoc ]) + ~backgroundColor:(({js|red|js}) + [@res.namedArgLoc ])) + [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) + [@JSX ])) + [@res.braces ]))[@res.braces ]) ()) + [@JSX ]) +let _ = + ((div ~callback:((reduce (fun [arity:1]() -> not state)) [@res.namedArgLoc ][@res.braces ]) ~children:[] ()) [@JSX ]) let _ = @@ -577,22 +554,19 @@ let _ = ~children:[((ReasonReact.array (Array.of_list (List.map - (Function$ - (fun [arity:1]possibleGradeValue -> - ((option - ~key:((string_of_int possibleGradeValue) - [@res.namedArgLoc ][@res.braces ]) - ~value:((string_of_int - possibleGradeValue) - [@res.namedArgLoc ][@res.braces ]) - ~children:[((str - (string_of_int - possibleGradeValue)) - [@res.braces ])] ()) - [@JSX ]))) + (fun [arity:1]possibleGradeValue -> + ((option + ~key:((string_of_int possibleGradeValue) + [@res.namedArgLoc ][@res.braces ]) + ~value:((string_of_int possibleGradeValue) + [@res.namedArgLoc ][@res.braces ]) + ~children:[((str + (string_of_int + possibleGradeValue)) + [@res.braces ])] ()) + [@JSX ])) (List.filter - (Function$ - (fun [arity:1]g -> g <= state.maxGrade)) + (fun [arity:1]g -> g <= state.maxGrade) possibleGradeValues)))) [@res.braces ])] ())[@JSX ]) ;;((div ~children:[((Js.log (a <= 10))[@res.braces ])] ())[@JSX ]) @@ -600,9 +574,7 @@ let _ = ~children:[((div ~children:[((Js.log (a <= 10))[@res.braces ])] ()) [@JSX ])] ())[@JSX ]) ;;((div - ~children:[((div - ~onClick:((Function$ - (fun [arity:1]_ -> Js.log (a <= 10))) + ~children:[((div ~onClick:((fun [arity:1]_ -> Js.log (a <= 10)) [@res.namedArgLoc ][@res.braces ]) ~children:[((div ~children:[((Js.log (a <= 10)) @@ -610,14 +582,13 @@ let _ = [@JSX ])] ()) [@JSX ])] ())[@JSX ]) ;;((div ~children:element ())[@JSX ]) -;;((div ~children:((Function$ (fun [arity:1]a -> 1))[@res.braces ]) ()) - [@JSX ]) +;;((div ~children:((fun [arity:1]a -> 1)[@res.braces ]) ())[@JSX ]) ;;((div ~children:((span ~children:[] ())[@JSX ]) ())[@JSX ]) ;;((div ~children:[|a|] ())[@JSX ]) ;;((div ~children:(1, 2) ())[@JSX ]) ;;((div ~children:((array |.u f)[@res.braces ]) ())[@JSX ]) ;;(([element])[@JSX ]) -;;(([((Function$ ((fun [arity:1]a -> 1)))[@res.braces ])])[@JSX ]) +;;(([(((fun [arity:1]a -> 1))[@res.braces ])])[@JSX ]) ;;(([((span ~children:[] ())[@JSX ])])[@JSX ]) ;;(([[|a|]])[@JSX ]) ;;(([(1, 2)])[@JSX ]) 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 7e6f17ed76..162b62c4fa 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 @@ -1,27 +1,19 @@ -let f (type t) = Function$ (fun [arity:1](xs : t list) -> ()) -let f (type t) = - Function$ - (fun [arity:2](xs : t list) -> fun (type s) -> fun (ys : s list) -> ()) -let f (type t) (type u) (type v) = - Function$ (fun [arity:1](xs : (t * u * v) list) -> ()) -let f (type t) (type u) (type v) = - Function$ - (fun [arity:2](xs : (t * u * v) list) -> fun (type s) -> fun (type w) -> - fun (type z) -> fun (ys : (s * w * z) list) -> ()) +let f (type t) [arity:1](xs : t list) = () +let f (type t) [arity:2](xs : t list) (type s) (ys : s list) = () +let f (type t) (type u) (type v) [arity:1](xs : (t * u * v) list) = () +let f (type t) (type u) (type v) [arity:2](xs : (t * u * v) list) (type s) + (type w) (type z) (ys : (s * w * z) list) = () let f = ((fun (type t) -> fun (type u) -> fun (type v) -> - Function$ - (fun [arity:2](xs : (t * u * v) list) -> ((fun (type s) -> fun (type w) - -> fun (type z) -> fun (ys : (s * w * z) list) -> ())[@attr2 ]))) + fun [arity:2](xs : (t * u * v) list) -> ((fun (type s) -> fun (type w) -> + fun (type z) -> fun (ys : (s * w * z) list) -> ())[@attr2 ])) [@attr ]) let f = ((fun (type t) -> ((fun (type s) -> - Function$ - (fun [arity:2](xs : (t * s) list) -> ((fun (type u) -> ((fun (type v) -> - fun (type w) -> fun (ys : (u * v * w) list) -> ())[@attr ]))[@attr ]))) + fun [arity:2](xs : (t * s) list) -> ((fun (type u) -> ((fun (type v) -> fun + (type w) -> fun (ys : (u * v * w) list) -> ())[@attr ]))[@attr ])) [@attr ]))[@attr ]) let cancel_and_collect_callbacks : 'a 'u 'c . (packed_callbacks list -> ('a, 'u, 'c) promise -> packed_callbacks list, [ `Has_arity2 ]) function$ = fun (type x) -> - Function$ - (fun [arity:2]callbacks_accumulator -> fun (p : (_, _, c) promise) -> ()) \ No newline at end of file + fun [arity:2]callbacks_accumulator -> fun (p : (_, _, c) promise) -> () \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/record.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/record.res.txt index 002b2e837f..ec8fbba7e5 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/record.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/record.res.txt @@ -13,10 +13,10 @@ let r = { expr with pexp_attributes = [||] } let r = { (make () : myRecord) with foo = bar } let r = { (make () : myRecord) with foo = bar } let r = { x = ?None; y = ?None; z = ?(None : tt) } -let z = Function$ (fun [arity:1]name -> { name?; x = 3 }) -let z = Function$ (fun [arity:1]name -> { name?; x = 3 }) -let z = Function$ (fun [arity:1]name -> { name; x? }) -let zz = Function$ (fun [arity:1]name -> { name; x? }) +let z [arity:1]name = { name?; x = 3 } +let z [arity:1]name = { name?; x = 3 } +let z [arity:1]name = { name; x? } +let zz [arity:1]name = { name; x? } let _ = match z with | { x? = None; y? = None; z? = (None : tt) } -> 11 diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/tupleVsDivision.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/tupleVsDivision.res.txt index 46850dc5c8..472331b774 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/tupleVsDivision.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/tupleVsDivision.res.txt @@ -1,7 +1,5 @@ ;;(foo ()) / 1 ;;foo () ;;(1, 2) |.u printTuple -let f = - Function$ - (fun [arity:1]() -> (((foo ()) / 1; foo (); (1, 2) |.u printTuple) - [@res.braces ])) \ No newline at end of file +let f [arity:1]() = (((foo ()) / 1; foo (); (1, 2) |.u printTuple) + [@res.braces ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/uncurried.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/uncurried.res.txt index 46c2414859..2a6d00d551 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/uncurried.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/uncurried.res.txt @@ -1,25 +1,15 @@ -let f = Function$ (fun [arity:2]a -> fun b -> a + b) -let f = Function$ (fun [arity:2]a -> fun b -> a + b) -let f = - Function$ (fun [arity:4]a -> fun b -> fun c -> fun d -> ((a + b) + c) + d) -let f = - Function$ - ((fun [arity:1]a -> - Function$ - ((fun [arity:1]b -> - Function$ - ((fun [arity:1]c -> - Function$ ((fun [arity:1]d -> ())[@attr4 ])) - [@attr3 ])) - [@attr2 ])) - [@attr ]) -let f = - Function$ - (fun [arity:4]((a)[@attr ]) -> - fun ((b)[@attr2 ]) -> fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ()) -let f = - Function$ - (fun [arity:4]((a)[@attr ]) -> - fun ((b)[@attr2 ]) -> fun ((c)[@attr3 ]) -> fun ((d)[@attr4 ]) -> ()) +let f [arity:2]a b = a + b +let f [arity:2]a b = a + b +let f [arity:4]a b c d = ((a + b) + c) + d +let f = + ((fun [arity:1]a -> + ((fun [arity:1]b -> + ((fun [arity:1]c -> ((fun [arity:1]d -> ())[@attr4 ]))[@attr3 ])) + [@attr2 ])) + [@attr ]) +let f [arity:4]((a)[@attr ]) ((b)[@attr2 ]) ((c)[@attr3 ]) ((d)[@attr4 ]) = + () +let f [arity:4]((a)[@attr ]) ((b)[@attr2 ]) ((c)[@attr3 ]) ((d)[@attr4 ]) = + () ;;add 1 2 ;;add 2 3 4 5 6 7 8 9 10 \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/expressions/expected/underscoreApply.res.txt b/tests/syntax_tests/data/parsing/grammar/expressions/expected/underscoreApply.res.txt index ebfa3f12d5..fd99198dba 100644 --- a/tests/syntax_tests/data/parsing/grammar/expressions/expected/underscoreApply.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/expressions/expected/underscoreApply.res.txt @@ -1,39 +1,21 @@ let l = - ([1; 2; 3] |.u - (Function$ - (fun [arity:1]__x -> - List.map (Function$ (fun [arity:1]i -> i + 1)) __x))) - |.u - (Function$ - (fun [arity:1]__x -> - List.filter (Function$ (fun [arity:1]i -> i > 0)) __x)) + ([1; 2; 3] |.u (fun [arity:1]__x -> List.map (fun [arity:1]i -> i + 1) __x)) + |.u (fun [arity:1]__x -> List.filter (fun [arity:1]i -> i > 0) __x) let l = - (Function$ (fun [arity:1]i -> i + 1)) |.u - (Function$ (fun [arity:1]__x -> List.map __x [1; 2; 3])) -let x = Function$ (fun [arity:1]__x -> List.length __x) -let nested = - Function$ - (fun [arity:1]x -> Function$ (fun [arity:1]__x -> List.length __x)) -let incr = Function$ (fun [arity:1]~v:((v)[@res.namedArgLoc ]) -> v + 1) + (fun [arity:1]i -> i + 1) |.u (fun [arity:1]__x -> List.map __x [1; 2; 3]) +let x [arity:1]__x = List.length __x +let nested [arity:1]x [arity:1]__x = List.length __x +let incr [arity:1]~v:((v)[@res.namedArgLoc ]) = v + 1 +let l1 = List.length (List.map (fun [arity:1]__x -> incr ~v:__x) [1; 2; 3]) +let l2 = List.length (List.map (fun [arity:1]__x -> incr ~v:__x) [1; 2; 3]) +let optParam [arity:2]?v:((v)[@res.namedArgLoc ]) () = + ((if v = None then 0 else 1)[@res.ternary ]) let l1 = List.length - (List.map (Function$ (fun [arity:1]__x -> incr ~v:__x)) [1; 2; 3]) + (List.map (fun [arity:1]__x -> optParam ?v:__x ()) [Some 1; None; Some 2]) let l2 = List.length - (List.map (Function$ (fun [arity:1]__x -> incr ~v:__x)) [1; 2; 3]) -let optParam = - Function$ - (fun [arity:2]?v:((v)[@res.namedArgLoc ]) -> - fun () -> ((if v = None then 0 else 1)[@res.ternary ])) -let l1 = - List.length - (List.map (Function$ (fun [arity:1]__x -> optParam ?v:__x ())) - [Some 1; None; Some 2]) -let l2 = - List.length - (List.map (Function$ (fun [arity:1]__x -> optParam ?v:__x ())) - [Some 1; None; Some 2]) -;;Function$ - (fun [arity:1]__x -> - underscoreWithComments - (Function$ (fun [arity:1]x -> ((something ())[@res.braces ]))) __x) \ No newline at end of file + (List.map (fun [arity:1]__x -> optParam ?v:__x ()) [Some 1; None; Some 2]) +;;fun [arity:1]__x -> + underscoreWithComments (fun [arity:1]x -> ((something ())[@res.braces ])) + __x \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/apply.res.txt b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/apply.res.txt index 22f9a13cc2..dd98469d3c 100644 --- a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/apply.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/apply.res.txt @@ -11,7 +11,5 @@ module X = ((F)(struct end))(struct end) module X = (F)((A : SetLike)) module X = ((F)((A : SetLike)))((B : TreeLike)) module X = ((F)((A : SetLike)))((B : TreeLike)) -let someFunctorAsFunction = - Function$ - (fun [arity:1](x : (module MT)) -> ((module (SomeFunctor)((val - x))) : (module ResT))) \ No newline at end of file +let someFunctorAsFunction [arity:1](x : (module MT)) = ((module + (SomeFunctor)((val x))) : (module ResT)) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/firstClassModules.res.txt b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/firstClassModules.res.txt index 55f32eeffe..9cd90797b1 100644 --- a/tests/syntax_tests/data/parsing/grammar/modexpr/expected/firstClassModules.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/modexpr/expected/firstClassModules.res.txt @@ -2,16 +2,11 @@ module Device = (val (((let deviceName = parseCmdline () in try Hashtbl.find devices deviceName with | Not_found -> exit 2) [@res.braces ]) : (module Device))) -let draw_using_device = - Function$ - (fun [arity:2]device_name -> - fun picture -> - ((let module Device = (val - (Hashtbl.find devices device_name : (module DEVICE))) in - Device.draw picture) - [@res.braces ])) +let draw_using_device [arity:2]device_name picture = + ((let module Device = (val + (Hashtbl.find devices device_name : (module DEVICE))) in + Device.draw picture) + [@res.braces ]) module New_three = (val (three : (module X_int))) -let to_int = - Function$ - (fun [arity:1]m -> ((let module M = (val (m : (module X_int))) in M.x) - [@res.braces ])) \ No newline at end of file +let to_int [arity:1]m = ((let module M = (val (m : (module X_int))) in M.x) + [@res.braces ]) \ 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 415ac22303..292fe7c79f 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 @@ -29,27 +29,18 @@ module Make(Cmp:sig type nonrec key = t type nonrec coll = key list let empty = [] - let add = - Function$ - (fun [arity:2](y : coll) -> - fun (e : key) -> - if List.exists (Function$ (fun [arity:1]x -> eq x e)) y - then y - else e :: y) + let add [arity:2](y : coll) (e : key) = + if List.exists (fun [arity:1]x -> eq x e) y then y else e :: y end module Gen1(P:Primitive)() = struct type nonrec t = P.t type nonrec internal = P.t - let inject = Function$ (fun [arity:1]t -> t) + let inject [arity:1]t = t end module DistinctString() : StringBased = - struct - type nonrec t = string - let inject = Function$ (fun [arity:1]t -> t) - end + struct type nonrec t = string + let inject [arity:1]t = t end module DistinctString() : StringBased = - struct - type nonrec t = string - let inject = Function$ (fun [arity:1]t -> t) - end \ No newline at end of file + struct type nonrec t = string + let inject [arity:1]t = t end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/any.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/any.res.txt index 80c80c49d3..81cd930bbd 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/any.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/any.res.txt @@ -17,13 +17,13 @@ let _ as _y|_ as _x = 1 | _ as _x|_ as _x -> () | (_ : unit) -> () | (_ : unit)|(_ : unit) -> () -let f = Function$ (fun [arity:1]_ -> ()) -let f = Function$ (fun [arity:1](_ as _x) -> ()) -let f = Function$ (fun [arity:1](_ : unit) -> ()) -let f = Function$ (fun [arity:1](_ : unit) -> ()) -let f = Function$ (fun [arity:1]((_ : unit) as _x) -> ()) -let g = Function$ (fun [arity:2]a -> fun _ -> ()) -let g = Function$ (fun [arity:2]_ -> fun a -> ()) +let f [arity:1]_ = () +let f [arity:1](_ as _x) = () +let f [arity:1](_ : unit) = () +let f [arity:1](_ : unit) = () +let f [arity:1]((_ : unit) as _x) = () +let g [arity:2]a _ = () +let g [arity:2]_ a = () ;;for _ = 0 to 10 do () done ;;for _ as _x = 0 to 10 do () done ;;for _ = 0 to 10 do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/array.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/array.res.txt index 32b3c803d0..f99697c3af 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/array.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/array.res.txt @@ -9,11 +9,11 @@ let ([|(1 : int);(2 : int)|] : int array) = () | [|1;2|] -> () | [|(1 : int);(2 : int)|] -> () | ([|(1 : int);(2 : int)|] : int) -> () -let f = Function$ (fun [arity:1][||] -> ()) -let f = Function$ (fun [arity:1][|x|] -> ()) -let f = Function$ (fun [arity:1][|x;y|] -> x + y) -let f = Function$ (fun [arity:1]([|x|] : int) -> ()) -let f = Function$ (fun [arity:1]([|x|] : int) -> ()) +let f [arity:1][||] = () +let f [arity:1][|x|] = () +let f [arity:1][|x;y|] = x + y +let f [arity:1]([|x|] : int) = () +let f [arity:1]([|x|] : int) = () ;;for [||] = 0 to 10 do () done ;;for [||] = 0 to 10 do () done ;;for [||] = 0 to 10 do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/constant.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/constant.res.txt index 70ade709ab..79aa64bcde 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/constant.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/constant.res.txt @@ -15,13 +15,12 @@ let ({js|stringPattern|js} : string) as s = () ;;for {js|stringPattern|js} = 0 to 10 do () done ;;for {js|stringPattern|js} as s = 0 to 10 do () done ;;for {js|stringPattern|js} as s = 0 to 10 do () done -let f = Function$ (fun [arity:1]{js|stringPattern|js} -> ()) -let f = Function$ (fun [arity:1]({js|stringPattern|js} as s) -> ()) -let f = Function$ (fun [arity:1]({js|stringPattern|js} as s) -> ()) -let f = Function$ (fun [arity:1]({js|stringPattern|js} : string) -> ()) -let f = - Function$ (fun [arity:1](({js|stringPattern|js} : string) as s) -> ()) -let f = Function$ (fun [arity:1]({js|stringPattern|js} : string) -> ()) +let f [arity:1]{js|stringPattern|js} = () +let f [arity:1]({js|stringPattern|js} as s) = () +let f [arity:1]({js|stringPattern|js} as s) = () +let f [arity:1]({js|stringPattern|js} : string) = () +let f [arity:1](({js|stringPattern|js} : string) as s) = () +let f [arity:1]({js|stringPattern|js} : string) = () let 1 = () let 1 as x = () let (1 : int) = () @@ -31,11 +30,11 @@ let (1 : int) as x = () | 1 as x -> () | (1 : int) -> () | (1 : int) as x -> () -let f = Function$ (fun [arity:1]1 -> ()) -let f = Function$ (fun [arity:1](1 as x) -> ()) -let f = Function$ (fun [arity:1](1 : int) -> ()) -let f = Function$ (fun [arity:1]((1 : int) as x) -> ()) -let f = Function$ (fun [arity:1](1 : int) -> ()) +let f [arity:1]1 = () +let f [arity:1](1 as x) = () +let f [arity:1](1 : int) = () +let f [arity:1]((1 : int) as x) = () +let f [arity:1](1 : int) = () ;;for i = 0 to 10 do () done ;;for i as x = 0 to 10 do () done ;;for i = 0 to 10 do () done @@ -49,16 +48,13 @@ let f = Function$ (fun [arity:1](1 : int) -> ()) let patterns = List.rev (List.map filterSpread patterns) in makeListPattern loc patterns None let _0 = 0x9A -let print = - Function$ - (fun [arity:2]ppf -> - fun i -> - match i.stamp with - | 0 -> fprintf ppf {js|%s!|js} i.name - | (-1) -> fprintf ppf {js|%s#|js} i.name - | 1 -> fprintf ppf {js|%s#|js} i.name - | (-1.) -> fprintf ppf {js|%s#|js} i.name - | 1. -> fprintf ppf {js|%s#|js} i.name) +let print [arity:2]ppf i = + match i.stamp with + | 0 -> fprintf ppf {js|%s!|js} i.name + | (-1) -> fprintf ppf {js|%s#|js} i.name + | 1 -> fprintf ppf {js|%s#|js} i.name + | (-1.) -> fprintf ppf {js|%s#|js} i.name + | 1. -> fprintf ppf {js|%s#|js} i.name let (-1)..(-1.) = x ;;match science with | (1.12, (-3.13)) -> true diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/constructor.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/constructor.res.txt index cf5a42dd94..e11c8e1b0b 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/constructor.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/constructor.res.txt @@ -34,24 +34,21 @@ let ((Instance (component : comp)) : React.t) = i | Instance (comp, tree) -> () | React.Instance (comp, tree) -> () | (Instance (comp : Component.t) : React.t) -> () -let f = Function$ (fun [arity:1](Instance) -> i) -let f = Function$ (fun [arity:1](Instance as i) -> i) -let f = Function$ (fun [arity:1](React.Instance) -> i) -let f = Function$ (fun [arity:1](React.Instance as x) -> i) -let f = Function$ (fun [arity:1](Instance component) -> i) -let f = Function$ (fun [arity:1](Instance component) -> i) -let f = Function$ (fun [arity:1](Instance { render; subtree }) -> i) -let f = Function$ (fun [arity:1](Instance ({ render; subtree }, inst)) -> i) -let f = - Function$ (fun [arity:1](Instance ({ render; subtree } : Instance.t)) -> i) -let f = - Function$ (fun [arity:1](Instance ({ render; subtree } : Instance.t)) -> i) -let f = Function$ (fun [arity:1](Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](Instance : React.t) -> i) -let f = Function$ (fun [arity:1](Instance : React.t) -> i) -let f = - Function$ (fun [arity:1](Instance (comp : Component.t) : React.t) -> ()) +let f [arity:1](Instance) = i +let f [arity:1](Instance as i) = i +let f [arity:1](React.Instance) = i +let f [arity:1](React.Instance as x) = i +let f [arity:1](Instance component) = i +let f [arity:1](Instance component) = i +let f [arity:1](Instance { render; subtree }) = i +let f [arity:1](Instance ({ render; subtree }, inst)) = i +let f [arity:1](Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](Instance (component, tree)) = i +let f [arity:1](Instance (component, tree)) = i +let f [arity:1](Instance : React.t) = i +let f [arity:1](Instance : React.t) = i +let f [arity:1](Instance (comp : Component.t) : React.t) = () ;;for Blue = x to y do () done ;;for Blue as c = x to y do () done ;;for Blue = x to y do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/dict.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/dict.res.txt index 3061adaee6..71d90dc35b 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/dict.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/dict.res.txt @@ -1,11 +1,9 @@ let someDict = Primitive_dict.make [|("one", {js|one|js})|] let (({ one?;_})[@res.dictPattern ]) = someDict -let foo = - Function$ - (fun [arity:1]() -> - match someDict with - | (({ one = {js|one|js};_})[@res.dictPattern ]) -> Js.log {js|one|js} - | _ -> Js.log {js|not one|js}) +let foo [arity:1]() = + match someDict with + | (({ one = {js|one|js};_})[@res.dictPattern ]) -> Js.log {js|one|js} + | _ -> Js.log {js|not one|js} type json = | Boolean of bool | Null [@as null] @@ -16,23 +14,18 @@ type json = type nonrec user = { name: string ; age?: float } -let decodeUser = - Function$ - (fun [arity:1](json : json) -> - (((match json with - | Object - (({ name = String name; age = ageJson;_})[@res.dictPattern ]) - -> - Some - { - name; - age = - ?((match ageJson with - | Number age -> Some age - | _ -> None)) - } - | _ -> (Js.log {js|Not an object.|js}; None)) - [@res.braces ]) : user option)) +let decodeUser [arity:1](json : json) = + (((match json with + | Object (({ name = String name; age = ageJson;_})[@res.dictPattern ]) + -> + Some + { + name; + age = + ?((match ageJson with | Number age -> Some age | _ -> None)) + } + | _ -> (Js.log {js|Not an object.|js}; None)) + [@res.braces ]) : user option) ;;Js.log (decodeUser (jsonParse (({js|{"name": "John", "age": 30}|js})[@res.template ]))) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/exception.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/exception.res.txt index e3d9e96b47..706842e109 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/exception.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/exception.res.txt @@ -25,14 +25,14 @@ let exception ((Foo : t exc) as e) = () | exception (Foo as e) -> () | exception Foo (a, b) -> () | (exception Foo : t exc) -> () -let f = Function$ (fun [arity:1]exception Foo -> ()) -let f = Function$ (fun [arity:1](exception Foo as e) -> ()) -let f = Function$ (fun [arity:1]exception (Foo as e) -> ()) -let f = Function$ (fun [arity:1]exception Foo (a, b) -> ()) -let f = Function$ (fun [arity:1]exception Foo -> ()) -let f = Function$ (fun [arity:1](exception Foo as e) -> ()) -let f = Function$ (fun [arity:1]exception Foo (a, b) -> ()) -let f = Function$ (fun [arity:1](exception Foo : t exc) -> ()) +let f [arity:1]exception Foo = () +let f [arity:1](exception Foo as e) = () +let f [arity:1]exception (Foo as e) = () +let f [arity:1]exception Foo (a, b) = () +let f [arity:1]exception Foo = () +let f [arity:1](exception Foo as e) = () +let f [arity:1]exception Foo (a, b) = () +let f [arity:1](exception Foo : t exc) = () ;;for exception Foo = 0 to 10 do () done ;;for exception Foo as e = 0 to 10 do () done ;;for exception Foo = 0 to 10 do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/extension.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/extension.res.txt index e669ad16e2..3dba64c406 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/extension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/extension.res.txt @@ -11,14 +11,13 @@ let [%patExt1 ]|[%patExt2 ] = () | [%pat.stuff test] as _x -> () | ([%pat.stuff test] : unit) -> () | [%patExt1 ]|[%patExt2 ] -> () -let f = Function$ (fun [arity:1][%patternExtension ] -> ()) -let f = Function$ (fun [arity:1][%pattern.extension ] -> ()) -let f = Function$ (fun [arity:1][%raw {js|x|js}] -> ()) -let f = - Function$ (fun [arity:2][%raw {js|x|js}] -> fun [%raw {js|y|js}] -> ()) -let f = Function$ (fun [arity:1]([%raw {js|x|js}] as _y) -> ()) -let f = Function$ (fun [arity:1]([%raw {js|x|js}] : unit) -> ()) -let f = Function$ (fun [arity:1]([%patExt1 ]|[%patExt2 ]) -> ()) +let f [arity:1][%patternExtension ] = () +let f [arity:1][%pattern.extension ] = () +let f [arity:1][%raw {js|x|js}] = () +let f [arity:2][%raw {js|x|js}] [%raw {js|y|js}] = () +let f [arity:1]([%raw {js|x|js}] as _y) = () +let f [arity:1]([%raw {js|x|js}] : unit) = () +let f [arity:1]([%patExt1 ]|[%patExt2 ]) = () ;;for [%ext ] = x to y do () done ;;for [%ext1 ]|[%ext2 ] = x to y do () done ;;for [%ext ] = x to y do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/firstClassModules.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/firstClassModules.res.txt index c971522621..a538484514 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/firstClassModules.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/firstClassModules.res.txt @@ -1,19 +1,14 @@ -let sort (type s) = Function$ (fun [arity:2](module Set) -> fun l -> ()) -let sort (type s) = - Function$ - (fun [arity:2]((module Set) : (module Set.S with type elt = s)) -> - fun l -> ()) -let sort (type s) = - Function$ - (fun - [arity:2]((module Set) : - (module Set.S with type elt = s and type elt2 = t)) - -> fun l -> ()) -let foo = Function$ (fun [arity:2](module Foo) -> fun baz -> Foo.bar baz) -let bump_list (type a) = - Function$ - (fun [arity:2]((module B) : (module Bumpable with type t = a)) -> - fun (l : a list) -> List.map ~f:((B.bump l)[@res.namedArgLoc ])) +let sort (type s) [arity:2](module Set) l = () +let sort (type s) [arity:2]((module Set) : (module Set.S with type elt = s)) + l = () +let sort (type s) + [arity:2]((module Set) : + (module Set.S with type elt = s and type elt2 = t)) + l = () +let foo [arity:2](module Foo) baz = Foo.bar baz +let bump_list (type a) + [arity:2]((module B) : (module Bumpable with type t = a)) (l : a list) = + List.map ~f:((B.bump l)[@res.namedArgLoc ]) ;;match x with | (module Set) -> () | ((module Set) : (module Set.S with type elt = s)) -> () diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/list.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/list.res.txt index 67522b4a55..62f7f5e8b1 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/list.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/list.res.txt @@ -33,24 +33,22 @@ let ((x::xs : int list) : int list) = () | x::(y::ys)::xs -> () | (x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l -> () | (x::xs : int list) -> () -let f = Function$ (fun [arity:1][] -> ()) -let f = Function$ (fun [arity:1]([] as p) -> ()) -let f = Function$ (fun [arity:1](x::[]) -> ()) -let f = Function$ (fun [arity:1](((x : int) as p)::[]) -> ()) -let f = Function$ (fun [arity:1]((x as p)::[] as p2) -> ()) -let f = Function$ (fun [arity:1](x::xs) -> ()) -let f = Function$ (fun [arity:1](x::(xs as tail)) -> ()) -let f = Function$ (fun [arity:1](x::y::tail) -> ()) -let f = Function$ (fun [arity:1](x::y::[]) -> ()) -let f = Function$ (fun [arity:1](x::y::[]) -> ()) -let f = Function$ (fun [arity:1](x::xs) -> ()) -let f = Function$ (fun [arity:1](x::y::tail) -> ()) -let f = Function$ (fun [arity:1](x::(y::ys)::xs) -> ()) -let f = - Function$ - (fun [arity:1]((x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l) - -> ()) -let f = Function$ (fun [arity:1](x::xs : int list) -> ()) +let f [arity:1][] = () +let f [arity:1]([] as p) = () +let f [arity:1](x::[]) = () +let f [arity:1](((x : int) as p)::[]) = () +let f [arity:1]((x as p)::[] as p2) = () +let f [arity:1](x::xs) = () +let f [arity:1](x::(xs as tail)) = () +let f [arity:1](x::y::tail) = () +let f [arity:1](x::y::[]) = () +let f [arity:1](x::y::[]) = () +let f [arity:1](x::xs) = () +let f [arity:1](x::y::tail) = () +let f [arity:1](x::(y::ys)::xs) = () +let f [arity:1]((x as p1)::((y as p2)::(ys as tail1))::(xs as tail2) as l) = + () +let f [arity:1](x::xs : int list) = () ;;for [] = x to y do () done ;;for [] as l = x to y do () done ;;for [] = x to y do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/polyvariants.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/polyvariants.res.txt index f9342b085d..9f2268f07f 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/polyvariants.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/polyvariants.res.txt @@ -31,24 +31,19 @@ let ((`Instance (component : comp)) : React.t) = i | `Instance ({ render; subtree } : Instance.t) -> () | `Instance (comp, tree) -> () | (`Instance (comp : Component.t) : React.t) -> () -let f = Function$ (fun [arity:1]`Instance -> i) -let f = Function$ (fun [arity:1](`Instance as i) -> i) -let f = Function$ (fun [arity:1](`Instance component) -> i) -let f = Function$ (fun [arity:1](`Instance component) -> i) -let f = Function$ (fun [arity:1](`Instance { render; subtree }) -> i) -let f = Function$ (fun [arity:1](`Instance ({ render; subtree }, inst)) -> i) -let f = - Function$ - (fun [arity:1](`Instance ({ render; subtree } : Instance.t)) -> i) -let f = - Function$ - (fun [arity:1](`Instance ({ render; subtree } : Instance.t)) -> i) -let f = Function$ (fun [arity:1](`Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](`Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](`Instance : React.t) -> i) -let f = Function$ (fun [arity:1](`Instance : React.t) -> i) -let f = - Function$ (fun [arity:1](`Instance (comp : Component.t) : React.t) -> ()) +let f [arity:1]`Instance = i +let f [arity:1](`Instance as i) = i +let f [arity:1](`Instance component) = i +let f [arity:1](`Instance component) = i +let f [arity:1](`Instance { render; subtree }) = i +let f [arity:1](`Instance ({ render; subtree }, inst)) = i +let f [arity:1](`Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](`Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](`Instance (component, tree)) = i +let f [arity:1](`Instance (component, tree)) = i +let f [arity:1](`Instance : React.t) = i +let f [arity:1](`Instance : React.t) = i +let f [arity:1](`Instance (comp : Component.t) : React.t) = () ;;for `Blue = x to y do () done ;;for `Blue as c = x to y do () done ;;for `Blue = x to y do () done @@ -67,22 +62,19 @@ let f = ;;for `Point { x; y; z } = x to y do () done ;;for `Point { x; y; z } as p = x to y do () done ;;match x with | #typeVar -> () | `lowercase -> () -let cmp = - Function$ - (fun [arity:2]selectedChoice -> - fun value -> - match (selectedChoice, value) with - | (#a, #a) -> true - | [|#b;#b|] -> true - | #b::#b::[] -> true - | { x = #c; y = #c } -> true - | Constructor (#a, #a) -> true - | `Constuctor (#a, #a) -> true - | #a as x -> true - | #a|#b -> true - | (#a : typ) -> true - | exception #a -> true - | _ -> false) +let cmp [arity:2]selectedChoice value = + match (selectedChoice, value) with + | (#a, #a) -> true + | [|#b;#b|] -> true + | #b::#b::[] -> true + | { x = #c; y = #c } -> true + | Constructor (#a, #a) -> true + | `Constuctor (#a, #a) -> true + | #a as x -> true + | #a|#b -> true + | (#a : typ) -> true + | exception #a -> true + | _ -> false ;;match polyVar with | `ease-in -> () | `ease-outâ›° -> () diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/record.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/record.res.txt index 2cb8f470d8..8560cd48a2 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/record.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/record.res.txt @@ -32,25 +32,24 @@ let ({ a } : myRecord) = x | { a;_} -> () | { a;_} -> () | ({ a } : myRecord) -> () -let f = Function$ (fun [arity:1]{ a } -> ()) -let f = Function$ (fun [arity:1]({ a } as r) -> ()) -let f = Function$ (fun [arity:1]{ a } -> ()) -let f = Function$ (fun [arity:1]{ a; b } -> ()) -let f = Function$ (fun [arity:1]{ a; b } -> ()) -let f = Function$ (fun [arity:1]{ ReasonReact.state = state } -> ()) -let f = - Function$ (fun [arity:1]{ ReasonReact.state = (state as prevState) } -> ()) -let f = Function$ (fun [arity:1]{ ReasonReact.state = theState } -> ()) -let f = Function$ (fun [arity:1]{ a = u } -> ()) -let f = Function$ (fun [arity:1]{ a = (u : int) } -> ()) -let f = Function$ (fun [arity:1]{ a = (((u as x) : int) as r) } -> ()) -let f = Function$ (fun [arity:1]{ a = { x; y } } -> ()) -let f = Function$ (fun [arity:1]{ a = { x = r; y = r2 } } -> ()) -let f = Function$ (fun [arity:1]{ a;_} -> ()) -let f = Function$ (fun [arity:1]{ a;_} -> ()) -let f = Function$ (fun [arity:1]({ a } : myRecord) -> ()) -let f = Function$ (fun [arity:1]({ a } : myRecord) -> ()) -let f = Function$ (fun [arity:1](({ a } : myRecord) as p) -> ()) +let f [arity:1]{ a } = () +let f [arity:1]({ a } as r) = () +let f [arity:1]{ a } = () +let f [arity:1]{ a; b } = () +let f [arity:1]{ a; b } = () +let f [arity:1]{ ReasonReact.state = state } = () +let f [arity:1]{ ReasonReact.state = (state as prevState) } = () +let f [arity:1]{ ReasonReact.state = theState } = () +let f [arity:1]{ a = u } = () +let f [arity:1]{ a = (u : int) } = () +let f [arity:1]{ a = (((u as x) : int) as r) } = () +let f [arity:1]{ a = { x; y } } = () +let f [arity:1]{ a = { x = r; y = r2 } } = () +let f [arity:1]{ a;_} = () +let f [arity:1]{ a;_} = () +let f [arity:1]({ a } : myRecord) = () +let f [arity:1]({ a } : myRecord) = () +let f [arity:1](({ a } : myRecord) as p) = () ;;for { a } = 0 to 10 do () done ;;for { a } as p = 0 to 10 do () done ;;for { a } = 0 to 10 do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/tuple.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/tuple.res.txt index 04a2d31947..ac98467c92 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/tuple.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/tuple.res.txt @@ -15,14 +15,13 @@ let (((1 : int), (2 : int)) : (int * int)) as tup = () | (((1 as p1) : int), ((2 as p2) : int)) as tup -> () | (((1 : int), (2 : int)) : (int * int)) -> () | (((1 : int), (2 : int)) : (int * int)) as tup -> () -let f = Function$ (fun [arity:1]x -> ()) -let f = Function$ (fun [arity:1]x -> ()) -let f = Function$ (fun [arity:1](x, y) -> x + y) -let f = Function$ (fun [arity:1](((x as p1), (y as p2)) as tup) -> x + y) -let f = Function$ (fun [arity:1]((x, y) : (int * int)) -> ()) -let f = Function$ (fun [arity:1]((x, y) : (int * int)) -> ()) -let f = - Function$ (fun [arity:1]((((x, y) as tup1) : (int * int)) as tup) -> ()) +let f [arity:1]x = () +let f [arity:1]x = () +let f [arity:1](x, y) = x + y +let f [arity:1](((x as p1), (y as p2)) as tup) = x + y +let f [arity:1]((x, y) : (int * int)) = () +let f [arity:1]((x, y) : (int * int)) = () +let f [arity:1]((((x, y) as tup1) : (int * int)) as tup) = () ;;for (x, y) = 0 to 10 do () done ;;for (x, y) as tup = 0 to 10 do () done ;;for (x, y) = 0 to 10 do () done diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/unit.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/unit.res.txt index 600c1ab974..edf7925bae 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/unit.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/unit.res.txt @@ -26,13 +26,13 @@ let (() : unit) as x = () ;;for (() : unit) as _u = () to () do () done ;;for ((() as _u) : unit) = () to () do () done ;;for (() : unit) as _u = () to () do () done -let f = Function$ (fun [arity:1]() -> ()) -let f = Function$ (fun [arity:1]() -> ()) -let f = Function$ (fun [arity:1](() as _u) -> ()) -let f = Function$ (fun [arity:2]() -> fun () -> ()) -let f = Function$ (fun [arity:2](() as _u) -> fun (() as _u) -> ()) -let f = Function$ (fun [arity:1](() : unit) -> ()) -let f = Function$ (fun [arity:1]((() as _u) : unit) -> ()) -let f = Function$ (fun [arity:1]((() : unit) as _u) -> ()) -let f = Function$ (fun [arity:1](() : unit) -> ()) -let f = Function$ (fun [arity:1]((() : unit) as _u) -> ()) \ No newline at end of file +let f [arity:1]() = () +let f [arity:1]() = () +let f [arity:1](() as _u) = () +let f [arity:2]() () = () +let f [arity:2](() as _u) (() as _u) = () +let f [arity:1](() : unit) = () +let f [arity:1]((() as _u) : unit) = () +let f [arity:1]((() : unit) as _u) = () +let f [arity:1](() : unit) = () +let f [arity:1]((() : unit) as _u) = () \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/variantSpreads.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/variantSpreads.res.txt index 39f0b14340..790aaff72e 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/variantSpreads.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/variantSpreads.res.txt @@ -12,43 +12,31 @@ type nonrec c = type nonrec d = | ... of b | ... of c -let doWithA = - Function$ - (fun [arity:1](a : a) -> - ((match a with - | One -> Js.log {js|aaa|js} - | Two -> Js.log {js|twwwoooo|js} - | Three -> Js.log {js|threeeee|js}) - [@res.braces ])) -let doWithB = - Function$ - (fun [arity:1](b : b) -> - ((match b with - | One -> Js.log {js|aaa|js} - | _ -> Js.log {js|twwwoooo|js}) - [@res.braces ])) -let lookup = - Function$ - (fun [arity:1](b : b) -> - match b with - | ((#a)[@res.patVariantSpread ]) as a -> doWithA a - | Four -> Js.log {js|four|js} - | Five -> Js.log {js|five|js}) -let lookup2 = - Function$ - (fun [arity:1](d : d) -> - match d with - | ((#a)[@res.patVariantSpread ]) as a -> doWithA a - | ((#b)[@res.patVariantSpread ]) as b -> doWithB b - | Six|Seven -> Js.log {js|Got rest of d|js}) -let lookupOpt = - Function$ - (fun [arity:1](b : b option) -> - match b with - | Some (((#a)[@res.patVariantSpread ]) as a) -> doWithA a - | Some (Four) -> Js.log {js|four|js} - | Some (Five) -> Js.log {js|five|js} - | None -> Js.log {js|None|js}) +let doWithA [arity:1](a : a) = + ((match a with + | One -> Js.log {js|aaa|js} + | Two -> Js.log {js|twwwoooo|js} + | Three -> Js.log {js|threeeee|js}) + [@res.braces ]) +let doWithB [arity:1](b : b) = + ((match b with | One -> Js.log {js|aaa|js} | _ -> Js.log {js|twwwoooo|js}) + [@res.braces ]) +let lookup [arity:1](b : b) = + match b with + | ((#a)[@res.patVariantSpread ]) as a -> doWithA a + | Four -> Js.log {js|four|js} + | Five -> Js.log {js|five|js} +let lookup2 [arity:1](d : d) = + match d with + | ((#a)[@res.patVariantSpread ]) as a -> doWithA a + | ((#b)[@res.patVariantSpread ]) as b -> doWithB b + | Six|Seven -> Js.log {js|Got rest of d|js} +let lookupOpt [arity:1](b : b option) = + match b with + | Some (((#a)[@res.patVariantSpread ]) as a) -> doWithA a + | Some (Four) -> Js.log {js|four|js} + | Some (Five) -> Js.log {js|five|js} + | None -> Js.log {js|None|js} module Foo = struct type nonrec zz = @@ -58,15 +46,11 @@ module Foo = | ... of zz | Third end -let doWithZ = - Function$ - (fun [arity:1](z : Foo.zz) -> - match z with - | First -> Js.log {js|First|js} - | Second -> Js.log {js|Second|js}) -let lookup3 = - Function$ - (fun [arity:1](d : Foo.xx) -> - match d with - | ((#Foo.zz)[@res.patVariantSpread ]) as z -> Js.log z - | Third -> Js.log {js|Third|js}) \ No newline at end of file +let doWithZ [arity:1](z : Foo.zz) = + match z with + | First -> Js.log {js|First|js} + | Second -> Js.log {js|Second|js} +let lookup3 [arity:1](d : Foo.xx) = + match d with + | ((#Foo.zz)[@res.patVariantSpread ]) as z -> Js.log z + | Third -> Js.log {js|Third|js} \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/pattern/expected/variants.res.txt b/tests/syntax_tests/data/parsing/grammar/pattern/expected/variants.res.txt index 432975df14..cfc110e98b 100644 --- a/tests/syntax_tests/data/parsing/grammar/pattern/expected/variants.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/pattern/expected/variants.res.txt @@ -31,24 +31,19 @@ let ((`Instance (component : comp)) : React.t) = i | `Instance ({ render; subtree } : Instance.t) -> () | `Instance (comp, tree) -> () | (`Instance (comp : Component.t) : React.t) -> () -let f = Function$ (fun [arity:1]`Instance -> i) -let f = Function$ (fun [arity:1](`Instance as i) -> i) -let f = Function$ (fun [arity:1](`Instance component) -> i) -let f = Function$ (fun [arity:1](`Instance component) -> i) -let f = Function$ (fun [arity:1](`Instance { render; subtree }) -> i) -let f = Function$ (fun [arity:1](`Instance ({ render; subtree }, inst)) -> i) -let f = - Function$ - (fun [arity:1](`Instance ({ render; subtree } : Instance.t)) -> i) -let f = - Function$ - (fun [arity:1](`Instance ({ render; subtree } : Instance.t)) -> i) -let f = Function$ (fun [arity:1](`Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](`Instance (component, tree)) -> i) -let f = Function$ (fun [arity:1](`Instance : React.t) -> i) -let f = Function$ (fun [arity:1](`Instance : React.t) -> i) -let f = - Function$ (fun [arity:1](`Instance (comp : Component.t) : React.t) -> ()) +let f [arity:1]`Instance = i +let f [arity:1](`Instance as i) = i +let f [arity:1](`Instance component) = i +let f [arity:1](`Instance component) = i +let f [arity:1](`Instance { render; subtree }) = i +let f [arity:1](`Instance ({ render; subtree }, inst)) = i +let f [arity:1](`Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](`Instance ({ render; subtree } : Instance.t)) = i +let f [arity:1](`Instance (component, tree)) = i +let f [arity:1](`Instance (component, tree)) = i +let f [arity:1](`Instance : React.t) = i +let f [arity:1](`Instance : React.t) = i +let f [arity:1](`Instance (comp : Component.t) : React.t) = () ;;for `Blue = x to y do () done ;;for `Blue as c = x to y do () done ;;for `Blue = x to y do () done diff --git a/tests/syntax_tests/data/parsing/grammar/signature/expected/itemExtension.res.txt b/tests/syntax_tests/data/parsing/grammar/signature/expected/itemExtension.res.txt index 93b79be024..e22ccf372b 100644 --- a/tests/syntax_tests/data/parsing/grammar/signature/expected/itemExtension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/signature/expected/itemExtension.res.txt @@ -2,6 +2,6 @@ module type Ext = sig [%%item.extension ] [%%item.extension.with.args {js|argument|js}] - [%%item.extension.with.args Function$ (fun [arity:1]x -> f x)] + [%%item.extension.with.args fun [arity:1]x -> f x] [%%item.extension ][@@withAttr ] end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/signature/expected/standAloneAttribute.res.txt b/tests/syntax_tests/data/parsing/grammar/signature/expected/standAloneAttribute.res.txt index 1cbdcbe530..6edea5748e 100644 --- a/tests/syntax_tests/data/parsing/grammar/signature/expected/standAloneAttribute.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/signature/expected/standAloneAttribute.res.txt @@ -2,5 +2,5 @@ module type StandaloneAttribute = sig [@@@standaloneAttribute ] [@@@standaloneAttribute withPayload] - [@@@standaloneAttribute Function$ (fun [arity:1]x -> x)] + [@@@standaloneAttribute fun [arity:1]x -> x] end \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/itemExtension.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/itemExtension.res.txt index 433e21c0b2..c2ed4e9624 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/itemExtension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/itemExtension.res.txt @@ -1,5 +1,5 @@ [%%itemExtension ] [%%item.extension ] [%%item.extension.with.args {js|argument|js}] -[%%item.extension.with.args Function$ (fun [arity:1]x -> f x)] +[%%item.extension.with.args fun [arity:1]x -> f x] [%%itemExtension ][@@attrOnExtension ] \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/letBinding.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/letBinding.res.txt index e48fba501b..16743dcf49 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/letBinding.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/letBinding.res.txt @@ -3,9 +3,8 @@ let a = 1[@@onFirstBinding ] let a = 1[@@onFirstBinding ] and b = 2[@@onSecondBinding ] let f : type t. t foo = - Function$ - (fun [arity:1]sideEffect -> - ((let module M = struct exception E of t end in - sideEffect (); Function$ ((fun [arity:1]x -> M.E x))) - [@res.braces ])) -let f : type t x u. (t * x * y) list = Function$ (fun [arity:1]l -> f l) \ No newline at end of file + fun [arity:1]sideEffect -> + ((let module M = struct exception E of t end in + sideEffect (); (fun [arity:1]x -> M.E x)) + [@res.braces ]) +let f : type t x u. (t * x * y) list = fun [arity:1]l -> f l \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/modExprExtension.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/modExprExtension.res.txt index c4af1f86b1..592f06fe05 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/modExprExtension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/modExprExtension.res.txt @@ -1,4 +1,4 @@ module A = [%modExprExtension ] module B = [%mod.expr.extension ] module C = [%mod.expr.extension.with.args {js|argument|js}] -module D = [%mod.expr.extension.with.args Function$ (fun [arity:1]x -> f x)] \ No newline at end of file +module D = [%mod.expr.extension.with.args fun [arity:1]x -> f x] \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/moduleTypeExtension.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/moduleTypeExtension.res.txt index 1d7d7f81e0..07536d09b3 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/moduleTypeExtension.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/moduleTypeExtension.res.txt @@ -1,5 +1,4 @@ module type A = [%modTypeExtension ] module type B = [%mod.type.extension ] module type C = [%mod.type.extension.with.args {js|argument|js}] -module type D = - [%mod.type.extension.with.args Function$ (fun [arity:1]x -> f x)] \ No newline at end of file +module type D = [%mod.type.extension.with.args fun [arity:1]x -> f x] \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/structure/expected/standaloneAttribute.res.txt b/tests/syntax_tests/data/parsing/grammar/structure/expected/standaloneAttribute.res.txt index 54269ef167..4ceacc35ff 100644 --- a/tests/syntax_tests/data/parsing/grammar/structure/expected/standaloneAttribute.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/structure/expected/standaloneAttribute.res.txt @@ -1,3 +1,3 @@ [@@@standaloneAttribute ] [@@@standaloneAttribute {js|with payload|js}] -[@@@standaloneAttribute Function$ (fun [arity:1]x -> x + 1)] \ No newline at end of file +[@@@standaloneAttribute fun [arity:1]x -> x + 1] \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/polyvariant.res.txt b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/polyvariant.res.txt index 500268180a..d2dc9d21a0 100644 --- a/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/polyvariant.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typedefinition/expected/polyvariant.res.txt @@ -55,4 +55,4 @@ type nonrec t = [< `x [@a ]] type nonrec t = [< `a of ((int * int) * int) [@one ] | ((int)[@two ]) | `b of string [@three ]> `w `x `y] -let f = Function$ (fun [arity:1](x : [ `b ]) -> x) \ No newline at end of file +let f [arity:1](x : [ `b ]) = x \ 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 ce8c44639a..fc276bf314 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 @@ -15,24 +15,18 @@ let steve = let steve = ((([%obj { name = {js|Steve|js}; age = 30 }] : < user ;age: int > )) [@res.braces ]) -let printFullUser = - Function$ (fun [arity:1](steve : < user ;age: int > ) -> Js.log steve) -let printFullUser = - Function$ - (fun [arity:1]~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) - -> Js.log steve) -let printFullUser = - Function$ - (fun [arity:1]~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) - -> Js.log steve) -let printFullUser = - Function$ - (fun [arity:1]?user:(((user)[@res.namedArgLoc ])= - (steve : < user ;age: int > )) -> Js.log steve) +let printFullUser [arity:1](steve : < user ;age: int > ) = Js.log steve +let printFullUser + [arity:1]~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) = + Js.log steve +let printFullUser + [arity:1]~user:(((user : < user ;age: int > ))[@res.namedArgLoc ]) = + Js.log steve +let printFullUser [arity:1]?user:(((user)[@res.namedArgLoc ])= + (steve : < user ;age: int > )) = Js.log steve external steve : < user ;age: int > = "steve"[@@val ] -let makeCeoOf30yearsOld = - Function$ - (fun [arity:1]name -> ([%obj { name; age = 30 }] : < user ;age: int > )) +let makeCeoOf30yearsOld [arity:1]name = + ([%obj { name; age = 30 }] : < user ;age: int > ) type nonrec optionalUser = < user ;age: int > option type nonrec optionalTupleUser = (< user ;age: int > * < user ;age: int > ) option diff --git a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/typeconstr.res.txt b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/typeconstr.res.txt index 6235a20fde..85afc1832c 100644 --- a/tests/syntax_tests/data/parsing/grammar/typexpr/expected/typeconstr.res.txt +++ b/tests/syntax_tests/data/parsing/grammar/typexpr/expected/typeconstr.res.txt @@ -60,5 +60,5 @@ type nonrec ('T, 'E) id_6 = | Ok of 'T | Err of { payload: 'E } -let foo = Function$ (fun [arity:1](x : int as 'X) -> x) +let foo [arity:1](x : int as 'X) = x module type A = (Foo with type t = 'X constraint 'X = int) \ 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 64bf9102df..dd25f83078 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 @@ -2,15 +2,9 @@ type nonrec t = unit type nonrec t = (unit -> unit, [ `Has_arity1 ]) function$ type nonrec t = (unit -> unit -> unit, [ `Has_arity2 ]) function$ type nonrec t = (unit -> unit, [ `Has_arity1 ]) function$ -let f = - Function$ - (fun [arity:1](f : (unit -> unit, [ `Has_arity1 ]) function$) -> f ()) -let f = - Function$ - (fun [arity:1](f : (unit -> unit, [ `Has_arity1 ]) function$) -> f ()) -let f = - Function$ - (fun [arity:1](f : (unit -> unit -> unit, [ `Has_arity2 ]) function$) -> - f () ()) +let f [arity:1](f : (unit -> unit, [ `Has_arity1 ]) function$) = f () +let f [arity:1](f : (unit -> unit, [ `Has_arity1 ]) function$) = f () +let f [arity:1](f : (unit -> unit -> unit, [ `Has_arity2 ]) function$) = + f () () external svg : (unit -> React.element, [ `Has_arity1 ]) function$ = "svg" external thing : (unit -> unit, [ `Has_arity1 ]) function$ = "svg" \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt b/tests/syntax_tests/data/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt index 2a06ff2c95..8cca00a285 100644 --- a/tests/syntax_tests/data/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt +++ b/tests/syntax_tests/data/parsing/infiniteLoops/expected/equalAfterBinaryExpr.res.txt @@ -10,172 +10,150 @@ Did you mean `==` here? -let rec _addLoop = - Function$ - (fun [arity:2]rbt -> - fun currentNode -> - ((if (Some currentNode) == (rbt |.u root) - then currentNode.color <- Black - else - if (currentNode.parent |.u castNotOption).color == Black - then () +let rec _addLoop [arity:2]rbt currentNode = + ((if (Some currentNode) == (rbt |.u root) + then currentNode.color <- Black + else + if (currentNode.parent |.u castNotOption).color == Black + then () + else + if + (((let uncle = uncleOf currentNode in + (uncle != None) && ((uncle |.u castNotOption).color == Red))) + [@res.braces ]) + then + ((currentNode.parent |.u castNotOption).color <- Black; + ((uncleOf currentNode) |.u castNotOption).color <- Black; + ((grandParentOf currentNode) |.u castNotOption).color <- Red; + _addLoop rbt ((grandParentOf currentNode) |.u castNotOption)) + else + (let currentNode = + if + (not (isLeft currentNode)) && + (isLeft (currentNode.parent |.u castNotOption)) + then + (rotateLeft rbt (currentNode.parent |.u castNotOption); + currentNode.left |.u castNotOption) else if - (((let uncle = uncleOf currentNode in - (uncle != None) && - ((uncle |.u castNotOption).color == Red))) - [@res.braces ]) + (isLeft currentNode) && + (not (isLeft (currentNode.parent |.u castNotOption))) then - ((currentNode.parent |.u castNotOption).color <- Black; - ((uncleOf currentNode) |.u castNotOption).color <- Black; - ((grandParentOf currentNode) |.u castNotOption).color <- - Red; - _addLoop rbt - ((grandParentOf currentNode) |.u castNotOption)) - else - (let currentNode = + (rotateRight rbt (currentNode.parent |.u castNotOption); + currentNode.right |.u castNotOption) + else currentNode in + (currentNode.parent |.u castNotOption).color <- Black; + ((grandParentOf currentNode) |.u castNotOption).color <- Red; + if isLeft currentNode + then + rotateRight rbt ((grandParentOf currentNode) |.u castNotOption) + else + rotateLeft rbt ((grandParentOf currentNode) |.u castNotOption))) + [@res.braces ]) +let removeNode [arity:2]rbt node = + ((if nodeToRemove.color == Black + then + (if successor.color == Red + then + (successor.color <- Black; + if successor.parent == None then rbt |.u (rootSet (Some successor))) + else + (let break = ref false in + let successorRef = ref successor in + while not break.contents do + let successor = successorRef.contents in + match successor.parent with + | None -> + (rbt |.u (rootSet (Some successor)); break.contents <- true) + | Some successorParent -> + let sibling = siblingOf successor in + (if + (sibling != None) && + ((sibling |.u castNotOption).color == Red) + then + (successorParent.color <- Red; + (sibling |.u castNotOption).color <- Black; + if isLeft successor + then rotateLeft rbt successorParent + else rotateRight rbt successorParent); + (let sibling = siblingOf successor in + let siblingNN = sibling |.u castNotOption in + if + (successorParent.color == Black) && + ((sibling == None) || + (((siblingNN.color == Black) && + ((siblingNN.left == None) || + ((siblingNN.left |.u castNotOption).color == + Black))) + && + ((siblingNN.right == None) || + ((siblingNN.right |.u castNotOption).color == + Black)))) + then + (if sibling != None then siblingNN.color <- Red; + successorRef.contents <- successorParent) + else if - (not (isLeft currentNode)) && - (isLeft (currentNode.parent |.u castNotOption)) + (successorParent.color == Red) && + ((sibling == None) || + (((siblingNN.color == Black) && + ((siblingNN.left == None) || + ((siblingNN.left |.u castNotOption).color + == Black))) + && + ((siblingNN.right == None) || + ((siblingNN.right |.u castNotOption).color + == Black)))) then - (rotateLeft rbt (currentNode.parent |.u castNotOption); - currentNode.left |.u castNotOption) + (if sibling != None then siblingNN.color <- Red; + successorParent.color <- Black; + break.contents <- true) else if - (isLeft currentNode) && - (not - (isLeft (currentNode.parent |.u castNotOption))) + (sibling != None) && + ((sibling |.u castNotOption).color == Black) then - (rotateRight rbt - (currentNode.parent |.u castNotOption); - currentNode.right |.u castNotOption) - else currentNode in - (currentNode.parent |.u castNotOption).color <- Black; - ((grandParentOf currentNode) |.u castNotOption).color <- - Red; - if isLeft currentNode - then - rotateRight rbt - ((grandParentOf currentNode) |.u castNotOption) - else - rotateLeft rbt - ((grandParentOf currentNode) |.u castNotOption))) - [@res.braces ])) -let removeNode = - Function$ - (fun [arity:2]rbt -> - fun node -> - ((if nodeToRemove.color == Black - then - (if successor.color == Red - then - (successor.color <- Black; - if successor.parent == None - then rbt |.u (rootSet (Some successor))) - else - (let break = ref false in - let successorRef = ref successor in - while not break.contents do - let successor = successorRef.contents in - match successor.parent with - | None -> - (rbt |.u (rootSet (Some successor)); - break.contents <- true) - | Some successorParent -> - let sibling = siblingOf successor in - (if - (sibling != None) && - ((sibling |.u castNotOption).color == Red) - then - (successorParent.color <- Red; - (sibling |.u castNotOption).color <- Black; - if isLeft successor - then rotateLeft rbt successorParent - else rotateRight rbt successorParent); - (let sibling = siblingOf successor in - let siblingNN = sibling |.u castNotOption in + (let sibling = sibling |.u castNotOption in if - (successorParent.color == Black) && - ((sibling == None) || - (((siblingNN.color == Black) && - ((siblingNN.left == None) || - ((siblingNN.left |.u castNotOption).color - == Black))) - && - ((siblingNN.right == None) || - ((siblingNN.right |.u castNotOption).color - == Black)))) + (((isLeft successor) && + ((sibling.right == None) || + ((sibling.right |.u castNotOption).color == + Black))) + && (sibling.left != None)) + && + ((sibling.left |.u castNotOption).color == Red) then - (if sibling != None then siblingNN.color <- Red; - successorRef.contents <- successorParent) + (sibling.color <- Red; + (sibling.left |.u castNotOption).color <- Black; + rotateRight rbt sibling) else if - (successorParent.color == Red) && - ((sibling == None) || - (((siblingNN.color == Black) && - ((siblingNN.left == None) || - ((siblingNN.left |.u castNotOption).color - == Black))) - && - ((siblingNN.right == None) || - ((siblingNN.right |.u castNotOption).color - == Black)))) - then - (if sibling != None then siblingNN.color <- Red; - successorParent.color <- Black; - break.contents <- true) - else - if - (sibling != None) && - ((sibling |.u castNotOption).color == Black) - then - (let sibling = sibling |.u castNotOption in - if - (((isLeft successor) && - ((sibling.right == None) || - ((sibling.right |.u castNotOption).color - == Black))) - && (sibling.left != None)) - && + (((not (isLeft successor)) && + ((sibling.left == None) || ((sibling.left |.u castNotOption).color - == Red) - then - (sibling.color <- Red; - (sibling.left |.u castNotOption).color <- - Black; - rotateRight rbt sibling) - else - if - (((not (isLeft successor)) && - ((sibling.left == None) || - ((sibling.left |.u castNotOption).color - == Black))) - && (sibling.right != None)) - && - ((sibling.right |.u castNotOption).color - == Red) - then - (sibling.color <- Red; - (sibling.right |.u castNotOption).color - <- Black; - rotateLeft rbt sibling); - break.contents <- true) - else - (let sibling = siblingOf successor in - let sibling = sibling |.u castNotOption in - sibling.color <- (successorParent.color); - if isLeft successor - then - ((sibling.right |.u castNotOption).color <- - Black; - rotateRight rbt successorParent) - else - ((sibling.left |.u castNotOption).color <- - Black; - rotateLeft rbt successorParent)))) - done)); - if isLeaf successor - then - (if (rbt |.u root) == (Some successor) - then (rbt |.u root) = None)) - [@res.braces ])) \ No newline at end of file + == Black))) + && (sibling.right != None)) + && + ((sibling.right |.u castNotOption).color == + Red) + then + (sibling.color <- Red; + (sibling.right |.u castNotOption).color <- + Black; + rotateLeft rbt sibling); + break.contents <- true) + else + (let sibling = siblingOf successor in + let sibling = sibling |.u castNotOption in + sibling.color <- (successorParent.color); + if isLeft successor + then + ((sibling.right |.u castNotOption).color <- Black; + rotateRight rbt successorParent) + else + ((sibling.left |.u castNotOption).color <- Black; + rotateLeft rbt successorParent)))) + done)); + if isLeaf successor + then (if (rbt |.u root) == (Some successor) then (rbt |.u root) = None)) + [@res.braces ]) \ 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 f690cecfef..9241e845d3 100644 --- a/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt +++ b/tests/syntax_tests/data/parsing/infiniteLoops/expected/nonRecTypes.res.txt @@ -125,423 +125,326 @@ include ;;{js||js} ;;{js|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@|js} end - let has = - Function$ - (fun [arity:2]rbt -> - fun value -> (_findNode rbt (rootGet rbt) value) != None) - let rec minNode = Function$ (fun [arity:1]node -> [%rescript.exprhole ]) - let findMin = Function$ (fun [arity:1]rbt -> [%rescript.exprhole ]) - let removeNode = - Function$ - (fun [arity:2]rbt -> - fun node -> - ((let nodeToRemove = - match ((leftGet node), (rightGet node)) with - | (Some _, Some _) -> - let successor = castNotOption (minNode (rightGet node)) in - (valueSet node (valueGet successor); - heightSet node (heightGet successor); - successor) - | _ -> node in - let successor = - match leftGet nodeToRemove with - | None -> rightGet nodeToRemove - | left -> left in - let (successor, isLeaf) = - match successor with - | None -> - let leaf = - createNode ~value:((Js.Internal.raw_expr {js|0|js}) - [@res.namedArgLoc ]) ~color:((Black) - [@res.namedArgLoc ]) ~height:((0.) - [@res.namedArgLoc ]) in - let isLeaf = - Js.Internal.fn_mk1 - (Function$ (fun [arity:1]x -> x == leaf)) in - (leaf, isLeaf) - | Some successor -> - (successor, - (Js.Internal.fn_mk1 - (Function$ (fun [arity:1]_ -> false)))) in - let nodeParent = parentGet nodeToRemove in - parentSet successor nodeParent; - (match nodeParent with - | None -> () - | Some parent -> - leftOrRightSet parent ~node:((nodeToRemove) - [@res.namedArgLoc ]) (Some successor)); - updateSumRecursive rbt successor; - if (colorGet nodeToRemove) == Black - then - (if (colorGet successor) == Red - then - (colorSet successor Black; - if (parentGet successor) == None - then rootSet rbt (Some successor)) - else - (let break = ref false in - let successorRef = ref successor in - while not break.contents do - let successor = successorRef.contents in - match parentGet successor with - | None -> - (rootSet rbt (Some successor); - break.contents <- true) - | Some successorParent -> - let sibling = siblingOf successor in - (if - (sibling != None) && - ((colorGet (castNotOption sibling)) == Red) - then - (colorSet successorParent Red; - colorSet (castNotOption sibling) Black; - if isLeft successor - then rotateLeft rbt successorParent - else rotateRight rbt successorParent); - (let sibling = siblingOf successor in - let siblingNN = castNotOption sibling in + let has [arity:2]rbt value = (_findNode rbt (rootGet rbt) value) != None + let rec minNode [arity:1]node = [%rescript.exprhole ] + let findMin [arity:1]rbt = [%rescript.exprhole ] + let removeNode [arity:2]rbt node = + ((let nodeToRemove = + match ((leftGet node), (rightGet node)) with + | (Some _, Some _) -> + let successor = castNotOption (minNode (rightGet node)) in + (valueSet node (valueGet successor); + heightSet node (heightGet successor); + successor) + | _ -> node in + let successor = + match leftGet nodeToRemove with + | None -> rightGet nodeToRemove + | left -> left in + let (successor, isLeaf) = + match successor with + | None -> + let leaf = + createNode ~value:((Js.Internal.raw_expr {js|0|js}) + [@res.namedArgLoc ]) ~color:((Black)[@res.namedArgLoc ]) + ~height:((0.)[@res.namedArgLoc ]) in + let isLeaf = Js.Internal.fn_mk1 (fun [arity:1]x -> x == leaf) in + (leaf, isLeaf) + | Some successor -> + (successor, (Js.Internal.fn_mk1 (fun [arity:1]_ -> false))) in + let nodeParent = parentGet nodeToRemove in + parentSet successor nodeParent; + (match nodeParent with + | None -> () + | Some parent -> + leftOrRightSet parent ~node:((nodeToRemove)[@res.namedArgLoc ]) + (Some successor)); + updateSumRecursive rbt successor; + if (colorGet nodeToRemove) == Black + then + (if (colorGet successor) == Red + then + (colorSet successor Black; + if (parentGet successor) == None + then rootSet rbt (Some successor)) + else + (let break = ref false in + let successorRef = ref successor in + while not break.contents do + let successor = successorRef.contents in + match parentGet successor with + | None -> + (rootSet rbt (Some successor); break.contents <- true) + | Some successorParent -> + let sibling = siblingOf successor in + (if + (sibling != None) && + ((colorGet (castNotOption sibling)) == Red) + then + (colorSet successorParent Red; + colorSet (castNotOption sibling) Black; + if isLeft successor + then rotateLeft rbt successorParent + else rotateRight rbt successorParent); + (let sibling = siblingOf successor in + let siblingNN = castNotOption sibling in + if + ((colorGet successorParent) == Black) && + ((sibling == None) || + ((((colorGet siblingNN) == Black) && + (((leftGet siblingNN) == None) || + ((colorGet + (castNotOption (leftGet siblingNN))) + == Black))) + && + (((rightGet siblingNN) == None) || + ((colorGet + (castNotOption (rightGet siblingNN))) + == Black)))) + then + (if sibling != None then colorSet siblingNN Red; + successorRef.contents <- successorParent) + else + if + ((colorGet successorParent) == Red) && + ((sibling == None) || + ((((colorGet siblingNN) == Black) && + (((leftGet siblingNN) == None) || + ((colorGet + (castNotOption (leftGet siblingNN))) + == Black))) + && + (((rightGet siblingNN) == None) || + ((colorGet + (castNotOption (rightGet siblingNN))) + == Black)))) + then + (if sibling != None then colorSet siblingNN Red; + colorSet successorParent Black; + break.contents <- true) + else + if + (sibling != None) && + ((colorGet (castNotOption sibling)) == Black) + then + (let sibling = castNotOption sibling in if - ((colorGet successorParent) == Black) && - ((sibling == None) || - ((((colorGet siblingNN) == Black) && - (((leftGet siblingNN) == None) || - ((colorGet - (castNotOption - (leftGet siblingNN))) - == Black))) - && - (((rightGet siblingNN) == None) || - ((colorGet - (castNotOption - (rightGet siblingNN))) - == Black)))) + (((isLeft successor) && + (((rightGet sibling) == None) || + ((colorGet + (castNotOption (rightGet sibling))) + == Black))) + && ((leftGet sibling) != None)) + && + ((colorGet (castNotOption (leftGet sibling))) + == Red) then - (if sibling != None - then colorSet siblingNN Red; - successorRef.contents <- successorParent) + (colorSet sibling Red; + colorSet (castNotOption (leftGet sibling)) + Black; + rotateRight rbt sibling) else if - ((colorGet successorParent) == Red) && - ((sibling == None) || - ((((colorGet siblingNN) == Black) && - (((leftGet siblingNN) == None) || - ((colorGet - (castNotOption - (leftGet siblingNN))) - == Black))) - && - (((rightGet siblingNN) == None) || - ((colorGet - (castNotOption - (rightGet siblingNN))) - == Black)))) - then - (if sibling != None - then colorSet siblingNN Red; - colorSet successorParent Black; - break.contents <- true) - else - if - (sibling != None) && - ((colorGet (castNotOption sibling)) == - Black) - then - (let sibling = castNotOption sibling in - if - (((isLeft successor) && - (((rightGet sibling) == None) || - ((colorGet - (castNotOption - (rightGet sibling))) - == Black))) - && ((leftGet sibling) != None)) - && + (((not (isLeft successor)) && + (((leftGet sibling) == None) || ((colorGet (castNotOption (leftGet sibling))) - == Red) - then - (colorSet sibling Red; - colorSet - (castNotOption (leftGet sibling)) - Black; - rotateRight rbt sibling) - else - if - (((not (isLeft successor)) && - (((leftGet sibling) == None) || - ((colorGet - (castNotOption - (leftGet sibling))) - == Black))) - && ((rightGet sibling) != None)) - && - ((colorGet - (castNotOption - (rightGet sibling))) - == Red) - then - (colorSet sibling Red; - colorSet - (castNotOption (rightGet sibling)) - Black; - rotateLeft rbt sibling); - break.contents <- true) - else - (let sibling = siblingOf successor in - let sibling = castNotOption sibling in - colorSet sibling - (colorGet successorParent); - if isLeft successor - then - (colorSet - (castNotOption (rightGet sibling)) - Black; - rotateRight rbt successorParent) - else - (colorSet - (castNotOption (leftGet sibling)) - Black; - rotateLeft rbt successorParent)))) - done)); - if Js.Internal.fn_run1 isLeaf successor - then - (if (rootGet rbt) == (Some successor) then rootSet rbt None; - (match parentGet successor with - | None -> () - | Some parent -> - leftOrRightSet parent ~node:((successor) - [@res.namedArgLoc ]) None))) - [@res.braces ])) - let remove = - Function$ - (fun [arity:2]rbt -> - fun value -> - match _findNode rbt (rootGet rbt) value with - | Some node -> - (removeNode rbt node; - sizeSet rbt ((sizeGet rbt) - 1); - Some (heightGet node)) - | None -> None) - let findThroughCallback = - Function$ - (fun [arity:2]rbt -> - fun cb -> - ((let rec findThroughCallback = - Function$ - (fun [arity:3]rbt -> - fun node -> - fun cb -> - match node with - | None -> None - | Some node -> - let cmp = - Js.Internal.fn_run1 cb (valueGet node) in - if cmp == 0 - then Some node - else - if cmp < 0 - then - findThroughCallback rbt (leftGet node) cb - else - findThroughCallback rbt (rightGet node) cb) in - match findThroughCallback rbt (rootGet rbt) cb with - | None -> None - | Some node -> Some (valueGet node)) - [@res.braces ])) - let make = - Function$ - (fun [arity:1]~compare:((compare)[@res.namedArgLoc ]) -> - t ~size:((0)[@res.namedArgLoc ]) ~root:((None)[@res.namedArgLoc ]) - ~compare:((compare)[@res.namedArgLoc ])) - let rec heightOfInterval = - Function$ - (fun [arity:4]rbt -> - fun node -> - fun lhs -> - fun rhs -> - match node with - | None -> 0. - | Some n -> - if (lhs == None) && (rhs == None) - then sumGet n - else - if - (lhs != None) && - ((Js.Internal.fn_run2 (compareGet rbt) - (valueGet n) (castNotOption lhs)) - < 0) - then heightOfInterval rbt (rightGet n) lhs rhs - else - if - (rhs != None) && - ((Js.Internal.fn_run2 (compareGet rbt) - (valueGet n) (castNotOption rhs)) - > 0) - then heightOfInterval rbt (leftGet n) lhs rhs - else - ((heightGet n) +. - (heightOfInterval rbt (leftGet n) lhs None)) - +. (heightOfInterval rbt (rightGet n) None rhs)) - let heightOfInterval = - Function$ - (fun [arity:3]rbt -> - fun lhs -> fun rhs -> heightOfInterval rbt (rootGet rbt) lhs rhs) - let rec firstVisibleNode = - Function$ - (fun [arity:2]node -> - fun offset -> - match node with - | None -> None - | Some node -> - if (sumGet node) <= offset - then None - else - (let nodeHeight = heightGet node in - let sumLeft = - match leftGet node with - | None -> 0.0 - | Some left -> sumGet left in - if sumLeft > offset - then firstVisibleNode (leftGet node) offset - else - if (sumLeft +. nodeHeight) > offset - then Some node - else - firstVisibleNode (rightGet node) - (offset -. (sumLeft +. nodeHeight)))) - let lastVisibleNode = - Function$ - (fun [arity:2]node -> - fun offset -> - match firstVisibleNode node offset with - | None -> maxNode node - | first -> first) - let firstVisible = - Function$ - (fun [arity:2]rbt -> - fun ~offset:((offset)[@res.namedArgLoc ]) -> - match firstVisibleNode (rootGet rbt) offset with + == Black))) + && ((rightGet sibling) != None)) + && + ((colorGet + (castNotOption (rightGet sibling))) + == Red) + then + (colorSet sibling Red; + colorSet (castNotOption (rightGet sibling)) + Black; + rotateLeft rbt sibling); + break.contents <- true) + else + (let sibling = siblingOf successor in + let sibling = castNotOption sibling in + colorSet sibling (colorGet successorParent); + if isLeft successor + then + (colorSet (castNotOption (rightGet sibling)) + Black; + rotateRight rbt successorParent) + else + (colorSet (castNotOption (leftGet sibling)) + Black; + rotateLeft rbt successorParent)))) + done)); + if Js.Internal.fn_run1 isLeaf successor + then + (if (rootGet rbt) == (Some successor) then rootSet rbt None; + (match parentGet successor with + | None -> () + | Some parent -> + leftOrRightSet parent ~node:((successor)[@res.namedArgLoc ]) + None))) + [@res.braces ]) + let remove [arity:2]rbt value = + match _findNode rbt (rootGet rbt) value with + | Some node -> + (removeNode rbt node; + sizeSet rbt ((sizeGet rbt) - 1); + Some (heightGet node)) + | None -> None + let findThroughCallback [arity:2]rbt cb = + ((let rec findThroughCallback [arity:3]rbt node cb = + match node with + | None -> None + | Some node -> + let cmp = Js.Internal.fn_run1 cb (valueGet node) in + if cmp == 0 + then Some node + else + if cmp < 0 + then findThroughCallback rbt (leftGet node) cb + else findThroughCallback rbt (rightGet node) cb in + match findThroughCallback rbt (rootGet rbt) cb with + | None -> None + | Some node -> Some (valueGet node)) + [@res.braces ]) + let make [arity:1]~compare:((compare)[@res.namedArgLoc ]) = + t ~size:((0)[@res.namedArgLoc ]) ~root:((None)[@res.namedArgLoc ]) + ~compare:((compare)[@res.namedArgLoc ]) + let rec heightOfInterval [arity:4]rbt node lhs rhs = + match node with + | None -> 0. + | Some n -> + if (lhs == None) && (rhs == None) + then sumGet n + else + if + (lhs != None) && + ((Js.Internal.fn_run2 (compareGet rbt) (valueGet n) + (castNotOption lhs)) + < 0) + then heightOfInterval rbt (rightGet n) lhs rhs + else + if + (rhs != None) && + ((Js.Internal.fn_run2 (compareGet rbt) (valueGet n) + (castNotOption rhs)) + > 0) + then heightOfInterval rbt (leftGet n) lhs rhs + else + ((heightGet n) +. (heightOfInterval rbt (leftGet n) lhs None)) + +. (heightOfInterval rbt (rightGet n) None rhs) + let heightOfInterval [arity:3]rbt lhs rhs = + heightOfInterval rbt (rootGet rbt) lhs rhs + let rec firstVisibleNode [arity:2]node offset = + match node with + | None -> None + | Some node -> + if (sumGet node) <= offset + then None + else + (let nodeHeight = heightGet node in + let sumLeft = + match leftGet node with + | None -> 0.0 + | Some left -> sumGet left in + if sumLeft > offset + then firstVisibleNode (leftGet node) offset + else + if (sumLeft +. nodeHeight) > offset + then Some node + else + firstVisibleNode (rightGet node) + (offset -. (sumLeft +. nodeHeight))) + let lastVisibleNode [arity:2]node offset = + match firstVisibleNode node offset with + | None -> maxNode node + | first -> first + let firstVisible [arity:2]rbt ~offset:((offset)[@res.namedArgLoc ]) = + match firstVisibleNode (rootGet rbt) offset with + | None -> None + | Some node -> Some (valueGet node) + let rec leftmost [arity:1]node = + match leftGet node with | None -> node | Some node -> leftmost node + let rec firstRightParent [arity:1]node = + match parentGet node with + | None -> None + | Some parent -> + if isLeft node then Some parent else firstRightParent parent + let nextNode [arity:1]node = + match rightGet node with + | None -> firstRightParent node + | Some right -> Some (leftmost right) + let rec sumLeftSpine [arity:2]node + ~fromRightChild:((fromRightChild)[@res.namedArgLoc ]) = + ((let leftSpine = + match leftGet node with + | None -> heightGet node + | Some left -> + if fromRightChild + then (heightGet node) +. (sumGet left) + else 0.0 in + match parentGet node with + | None -> leftSpine + | Some parent -> + leftSpine +. + (sumLeftSpine parent + ~fromRightChild:(((rightGet parent) == (Some node)) + [@res.namedArgLoc ]))) + [@res.braces ]) + let getY [arity:1]node = + (sumLeftSpine node ~fromRightChild:((true)[@res.namedArgLoc ])) -. + (heightGet node) + let linearSearch [arity:2]rbt callback = + ((let rec find [arity:2]node callback = + if Js.Internal.fn_run1 callback (valueGet node) + then Some (valueGet node) + else + (match nextNode node with | None -> None - | Some node -> Some (valueGet node)) - let rec leftmost = - Function$ - (fun [arity:1]node -> - match leftGet node with - | None -> node - | Some node -> leftmost node) - let rec firstRightParent = - Function$ - (fun [arity:1]node -> - match parentGet node with - | None -> None - | Some parent -> - if isLeft node then Some parent else firstRightParent parent) - let nextNode = - Function$ - (fun [arity:1]node -> - match rightGet node with - | None -> firstRightParent node - | Some right -> Some (leftmost right)) - let rec sumLeftSpine = - Function$ - (fun [arity:2]node -> - fun ~fromRightChild:((fromRightChild)[@res.namedArgLoc ]) -> - ((let leftSpine = - match leftGet node with - | None -> heightGet node - | Some left -> - if fromRightChild - then (heightGet node) +. (sumGet left) - else 0.0 in - match parentGet node with - | None -> leftSpine - | Some parent -> - leftSpine +. - (sumLeftSpine parent - ~fromRightChild:(((rightGet parent) == (Some node)) - [@res.namedArgLoc ]))) - [@res.braces ])) - let getY = - Function$ - (fun [arity:1]node -> - (sumLeftSpine node ~fromRightChild:((true)[@res.namedArgLoc ])) -. - (heightGet node)) - let linearSearch = - Function$ - (fun [arity:2]rbt -> - fun callback -> - ((let rec find = - Function$ - (fun [arity:2]node -> - fun callback -> - if Js.Internal.fn_run1 callback (valueGet node) - then Some (valueGet node) - else - (match nextNode node with - | None -> None - | Some node -> find node callback)) in - match minNode (rootGet rbt) with - | None -> None - | Some node -> find node callback) - [@res.braces ])) - let rec iterate = - Function$ - (fun [arity:4]~inclusive:((inclusive)[@res.namedArgLoc ]) -> - fun firstNode -> - fun lastNode -> - fun ~callback:((callback)[@res.namedArgLoc ]) -> - match firstNode with - | None -> () - | Some node -> - (if inclusive then Js.Internal.fn_run1 callback node; - if firstNode != lastNode - then - (if not inclusive - then Js.Internal.fn_run1 callback node; - iterate ~inclusive:((inclusive)[@res.namedArgLoc ]) - (nextNode node) lastNode ~callback:((callback) - [@res.namedArgLoc ])))) - let rec iterateWithY = - Function$ - (fun [arity:5]?y:((y)[@res.namedArgLoc ]) -> - fun ~inclusive:((inclusive)[@res.namedArgLoc ]) -> - fun firstNode -> - fun lastNode -> - fun ~callback:((callback)[@res.namedArgLoc ]) -> - match firstNode with - | None -> () - | Some node -> - let y = match y with | None -> getY node | Some y -> y in - (if inclusive then Js.Internal.fn_run2 callback node y; - if firstNode != lastNode - then - (if not inclusive - then Js.Internal.fn_run2 callback node y; - iterateWithY ~y:((y +. (heightGet node)) - [@res.namedArgLoc ]) ~inclusive:((inclusive) - [@res.namedArgLoc ]) (nextNode node) lastNode - ~callback:((callback)[@res.namedArgLoc ])))) - let rec updateSum = - Function$ - (fun [arity:2]node -> - fun ~delta:((delta)[@res.namedArgLoc ]) -> - match node with - | None -> () - | Some node -> - (sumSet node ((sumGet node) +. delta); - updateSum (parentGet node) ~delta:((delta) - [@res.namedArgLoc ]))) - let setHeight = - Function$ - (fun [arity:3]rbt -> - fun value -> - fun ~height:((height)[@res.namedArgLoc ]) -> - match _findNode rbt (rootGet rbt) value with - | None -> () - | Some node -> - let delta = height -. (heightGet node) in - (heightSet node height; - updateSum (Some node) ~delta:((delta)[@res.namedArgLoc ]))) + | Some node -> find node callback) in + match minNode (rootGet rbt) with + | None -> None + | Some node -> find node callback) + [@res.braces ]) + let rec iterate [arity:4]~inclusive:((inclusive)[@res.namedArgLoc ]) + firstNode lastNode ~callback:((callback)[@res.namedArgLoc ]) = + match firstNode with + | None -> () + | Some node -> + (if inclusive then Js.Internal.fn_run1 callback node; + if firstNode != lastNode + then + (if not inclusive then Js.Internal.fn_run1 callback node; + iterate ~inclusive:((inclusive)[@res.namedArgLoc ]) + (nextNode node) lastNode ~callback:((callback) + [@res.namedArgLoc ]))) + let rec iterateWithY [arity:5]?y:((y)[@res.namedArgLoc ]) + ~inclusive:((inclusive)[@res.namedArgLoc ]) firstNode lastNode + ~callback:((callback)[@res.namedArgLoc ]) = + match firstNode with + | None -> () + | Some node -> + let y = match y with | None -> getY node | Some y -> y in + (if inclusive then Js.Internal.fn_run2 callback node y; + if firstNode != lastNode + then + (if not inclusive then Js.Internal.fn_run2 callback node y; + iterateWithY ~y:((y +. (heightGet node))[@res.namedArgLoc ]) + ~inclusive:((inclusive)[@res.namedArgLoc ]) (nextNode node) + lastNode ~callback:((callback)[@res.namedArgLoc ]))) + let rec updateSum [arity:2]node ~delta:((delta)[@res.namedArgLoc ]) = + match node with + | None -> () + | Some node -> + (sumSet node ((sumGet node) +. delta); + updateSum (parentGet node) ~delta:((delta)[@res.namedArgLoc ])) + let setHeight [arity:3]rbt value ~height:((height)[@res.namedArgLoc ]) = + match _findNode rbt (rootGet rbt) value with + | None -> () + | Some node -> + let delta = height -. (heightGet node) in + (heightSet node height; + updateSum (Some node) ~delta:((delta)[@res.namedArgLoc ])) type nonrec 'value oldNewVisibleNodes = { mutable old: 'value array ; diff --git a/tests/syntax_tests/data/parsing/infiniteLoops/expected/templateEof.res.txt b/tests/syntax_tests/data/parsing/infiniteLoops/expected/templateEof.res.txt index e32f3b1321..6b73b0fbde 100644 --- a/tests/syntax_tests/data/parsing/infiniteLoops/expected/templateEof.res.txt +++ b/tests/syntax_tests/data/parsing/infiniteLoops/expected/templateEof.res.txt @@ -20,6 +20,5 @@ ;;et ;;foo = - (Function$ - (fun [arity:1]x -> - match x with | (("")[@res.template ]) -> [%rescript.exprhole ])) \ No newline at end of file + (fun [arity:1]x -> + match x with | (("")[@res.template ]) -> [%rescript.exprhole ]) \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/recovery/expression/expected/emptyBlock.res.txt b/tests/syntax_tests/data/parsing/recovery/expression/expected/emptyBlock.res.txt index fca8935cc9..6316a44ebd 100644 --- a/tests/syntax_tests/data/parsing/recovery/expression/expected/emptyBlock.res.txt +++ b/tests/syntax_tests/data/parsing/recovery/expression/expected/emptyBlock.res.txt @@ -1,2 +1,2 @@ let x = { } -let f = Function$ (fun [arity:2]a -> fun b -> { }) \ No newline at end of file +let f [arity:2]a b = { } \ No newline at end of file diff --git a/tests/syntax_tests/data/parsing/recovery/expression/expected/list.res.txt b/tests/syntax_tests/data/parsing/recovery/expression/expected/list.res.txt index 3be57506a5..993c5a78a3 100644 --- a/tests/syntax_tests/data/parsing/recovery/expression/expected/list.res.txt +++ b/tests/syntax_tests/data/parsing/recovery/expression/expected/list.res.txt @@ -30,16 +30,13 @@ let flags = ((if reasonFormat then ((let parts = Utils.split_on_char ' ' flags in - let rec loop = - Function$ - (fun [arity:1]items -> - ((match items with - | [|{js|-pp|js};_ppFlag;rest|] -> loop rest - | [|x;rest|] -> - ((Belt.Array.concatMany)[@res.spread ]) - [|[|x|];(loop rest)|] - | [||] -> [||]) - [@res.braces ])) in + let rec loop [arity:1]items = + ((match items with + | [|{js|-pp|js};_ppFlag;rest|] -> loop rest + | [|x;rest|] -> + ((Belt.Array.concatMany)[@res.spread ]) [|[|x|];(loop rest)|] + | [||] -> [||]) + [@res.braces ]) in String.concat {js| |js} (loop parts)) [@res.braces ]) else flags) diff --git a/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt b/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt index 4e32edbfe0..75e141a375 100644 --- a/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt @@ -2,11 +2,11 @@ module V4C = { @res.jsxComponentProps - type props = {} + type props<'a, 'b> = {a: 'a, b: 'b} - let make = (type a, _: props) => (~a, ~b, _) => ReactDOM.createDOMElementVariadic("div", []) + let make = (type a, {a, b, _}: props<_, _>) => ReactDOM.createDOMElementVariadic("div", []) let make = { - let \"TypeConstraint$V4C" = props => make(props) + let \"TypeConstraint$V4C" = (props: props<_>) => make(props) \"TypeConstraint$V4C" } @@ -16,11 +16,11 @@ module V4C = { module V4A = { @res.jsxComponentProps - type props = {} + type props<'a, 'b> = {a: 'a, b: 'b} - let make = (type a, _: props) => (~a, ~b, _) => ReactDOM.jsx("div", {}) + let make = (type a, {a, b, _}: props<_, _>) => ReactDOM.jsx("div", {}) let make = { - let \"TypeConstraint$V4A" = props => make(props) + let \"TypeConstraint$V4A" = (props: props<_>) => make(props) \"TypeConstraint$V4A" } diff --git a/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt b/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt index 41435587ce..9141e4ff5b 100644 --- a/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt @@ -46,8 +46,8 @@ let _ = await !ref let _ = await f let _ = await %extension let _ = await "test" -let _ = await (a, b) => a + b -let _ = await async (a, b) => a + b +let _ = await ((a, b) => a + b) +let _ = await (async (a, b) => a + b) let _ = await ( switch x { | A => () diff --git a/tests/syntax_tests/data/printer/expr/expected/callback.res.txt b/tests/syntax_tests/data/printer/expr/expected/callback.res.txt index d38643f0d7..a2d661ce40 100644 --- a/tests/syntax_tests/data/printer/expr/expected/callback.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/callback.res.txt @@ -226,10 +226,10 @@ myPromise Js.log(value) Js.Promise.resolve(value + 3) }, _)) -->(Js.Promise.catch(err => { - Js.log2("Failure!!", err) - Js.Promise.resolve(-2) - }, _)) +->Js.Promise.catch(err => { + Js.log2("Failure!!", err) + Js.Promise.resolve(-2) +}, _) let decoratorTags = items diff --git a/tests/syntax_tests/data/printer/expr/expected/record.res.txt b/tests/syntax_tests/data/printer/expr/expected/record.res.txt index 97ddee1eee..fb16fe7113 100644 --- a/tests/syntax_tests/data/printer/expr/expected/record.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/record.res.txt @@ -101,5 +101,5 @@ let optParen = {x: 3, y: ?(someBool ? Some("") : None)} let optParen = {x: 3, y: ?(3 + 4)} let optParen = {x: 3, y: ?foo(bar)} let optParen = {x: 3, y: ?(foo->bar)} -let optParen = {x: 3, y: ?() => 3} +let optParen = {x: 3, y: ?(() => 3)} let optParen = {x: 3, y: ?-3} diff --git a/tests/syntax_tests/data/printer/expr/expected/underscoreApply.res.txt b/tests/syntax_tests/data/printer/expr/expected/underscoreApply.res.txt index a5ef46cc9e..dc50fb21da 100644 --- a/tests/syntax_tests/data/printer/expr/expected/underscoreApply.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/underscoreApply.res.txt @@ -10,9 +10,9 @@ let x = f(~a=_, ~b=_, ~c=g(~x=2, ~y=_, ~z=_)) let nested = x => List.length(_) let nested2 = (x, y, z) => List.length(_) -let l = (List.filter(i => i > 0, _))((List.map(i => i + 1, _))([1, 2, 3])) +let l = List.filter(i => i > 0, _)(List.map(i => i + 1, _)([1, 2, 3])) -let l = (List.map(_, [1, 2, 3]))(i => i + 1) +let l = List.map(_, [1, 2, 3])(i => i + 1) let x = List.length(_) @@ -33,10 +33,10 @@ f(a, b, (a, b) => List.length(_)) // callback in first position f((a, b) => List.length(_), a, b) -(f(a, b, _))(x, y) +f(a, b, _)(x, y) -f(a, b, _) -(f(a, b, _)) + (g(x, _, z)) -(f(a, b, _)) + (g(x, _, z)) + (h(alpha, beta, _)) +f(a, b, _) + g(x, _, z) +f(a, b, _) + (g(x, _, z)) + h(alpha, beta, _) assert(f(a, b, _)) @@ -44,7 +44,7 @@ getDirector(a, b, _).name f(a, b, _) ? g(x, y, _) : h(alpha, beta, _) -
+
{f(a, b, _)}
f(a, b, _)[ix] @@ -52,14 +52,14 @@ f(a, b, _)[ix] = 2 getDirector(a, b, _).name = "Steve" -(Array.get(_, 0))(filterNone) -filterNone->(Array.get(_, 0)) +Array.get(_, 0)(filterNone) +filterNone->Array.get(_, 0) Array.get(_, 0) -1 + (Array.get(_, 0)) -(Array.get(_, 1)) + (Array.get(_, 0)) +1 + Array.get(_, 0) +Array.get(_, 1) + Array.get(_, 0) let f = Array.get(_, 0) -let photo = (Array.get(_, 0))(filterNone(pricedRoom["room"]["photos"])) +let photo = Array.get(_, 0)(filterNone(pricedRoom["room"]["photos"])) underscoreWithComments(// Comment 1 x => { From ecc5dec10648c474e8e8feb6f3e41f5b8172ae51 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 08:08:51 +0100 Subject: [PATCH 03/17] Update printtyped.ml --- compiler/ml/printtyped.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 1451266b2b..51ec786875 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -285,8 +285,11 @@ and expression i ppf x = line i ppf "Texp_let %a\n" fmt_rec_flag rf; list i value_binding ppf l; expression i ppf e - | Texp_function {arg_label = p; param; case = case_; partial = _} -> + | Texp_function {arg_label = p; arity; param; case = case_; partial = _} -> line i ppf "Texp_function\n"; + (match arity with + | Some arity -> line i ppf "arity: %d\n" arity + | None -> ()); line i ppf "%a" Ident.print param; arg_label i ppf p; case i ppf case_ From 7a18bdf130dd80f4f7ad6bfcb7721db93f2ac1e2 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 08:42:27 +0100 Subject: [PATCH 04/17] Adjustments to lambda translation. --- compiler/ml/translcore.ml | 17 +++++++++++------ tests/tests/src/class_type_ffi_test.res | 5 +++-- tests/tests/src/more_poly_variant_test.res | 11 ++++++----- tests/tests/src/test_bs_this.res | 11 ++++++----- tests/tests/src/uncurried_default.args.mjs | 16 ++++++++-------- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 9460b1f681..ce51b425e2 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -699,11 +699,9 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = match arity with | Some arity -> let prim = - match - (Ast_uncurried.type_extract_uncurried_fun - (Ctype.expand_head e.exp_env e.exp_type)) - .desc - with + let expanded = Ctype.expand_head e.exp_env e.exp_type in + let extracted = Ast_uncurried.type_extract_uncurried_fun expanded in + match (Btype.repr extracted).desc with | Tarrow (Nolabel, t, _, _) -> ( match (Ctype.expand_head e.exp_env t).desc with | Tconstr (Pident {name = "unit"}, [], _) -> Pjs_fn_make_unit @@ -1052,7 +1050,14 @@ and transl_function loc partial param case = c_rhs = { exp_desc = - Texp_function {arg_label = _; param = param'; case; partial = partial'}; + Texp_function + { + arg_label = _; + arity = None; + param = param'; + case; + partial = partial'; + }; } as exp; } when Parmatch.inactive ~partial pat && not (exp |> has_async_attribute) -> diff --git a/tests/tests/src/class_type_ffi_test.res b/tests/tests/src/class_type_ffi_test.res index 211f385297..de7546c0c6 100644 --- a/tests/tests/src/class_type_ffi_test.res +++ b/tests/tests/src/class_type_ffi_test.res @@ -30,5 +30,6 @@ let off2 = (o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => o["huge_method"](a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) /* Test [fn_mk] */ -let mk_f = () => (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => - a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) +let mk_f = () => + (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => + a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) diff --git a/tests/tests/src/more_poly_variant_test.res b/tests/tests/src/more_poly_variant_test.res index b471c3bb82..b4f2f9ff4b 100644 --- a/tests/tests/src/more_poly_variant_test.res +++ b/tests/tests/src/more_poly_variant_test.res @@ -1,10 +1,11 @@ type rec vlist<'a> = [#Nil | #Cons('a, vlist<'a>)] -let rec map = (f): (vlist<'a> => vlist<'b>) => x => - switch x { - | #Nil => #Nil - | #Cons(a, l) => #Cons(f(a), map(f)(l)) - } +let rec map = (f): (vlist<'a> => vlist<'b>) => + x => + switch x { + | #Nil => #Nil + | #Cons(a, l) => #Cons(f(a), map(f)(l)) + } let split_cases = x => switch x { diff --git a/tests/tests/src/test_bs_this.res b/tests/tests/src/test_bs_this.res index 68358e6e03..af32b4deb9 100644 --- a/tests/tests/src/test_bs_this.res +++ b/tests/tests/src/test_bs_this.res @@ -2,11 +2,12 @@ let uux_this: @this ({"length": int}, int, int) => int = @this (o, x, y) => o["l let even = @this (o, x) => x + o -let bark = () => @this -(o: 'self, x, y) => { - Js.log((o["length"], o["x"], o["y"], x, y)) - x + y -} +let bark = () => + @this + (o: 'self, x, y) => { + Js.log((o["length"], o["x"], o["y"], x, y)) + x + y + } let js_obj: 'self = { "bark": @this diff --git a/tests/tests/src/uncurried_default.args.mjs b/tests/tests/src/uncurried_default.args.mjs index 2cabf6e06a..18f639c123 100644 --- a/tests/tests/src/uncurried_default.args.mjs +++ b/tests/tests/src/uncurried_default.args.mjs @@ -1,10 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -function withOpt(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 1; - return (zOpt, w) => { - let z = zOpt !== undefined ? zOpt : 1; +function withOpt($staropt$star, y) { + return ($staropt$star$1, w) => { + let x = $staropt$star !== undefined ? $staropt$star : 1; + let z = $staropt$star$1 !== undefined ? $staropt$star$1 : 1; return ((x + y | 0) + z | 0) + w | 0; }; } @@ -53,10 +53,10 @@ let StandardNotation = { r3: r3 }; -function withOpt$1(xOpt, y) { - let x = xOpt !== undefined ? xOpt : 1; - return (zOpt, w) => { - let z = zOpt !== undefined ? zOpt : 1; +function withOpt$1($staropt$star, y) { + return ($staropt$star$1, w) => { + let x = $staropt$star !== undefined ? $staropt$star : 1; + let z = $staropt$star$1 !== undefined ? $staropt$star$1 : 1; return ((x + y | 0) + z | 0) + w | 0; }; } From 56a2a18132237b8e28e03df107bfbeb9d15ffd5c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 08:53:21 +0100 Subject: [PATCH 05/17] remove infinte loop in builtin ppx --- compiler/frontend/bs_builtin_ppx.ml | 12 ------------ tests/tests/src/UncurriedExternals.mjs | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/compiler/frontend/bs_builtin_ppx.ml b/compiler/frontend/bs_builtin_ppx.ml index a770992366..ed3171cc24 100644 --- a/compiler/frontend/bs_builtin_ppx.ml +++ b/compiler/frontend/bs_builtin_ppx.ml @@ -110,18 +110,6 @@ let expr_mapper ~async_context ~in_function_def (self : mapper) | Pexp_constant (Pconst_integer (s, Some 'l')) -> {e with pexp_desc = Pexp_constant (Pconst_integer (s, None))} (* End rewriting *) - | _ - when Ast_uncurried.expr_is_uncurried_fun e - && - match - Ast_attributes.process_attributes_rev - (Ast_uncurried.expr_extract_uncurried_fun e).pexp_attributes - with - | Meth_callback _, _ -> true - | _ -> false -> - (* Treat @this (. x, y, z) => ... just like @this (x, y, z) => ... *) - let fun_expr = Ast_uncurried.expr_extract_uncurried_fun e in - self.expr self fun_expr | Pexp_newtype (s, body) -> let async = Ast_attributes.has_async_payload e.pexp_attributes <> None in let body = Ast_async.add_async_attribute ~async body in diff --git a/tests/tests/src/UncurriedExternals.mjs b/tests/tests/src/UncurriedExternals.mjs index a50b793b71..7cd7ec36d5 100644 --- a/tests/tests/src/UncurriedExternals.mjs +++ b/tests/tests/src/UncurriedExternals.mjs @@ -64,9 +64,9 @@ let StandardNotation = { set: StandardNotation_set }; -function methodWithAsync() { +function methodWithAsync(param) { let $$this = this ; - return async arg => $$this + arg | 0; + return (async arg => $$this + arg | 0)(param); } export { From a8250da8623e5dea81d6b6e265cae7438be98b4c Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 13:41:31 +0100 Subject: [PATCH 06/17] Fix derive projector arity. --- compiler/frontend/ast_derive_projector.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/frontend/ast_derive_projector.ml b/compiler/frontend/ast_derive_projector.ml index 2fab2e2a3b..4506f52ca9 100644 --- a/compiler/frontend/ast_derive_projector.ml +++ b/compiler/frontend/ast_derive_projector.ml @@ -108,7 +108,7 @@ let init () = annotate_type in Ext_list.fold_right vars exp (fun var b -> - Ast_compatible.fun_ ~arity:(Some 1) + Ast_compatible.fun_ ~arity:None (Pat.var {loc; txt = var}) b) |> handle_uncurried_accessor_tranform ~arity)) From 48eb846a719aa202eb616733068847652421c77b Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 13:46:15 +0100 Subject: [PATCH 07/17] Update TestPpx.res.jsout --- tests/tools_tests/src/expected/TestPpx.res.jsout | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tools_tests/src/expected/TestPpx.res.jsout b/tests/tools_tests/src/expected/TestPpx.res.jsout index f1abca17ba..37e7eac983 100644 --- a/tests/tools_tests/src/expected/TestPpx.res.jsout +++ b/tests/tools_tests/src/expected/TestPpx.res.jsout @@ -24,12 +24,10 @@ function two(x, y) { return x + y | 0; } -let n = 6; - let Arity = { one: one, two: two, - n: n + n: 6 }; let a = "A"; From 44bb8a98e9fc4d6b0ef1fdc3745f9699cef4b86f Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 14:22:19 +0100 Subject: [PATCH 08/17] analysis --- analysis/src/Hint.ml | 10 +++------- compiler/gentype/TranslateStructure.ml | 3 --- .../src/expected/GenericJsxCompletion.res.txt | 2 -- .../tests/src/expected/Completion.res.txt | 8 -------- .../expected/CompletionFunctionArguments.res.txt | 2 -- .../src/expected/CompletionInferValues.res.txt | 13 ------------- .../tests/src/expected/CompletionJsx.res.txt | 8 -------- .../tests/src/expected/CompletionPattern.res.txt | 1 - .../tests/src/expected/CompletionPipeChain.res.txt | 2 -- .../tests/src/expected/Destructuring.res.txt | 2 -- .../tests/src/expected/DocumentSymbol.res.txt | 12 ++++++------ .../tests/src/expected/RecoveryOnProp.res.txt | 1 - .../analysis_tests/tests/src/expected/Xform.res.txt | 1 - 13 files changed, 9 insertions(+), 56 deletions(-) diff --git a/analysis/src/Hint.ml b/analysis/src/Hint.ml index b922dae2b5..8ecd71e6b3 100644 --- a/analysis/src/Hint.ml +++ b/analysis/src/Hint.ml @@ -60,7 +60,8 @@ let inlay ~path ~pos ~maxLength ~debug = ( Pexp_constant _ | Pexp_tuple _ | Pexp_record _ | Pexp_variant _ | Pexp_apply _ | Pexp_match _ | Pexp_construct _ | Pexp_ifthenelse _ | Pexp_array _ | Pexp_ident _ | Pexp_try _ | Pexp_lazy _ - | Pexp_send _ | Pexp_field _ | Pexp_open _ ); + | Pexp_send _ | Pexp_field _ | Pexp_open _ + | Pexp_fun (_, _, _, _, Some _) ); }; } -> push vb.pvb_pat.ppat_loc Type @@ -125,12 +126,7 @@ let codeLens ~path ~debug = (match vb with | { pvb_pat = {ppat_desc = Ppat_var _; ppat_loc}; - pvb_expr = - { - pexp_desc = - Pexp_construct - ({txt = Lident "Function$"}, Some {pexp_desc = Pexp_fun _}); - }; + pvb_expr = {pexp_desc = Pexp_fun _}; } -> push ppat_loc | _ -> ()); diff --git a/compiler/gentype/TranslateStructure.ml b/compiler/gentype/TranslateStructure.ml index 8cab0461b4..982ea9de3d 100644 --- a/compiler/gentype/TranslateStructure.ml +++ b/compiler/gentype/TranslateStructure.ml @@ -18,9 +18,6 @@ let rec addAnnotationsToTypes_ ~config ~(expr : Typedtree.expression) else a_name in {a_name; a_type} :: next_types1 - | Texp_construct ({txt = Lident "Function$"}, _, [fun_expr]), _, _ -> - (* let uncurried1: function$<_, _> = Function$(x => x |> string_of_int, [`Has_arity1]) *) - addAnnotationsToTypes_ ~config ~expr:fun_expr arg_types | Texp_apply ({exp_desc = Texp_ident (path, _, _)}, [(_, Some expr1)]), _, _ -> ( match path |> TranslateTypeExprFromTypes.path_to_list |> List.rev with diff --git a/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt b/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt index f2cbf254f5..fccb2c9247 100644 --- a/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt +++ b/tests/analysis_tests/tests-generic-jsx-transform/src/expected/GenericJsxCompletion.res.txt @@ -47,7 +47,6 @@ Path GenericJsx.Elements.props Complete src/GenericJsxCompletion.res 14:21 posCursor:[14:21] posNoWhite:[14:20] Found expr:[8:13->23:3] -posCursor:[14:21] posNoWhite:[14:20] Found expr:[8:14->23:3] posCursor:[14:21] posNoWhite:[14:20] Found expr:[9:4->22:10] posCursor:[14:21] posNoWhite:[14:20] Found expr:[10:4->22:10] posCursor:[14:21] posNoWhite:[14:20] Found expr:[11:4->22:10] @@ -86,7 +85,6 @@ Path Js.String2.st Complete src/GenericJsxCompletion.res 20:24 posCursor:[20:24] posNoWhite:[20:23] Found expr:[8:13->23:3] -posCursor:[20:24] posNoWhite:[20:23] Found expr:[8:14->23:3] posCursor:[20:24] posNoWhite:[20:23] Found expr:[9:4->22:10] posCursor:[20:24] posNoWhite:[20:23] Found expr:[10:4->22:10] posCursor:[20:24] posNoWhite:[20:23] Found expr:[11:4->22:10] diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index da4248ef4d..574174fd8b 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -995,7 +995,6 @@ Path Objects.Rec.recordVal Complete src/Completion.res 120:7 posCursor:[120:7] posNoWhite:[120:6] Found expr:[119:11->123:1] -posCursor:[120:7] posNoWhite:[120:6] Found expr:[119:11->123:1] posCursor:[120:7] posNoWhite:[120:6] Found expr:[120:5->122:5] posCursor:[120:7] posNoWhite:[120:6] Found expr:[120:5->120:7] Pexp_ident my:[120:5->120:7] @@ -1511,7 +1510,6 @@ Path SomeLocal Complete src/Completion.res 275:15 posCursor:[275:15] posNoWhite:[275:14] Found expr:[274:11->278:1] -posCursor:[275:15] posNoWhite:[275:14] Found expr:[274:11->278:1] posCursor:[275:15] posNoWhite:[275:14] Found expr:[275:5->277:3] posCursor:[275:15] posNoWhite:[275:14] Found expr:[275:13->275:15] Pexp_ident _w:[275:13->275:15] @@ -1851,7 +1849,6 @@ posCursor:[339:26] posNoWhite:[339:25] Found expr:[336:3->349:23] JSX 336:6] onClick[337:4->337:11]=...[337:13->349:23]> _children:None posCursor:[339:26] posNoWhite:[339:25] Found expr:[337:13->349:23] posCursor:[339:26] posNoWhite:[339:25] Found expr:[337:13->341:6] -posCursor:[339:26] posNoWhite:[339:25] Found expr:[337:13->341:6] posCursor:[339:26] posNoWhite:[339:25] Found expr:[338:6->341:5] posCursor:[339:26] posNoWhite:[339:25] Found expr:[339:16->341:5] posCursor:[339:26] posNoWhite:[339:25] Found pattern:[339:20->341:5] @@ -1983,7 +1980,6 @@ posCursor:[358:23] posNoWhite:[358:22] Found expr:[358:12->358:23] Complete src/Completion.res 365:8 posCursor:[365:8] posNoWhite:[365:7] Found expr:[363:8->368:3] -posCursor:[365:8] posNoWhite:[365:7] Found expr:[363:8->368:3] posCursor:[365:8] posNoWhite:[365:7] Found pattern:[365:7->367:5] posCursor:[365:8] posNoWhite:[365:7] Found pattern:[365:7->365:8] Ppat_construct T:[365:7->365:8] @@ -2065,7 +2061,6 @@ Path T Complete src/Completion.res 376:21 posCursor:[376:21] posNoWhite:[376:20] Found expr:[374:8->379:3] -posCursor:[376:21] posNoWhite:[376:20] Found expr:[374:8->379:3] posCursor:[376:21] posNoWhite:[376:20] Found pattern:[376:7->378:5] posCursor:[376:21] posNoWhite:[376:20] Found pattern:[376:7->376:21] Ppat_construct AndThatOther.T:[376:7->376:21] @@ -2168,7 +2163,6 @@ Path funRecord Complete src/Completion.res 392:12 posCursor:[392:12] posNoWhite:[392:11] Found expr:[390:8->395:1] -posCursor:[392:12] posNoWhite:[392:11] Found expr:[390:8->395:1] posCursor:[392:12] posNoWhite:[392:11] Found expr:[391:2->394:4] posCursor:[392:12] posNoWhite:[392:11] Found expr:[392:6->394:4] posCursor:[392:12] posNoWhite:[392:11] Found expr:[392:6->392:12] @@ -2272,7 +2266,6 @@ Path r Complete src/Completion.res 412:21 posCursor:[412:21] posNoWhite:[412:20] Found expr:[411:14->418:1] -posCursor:[412:21] posNoWhite:[412:20] Found expr:[411:14->418:1] posCursor:[412:21] posNoWhite:[412:20] Found expr:[412:5->417:17] posCursor:[412:21] posNoWhite:[412:20] Found expr:[412:5->414:42] posCursor:[412:21] posNoWhite:[412:20] Found expr:[412:5->414:5] @@ -2299,7 +2292,6 @@ Path SomeLocalModule. Complete src/Completion.res 415:21 posCursor:[415:21] posNoWhite:[415:20] Found expr:[411:14->418:1] -posCursor:[415:21] posNoWhite:[415:20] Found expr:[411:14->418:1] posCursor:[415:21] posNoWhite:[415:20] Found expr:[414:2->417:17] posCursor:[415:21] posNoWhite:[415:20] Found expr:[415:5->417:17] Pexp_apply ...[415:5->417:8] (...[417:9->417:16]) diff --git a/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt b/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt index 92e0ecdb04..986bf2eada 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt @@ -425,7 +425,6 @@ Complete src/CompletionFunctionArguments.res 109:29 posCursor:[109:29] posNoWhite:[109:28] Found expr:[105:3->114:4] JSX 105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2 posCursor:[109:29] posNoWhite:[109:28] Found expr:[106:35->113:5] -posCursor:[109:29] posNoWhite:[109:28] Found expr:[106:16->113:5] posCursor:[109:29] posNoWhite:[109:28] Found expr:[107:6->109:29] posCursor:[109:29] posNoWhite:[109:28] Found expr:[108:6->109:29] posCursor:[109:29] posNoWhite:[109:28] Found expr:[109:9->109:29] @@ -450,7 +449,6 @@ Complete src/CompletionFunctionArguments.res 111:27 posCursor:[111:27] posNoWhite:[111:26] Found expr:[105:3->114:4] JSX 105:6] onMouseDown[106:4->106:15]=...[106:35->113:5]> _children:114:2 posCursor:[111:27] posNoWhite:[111:26] Found expr:[106:35->113:5] -posCursor:[111:27] posNoWhite:[111:26] Found expr:[106:16->113:5] posCursor:[111:27] posNoWhite:[111:26] Found expr:[107:6->111:27] posCursor:[111:27] posNoWhite:[111:26] Found expr:[108:6->111:27] posCursor:[111:27] posNoWhite:[111:26] Found expr:[111:9->111:27] diff --git a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt index ee5375d92f..eea7ad9297 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionInferValues.res.txt @@ -80,7 +80,6 @@ Complete src/CompletionInferValues.res 24:63 posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:3->24:64] Pexp_apply ...[24:3->24:21] (...[24:22->24:63]) posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:22->24:63] -posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:23->24:63] posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:36->24:63] posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:42->24:63] posCursor:[24:63] posNoWhite:[24:62] Found expr:[24:52->24:63] @@ -112,7 +111,6 @@ Complete src/CompletionInferValues.res 27:90 posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:39->27:91] Pexp_apply ...[27:39->27:48] (...[27:49->27:90]) posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:49->27:90] -posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:50->27:90] posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:56->27:90] posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:69->27:90] posCursor:[27:90] posNoWhite:[27:89] Found expr:[27:79->27:90] @@ -146,7 +144,6 @@ Complete src/CompletionInferValues.res 30:36 posCursor:[30:36] posNoWhite:[30:35] Found expr:[30:3->30:39] Pexp_apply ...[30:3->30:15] (...[30:16->30:38]) posCursor:[30:36] posNoWhite:[30:35] Found expr:[30:16->30:38] -posCursor:[30:36] posNoWhite:[30:35] Found expr:[30:16->30:38] posCursor:[30:36] posNoWhite:[30:35] Found expr:[30:27->30:36] Completable: Cpath Value[event]->pr Package opens Pervasives.JsxModules.place holder @@ -173,7 +170,6 @@ Complete src/CompletionInferValues.res 41:50 posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:12->41:56] JSX 41:15] onMouseEnter[41:16->41:28]=...[41:36->41:52]> _children:41:54 posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:36->41:52] -posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:29->41:52] posCursor:[41:50] posNoWhite:[41:49] Found expr:[41:41->41:50] Completable: Cpath Value[event]->pr <> Package opens Pervasives.JsxModules.place holder @@ -200,7 +196,6 @@ Complete src/CompletionInferValues.res 44:50 posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:12->44:56] JSX 44:15] onMouseEnter[44:16->44:28]=...[44:36->44:52]> _children:44:54 posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:36->44:52] -posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:29->44:52] posCursor:[44:50] posNoWhite:[44:49] Found expr:[44:41->44:50] Completable: Cpath Value[event]->pr <> Package opens Pervasives.JsxModules.place holder @@ -226,7 +221,6 @@ Complete src/CompletionInferValues.res 47:87 posCursor:[47:87] posNoWhite:[47:86] Found expr:[47:12->47:93] JSX 47:15] onMouseEnter[47:16->47:28]=...[47:36->47:89]> _children:47:91 posCursor:[47:87] posNoWhite:[47:86] Found expr:[47:36->47:89] -posCursor:[47:87] posNoWhite:[47:86] Found expr:[47:29->47:89] posCursor:[47:87] posNoWhite:[47:86] Found expr:[47:41->47:87] posCursor:[47:87] posNoWhite:[47:86] Found expr:[47:81->47:87] Completable: Cpath Value[btn]->t <> @@ -257,7 +251,6 @@ Complete src/CompletionInferValues.res 50:108 posCursor:[50:108] posNoWhite:[50:107] Found expr:[50:12->50:114] JSX 50:15] onMouseEnter[50:16->50:28]=...[50:36->50:110]> _children:50:112 posCursor:[50:108] posNoWhite:[50:107] Found expr:[50:36->50:110] -posCursor:[50:108] posNoWhite:[50:107] Found expr:[50:29->50:110] posCursor:[50:108] posNoWhite:[50:107] Found expr:[50:41->50:108] posCursor:[50:108] posNoWhite:[50:107] Found expr:[50:100->50:108] Completable: Cpath Value[btn]->spl <> @@ -300,7 +293,6 @@ Complete src/CompletionInferValues.res 53:130 posCursor:[53:130] posNoWhite:[53:129] Found expr:[53:12->53:136] JSX 53:15] onMouseEnter[53:16->53:28]=...[53:36->53:132]> _children:53:134 posCursor:[53:130] posNoWhite:[53:129] Found expr:[53:36->53:132] -posCursor:[53:130] posNoWhite:[53:129] Found expr:[53:29->53:132] posCursor:[53:130] posNoWhite:[53:129] Found expr:[53:41->53:130] posCursor:[53:130] posNoWhite:[53:129] Found expr:[53:123->53:130] Completable: Cpath Value[btn]->ma <> @@ -663,7 +655,6 @@ Complete src/CompletionInferValues.res 130:26 posCursor:[130:26] posNoWhite:[130:25] Found expr:[130:3->130:37] Pexp_apply ...[130:3->130:23] (...[130:24->130:36]) posCursor:[130:26] posNoWhite:[130:25] Found expr:[130:24->130:36] -posCursor:[130:26] posNoWhite:[130:25] Found expr:[130:25->130:36] posCursor:[130:26] posNoWhite:[130:25] Found pattern:[130:25->130:27] posCursor:[130:26] posNoWhite:[130:25] Found pattern:[130:25->130:27] Completable: Cpattern CArgument CArgument Value[fnWithRecordCallback]($0)($0)->recordBody @@ -690,7 +681,6 @@ Complete src/CompletionInferValues.res 137:30 posCursor:[137:30] posNoWhite:[137:29] Found expr:[137:3->137:33] Pexp_apply ...[137:3->137:6] (~cb137:8->137:10=...[137:11->137:32]) posCursor:[137:30] posNoWhite:[137:29] Found expr:[137:11->137:32] -posCursor:[137:30] posNoWhite:[137:29] Found expr:[137:12->137:32] posCursor:[137:30] posNoWhite:[137:29] Found expr:[137:24->0:-1] posCursor:[137:30] posNoWhite:[137:29] Found expr:[137:24->0:-1] Completable: Cpath Value[root]-> @@ -725,7 +715,6 @@ Complete src/CompletionInferValues.res 146:30 posCursor:[146:30] posNoWhite:[146:29] Found expr:[146:3->146:33] Pexp_apply ...[146:3->146:6] (~cb146:8->146:10=...[146:11->146:32]) posCursor:[146:30] posNoWhite:[146:29] Found expr:[146:11->146:32] -posCursor:[146:30] posNoWhite:[146:29] Found expr:[146:12->146:32] posCursor:[146:30] posNoWhite:[146:29] Found expr:[146:24->0:-1] posCursor:[146:30] posNoWhite:[146:29] Found expr:[146:24->0:-1] Completable: Cpath Value[root]-> @@ -802,7 +791,6 @@ Complete src/CompletionInferValues.res 158:105 posCursor:[158:105] posNoWhite:[158:104] Found expr:[158:18->158:110] Pexp_apply ...[158:18->158:49] (~prepare158:51->158:58=...[158:59->158:72], ~render158:74->158:80=...[158:81->158:106], ...[158:107->158:109]) posCursor:[158:105] posNoWhite:[158:104] Found expr:[158:81->158:106] -posCursor:[158:105] posNoWhite:[158:104] Found expr:[158:82->158:106] posCursor:[158:105] posNoWhite:[158:104] Found expr:[158:97->158:105] Pexp_field [158:97->158:104] _:[158:105->158:105] Completable: Cpath Value[support]."" @@ -827,7 +815,6 @@ Complete src/CompletionInferValues.res 162:110 posCursor:[162:110] posNoWhite:[162:109] Found expr:[162:18->162:115] Pexp_apply ...[162:18->162:49] (~prepare162:51->162:58=...[162:59->162:72], ~render162:74->162:80=...[162:81->162:111], ...[162:112->162:114]) posCursor:[162:110] posNoWhite:[162:109] Found expr:[162:81->162:111] -posCursor:[162:110] posNoWhite:[162:109] Found expr:[162:82->162:111] posCursor:[162:110] posNoWhite:[162:109] Found expr:[162:104->0:-1] posCursor:[162:110] posNoWhite:[162:109] Found expr:[162:104->0:-1] Completable: Cpath Value[root]-> diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt index cbb97152b8..6036538868 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt @@ -23,7 +23,6 @@ Path Js.String2.st Complete src/CompletionJsx.res 13:21 posCursor:[13:21] posNoWhite:[13:20] Found expr:[8:13->33:3] -posCursor:[13:21] posNoWhite:[13:20] Found expr:[8:14->33:3] posCursor:[13:21] posNoWhite:[13:20] Found expr:[9:4->32:10] posCursor:[13:21] posNoWhite:[13:20] Found expr:[10:4->32:10] posCursor:[13:21] posNoWhite:[13:20] Found expr:[11:4->32:10] @@ -61,7 +60,6 @@ Path Js.String2.st Complete src/CompletionJsx.res 18:24 posCursor:[18:24] posNoWhite:[18:23] Found expr:[8:13->33:3] -posCursor:[18:24] posNoWhite:[18:23] Found expr:[8:14->33:3] posCursor:[18:24] posNoWhite:[18:23] Found expr:[9:4->32:10] posCursor:[18:24] posNoWhite:[18:23] Found expr:[10:4->32:10] posCursor:[18:24] posNoWhite:[18:23] Found expr:[11:4->32:10] @@ -106,7 +104,6 @@ Path Js.String2.st Complete src/CompletionJsx.res 20:27 posCursor:[20:27] posNoWhite:[20:26] Found expr:[8:13->33:3] -posCursor:[20:27] posNoWhite:[20:26] Found expr:[8:14->33:3] posCursor:[20:27] posNoWhite:[20:26] Found expr:[9:4->32:10] posCursor:[20:27] posNoWhite:[20:26] Found expr:[10:4->32:10] posCursor:[20:27] posNoWhite:[20:26] Found expr:[11:4->32:10] @@ -150,7 +147,6 @@ Path Js.String2.st Complete src/CompletionJsx.res 22:44 posCursor:[22:44] posNoWhite:[22:43] Found expr:[8:13->33:3] -posCursor:[22:44] posNoWhite:[22:43] Found expr:[8:14->33:3] posCursor:[22:44] posNoWhite:[22:43] Found expr:[9:4->32:10] posCursor:[22:44] posNoWhite:[22:43] Found expr:[10:4->32:10] posCursor:[22:44] posNoWhite:[22:43] Found expr:[11:4->32:10] @@ -196,7 +192,6 @@ Path Js.String2.st Complete src/CompletionJsx.res 24:19 posCursor:[24:19] posNoWhite:[24:18] Found expr:[8:13->33:3] -posCursor:[24:19] posNoWhite:[24:18] Found expr:[8:14->33:3] posCursor:[24:19] posNoWhite:[24:18] Found expr:[9:4->32:10] posCursor:[24:19] posNoWhite:[24:18] Found expr:[10:4->32:10] posCursor:[24:19] posNoWhite:[24:18] Found expr:[11:4->32:10] @@ -277,7 +272,6 @@ Path Belt.Int. Complete src/CompletionJsx.res 26:14 posCursor:[26:14] posNoWhite:[26:13] Found expr:[8:13->33:3] -posCursor:[26:14] posNoWhite:[26:13] Found expr:[8:14->33:3] posCursor:[26:14] posNoWhite:[26:13] Found expr:[9:4->32:10] posCursor:[26:14] posNoWhite:[26:13] Found expr:[10:4->32:10] posCursor:[26:14] posNoWhite:[26:13] Found expr:[11:4->32:10] @@ -357,7 +351,6 @@ Path Belt.Int. Complete src/CompletionJsx.res 28:20 posCursor:[28:20] posNoWhite:[28:19] Found expr:[8:13->33:3] -posCursor:[28:20] posNoWhite:[28:19] Found expr:[8:14->33:3] posCursor:[28:20] posNoWhite:[28:19] Found expr:[9:4->32:10] posCursor:[28:20] posNoWhite:[28:19] Found expr:[10:4->32:10] posCursor:[28:20] posNoWhite:[28:19] Found expr:[11:4->32:10] @@ -396,7 +389,6 @@ Path Js.Array2.a Complete src/CompletionJsx.res 30:12 posCursor:[30:12] posNoWhite:[30:11] Found expr:[8:13->33:3] -posCursor:[30:12] posNoWhite:[30:11] Found expr:[8:14->33:3] posCursor:[30:12] posNoWhite:[30:11] Found expr:[9:4->32:10] posCursor:[30:12] posNoWhite:[30:11] Found expr:[10:4->32:10] posCursor:[30:12] posNoWhite:[30:11] Found expr:[11:4->32:10] diff --git a/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt b/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt index 2e4d21643c..7ea73630c3 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionPattern.res.txt @@ -1129,7 +1129,6 @@ Path res Complete src/CompletionPattern.res 227:25 posCursor:[227:25] posNoWhite:[227:24] Found expr:[223:11->231:1] -posCursor:[227:25] posNoWhite:[227:24] Found expr:[223:12->231:1] posCursor:[227:25] posNoWhite:[227:24] Found expr:[226:4->227:28] posCursor:[227:25] posNoWhite:[227:24] Found pattern:[227:18->227:27] Completable: Cpattern Value[r]->recordBody diff --git a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt index 24521a5cf3..ab4a1661d6 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionPipeChain.res.txt @@ -426,7 +426,6 @@ Complete src/CompletionPipeChain.res 82:30 posCursor:[82:30] posNoWhite:[82:29] Found expr:[76:15->93:1] Pexp_apply ...[76:15->76:46] (~prepare77:3->77:10=...[77:11->77:24], ~render78:3->78:9=...[78:10->91:3], ...[92:2->92:4]) posCursor:[82:30] posNoWhite:[82:29] Found expr:[78:10->91:3] -posCursor:[82:30] posNoWhite:[82:29] Found expr:[78:10->91:3] posCursor:[82:30] posNoWhite:[82:29] Found expr:[79:4->90:14] posCursor:[82:30] posNoWhite:[82:29] Found expr:[82:7->90:14] posCursor:[82:30] posNoWhite:[82:29] Found expr:[82:7->82:30] @@ -453,7 +452,6 @@ Complete src/CompletionPipeChain.res 88:16 posCursor:[88:16] posNoWhite:[88:15] Found expr:[76:15->93:1] Pexp_apply ...[76:15->76:46] (~prepare77:3->77:10=...[77:11->77:24], ~render78:3->78:9=...[78:10->91:3], ...[92:2->92:4]) posCursor:[88:16] posNoWhite:[88:15] Found expr:[78:10->91:3] -posCursor:[88:16] posNoWhite:[88:15] Found expr:[78:10->91:3] posCursor:[88:16] posNoWhite:[88:15] Found expr:[79:4->90:14] posCursor:[88:16] posNoWhite:[88:15] Found expr:[84:4->90:14] posCursor:[88:16] posNoWhite:[88:15] Found expr:[85:4->90:14] diff --git a/tests/analysis_tests/tests/src/expected/Destructuring.res.txt b/tests/analysis_tests/tests/src/expected/Destructuring.res.txt index 3cafe0a912..000a516af5 100644 --- a/tests/analysis_tests/tests/src/expected/Destructuring.res.txt +++ b/tests/analysis_tests/tests/src/expected/Destructuring.res.txt @@ -34,7 +34,6 @@ Path x Complete src/Destructuring.res 11:13 posCursor:[11:13] posNoWhite:[11:11] Found expr:[10:8->14:1] -posCursor:[11:13] posNoWhite:[11:11] Found expr:[10:9->14:1] posCursor:[11:13] posNoWhite:[11:11] Found expr:[11:2->13:6] posCursor:[11:13] posNoWhite:[11:11] Found pattern:[11:6->11:14] Completable: Cpattern Value[x]->recordBody @@ -51,7 +50,6 @@ Path x Complete src/Destructuring.res 17:10 posCursor:[17:10] posNoWhite:[17:9] Found expr:[16:9->20:1] -posCursor:[17:10] posNoWhite:[17:9] Found expr:[16:10->20:1] posCursor:[17:10] posNoWhite:[17:9] Found expr:[17:5->19:11] posCursor:[17:10] posNoWhite:[17:9] Found pattern:[17:9->17:11] Completable: Cpattern Value[x]->recordBody diff --git a/tests/analysis_tests/tests/src/expected/DocumentSymbol.res.txt b/tests/analysis_tests/tests/src/expected/DocumentSymbol.res.txt index 561093483a..d103cf3956 100644 --- a/tests/analysis_tests/tests/src/expected/DocumentSymbol.res.txt +++ b/tests/analysis_tests/tests/src/expected/DocumentSymbol.res.txt @@ -14,7 +14,7 @@ DocumentSymbol src/DocumentSymbol.res "children": [ { "name": "customDouble", - "kind": 13, + "kind": 12, "range": {"start": {"line": 6, "character": 2}, "end": {"line": 6, "character": 35}}, "selectionRange": {"start": {"line": 6, "character": 2}, "end": {"line": 6, "character": 35}} }] @@ -27,13 +27,13 @@ DocumentSymbol src/DocumentSymbol.res "children": [ { "name": "foo", - "kind": 13, + "kind": 12, "range": {"start": {"line": 10, "character": 2}, "end": {"line": 10, "character": 54}}, "selectionRange": {"start": {"line": 10, "character": 2}, "end": {"line": 10, "character": 54}} }, { "name": "next", - "kind": 13, + "kind": 12, "range": {"start": {"line": 11, "character": 2}, "end": {"line": 11, "character": 48}}, "selectionRange": {"start": {"line": 11, "character": 2}, "end": {"line": 11, "character": 48}} }] @@ -58,13 +58,13 @@ DocumentSymbol src/DocumentSymbol.res }, { "name": "abc", - "kind": 13, + "kind": 12, "range": {"start": {"line": 18, "character": 2}, "end": {"line": 18, "character": 32}}, "selectionRange": {"start": {"line": 18, "character": 2}, "end": {"line": 18, "character": 32}} }, { "name": "abd", - "kind": 13, + "kind": 12, "range": {"start": {"line": 19, "character": 2}, "end": {"line": 19, "character": 32}}, "selectionRange": {"start": {"line": 19, "character": 2}, "end": {"line": 19, "character": 32}} }] @@ -89,7 +89,7 @@ DocumentSymbol src/DocumentSymbol.res "children": [ { "name": "make", - "kind": 13, + "kind": 12, "range": {"start": {"line": 26, "character": 4}, "end": {"line": 27, "character": 97}}, "selectionRange": {"start": {"line": 26, "character": 4}, "end": {"line": 27, "character": 97}} }] diff --git a/tests/analysis_tests/tests/src/expected/RecoveryOnProp.res.txt b/tests/analysis_tests/tests/src/expected/RecoveryOnProp.res.txt index 042b5569db..bb85ebdca0 100644 --- a/tests/analysis_tests/tests/src/expected/RecoveryOnProp.res.txt +++ b/tests/analysis_tests/tests/src/expected/RecoveryOnProp.res.txt @@ -2,7 +2,6 @@ Complete src/RecoveryOnProp.res 6:26 posCursor:[6:26] posNoWhite:[6:25] Found expr:[3:3->11:8] JSX 3:6] onClick[4:4->4:11]=...[4:13->0:-1]> _children:None posCursor:[6:26] posNoWhite:[6:25] Found expr:[4:13->8:6] -posCursor:[6:26] posNoWhite:[6:25] Found expr:[4:13->8:6] posCursor:[6:26] posNoWhite:[6:25] Found expr:[5:6->8:5] posCursor:[6:26] posNoWhite:[6:25] Found expr:[6:16->8:5] posCursor:[6:26] posNoWhite:[6:25] Found pattern:[6:20->8:5] diff --git a/tests/analysis_tests/tests/src/expected/Xform.res.txt b/tests/analysis_tests/tests/src/expected/Xform.res.txt index b37acf31db..fec60ff18b 100644 --- a/tests/analysis_tests/tests/src/expected/Xform.res.txt +++ b/tests/analysis_tests/tests/src/expected/Xform.res.txt @@ -119,7 +119,6 @@ newText: Xform src/Xform.res 48:21 posCursor:[48:21] posNoWhite:[48:19] Found expr:[48:15->48:25] -posCursor:[48:21] posNoWhite:[48:19] Found expr:[48:15->48:25] Completable: Cpath Value[name] Package opens Pervasives.JsxModules.place holder ContextPath Value[name] From 429a147c8408871e58646d4dd84c8375ca68b070 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 13 Dec 2024 14:35:38 +0100 Subject: [PATCH 09/17] TODO: investigate termination --- .../termination/expected/termination.txt | 59 +++++++------------ 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt b/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt index 63e15f8134..5852d6ee99 100644 --- a/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt +++ b/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt @@ -70,15 +70,16 @@ Termination Analysis for butSecondArgumentIsAlwaysEvaluated Function Table - 1 parseExpression: [_ || _]; [+Parser.next; parseExpression; parseExpression; _ || _] - 2 parseList: parseList$loop - 3 parseList$loop: [_ || f; parseList$loop; _] - 4 parseListExpression: _ - 5 parseListExpression2: parseExpression; parseList - 6 parseListInt: _ - 7 parseListIntTailRecursive: parseListIntTailRecursive$loop - 8 parseListIntTailRecursive$loop: [_ || parseListIntTailRecursive$loop] - 9 parseListListInt: parseList + 1 parseExpression: [_ || _]; [+Parser.next; parseExpression; parseExpression; _ || parseInt] + 2 parseInt: [_ || _]; +Parser.next; _ + 3 parseList: parseList$loop + 4 parseList$loop: [_ || f; parseList$loop; _] + 5 parseListExpression: _ + 6 parseListExpression2: parseExpression; parseList + 7 parseListInt: parseList + 8 parseListIntTailRecursive: parseListIntTailRecursive$loop + 9 parseListIntTailRecursive$loop: [_ || parseInt; parseListIntTailRecursive$loop] + 10 parseListListInt: parseList Termination Analysis for parseListInt @@ -111,10 +112,13 @@ Function Table 1 alwaysReturnNone: [+Parser.next; alwaysReturnNone || None] - 2 parseIntOWrapper: _ - 3 parseListIntO: _ - 4 testAlwaysReturnNone: alwaysReturnNone - 5 thisMakesNoProgress: None; [_ || +Parser.next; Some] + 2 parseIntO: [+Parser.next; Some || None] + 3 parseIntOWrapper: parseIntO + 4 parseListIntO: parseListO + 5 parseListO: parseListO$loop + 6 parseListO$loop: [+Parser.next; _ || switch f {some: parseListO$loop, none: _}] + 7 testAlwaysReturnNone: alwaysReturnNone + 8 thisMakesNoProgress: None; [_ || +Parser.next; Some] Termination Analysis for parseListIntO @@ -149,10 +153,10 @@ Termination Analysis Stats Files:1 Recursive Blocks:21 - Functions:45 - Infinite Loops:12 - Hygiene Errors:3 - Cache Hits:4/21 + Functions:49 + Infinite Loops:10 + Hygiene Errors:2 + Cache Hits:7/30 Error Termination @@ -207,10 +211,6 @@ TestCyberTruck.res:217:32-73 Call must have named argument f - Error Hygiene - TestCyberTruck.res:198:29-53 - Named argument f must be passed a recursive function - Error Termination TestCyberTruck.res:180:15-21 Possible infinite loop when calling parseList$loop which is parseList$loop @@ -219,21 +219,6 @@ 2 parseList (TestCyberTruck.res 201) 1 parseListListInt (TestCyberTruck.res 201) - Error Termination - TestCyberTruck.res:180:15-21 - Possible infinite loop when calling parseList$loop which is parseList$loop - CallStack: - 3 parseList$loop (TestCyberTruck.res 183) - 2 parseList (TestCyberTruck.res 220) - 1 parseListExpression2 (TestCyberTruck.res 220) - - Error Termination - TestCyberTruck.res:228:7-38 - Possible infinite loop when calling parseListIntTailRecursive$loop - CallStack: - 2 parseListIntTailRecursive$loop (TestCyberTruck.res 230) - 1 parseListIntTailRecursive (TestCyberTruck.res 223) - Error Termination TestCyberTruck.res:238:31-49 Possible infinite loop when calling loopAfterProgress @@ -246,4 +231,4 @@ CallStack: 1 countRendersCompiled (TestCyberTruck.res 283) - Analysis reported 15 issues (Error Hygiene:3, Error Termination:12) + Analysis reported 12 issues (Error Hygiene:2, Error Termination:10) From a970164ef57cfde6b4e6d3e6093c707381314756 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 15 Dec 2024 16:21:21 +0100 Subject: [PATCH 10/17] Clean up now unused occurrences of `Function$`. --- analysis/src/CompletionFrontEnd.ml | 2 +- analysis/src/Xform.ml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index 6337c0b5bb..30778f0ee0 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -1093,7 +1093,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor (* Ignore list expressions, used in JSX, unit, and more *) () | Pexp_construct (lid, eOpt) -> ( let lidPath = flattenLidCheckDot lid in - if debug && lid.txt <> Lident "Function$" then + if debug then Printf.printf "Pexp_construct %s:%s %s\n" (lidPath |> String.concat "\n") (Loc.toString lid.loc) diff --git a/analysis/src/Xform.ml b/analysis/src/Xform.ml index f2a91382b9..fd4ee056a6 100644 --- a/analysis/src/Xform.ml +++ b/analysis/src/Xform.ml @@ -303,10 +303,7 @@ module AddTypeAnnotation = struct in let rec processFunction ~argNum (e : Parsetree.expression) = match e.pexp_desc with - | Pexp_fun (argLabel, _, pat, e, _) - | Pexp_construct - ( {txt = Lident "Function$"}, - Some {pexp_desc = Pexp_fun (argLabel, _, pat, e, _)} ) -> + | Pexp_fun (argLabel, _, pat, e, _) -> let isUnlabeledOnlyArg = argNum = 1 && argLabel = Nolabel && From e356454f4ac30c7bf9f1d0e4bb173d057df6c3f2 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 15 Dec 2024 16:21:40 +0100 Subject: [PATCH 11/17] Add ppx error test --- tests/tools_tests/ppx/TestPpx.res | 5 +++ .../src/expected/TestPpx.res.jsout | 45 ------------------- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/tests/tools_tests/ppx/TestPpx.res b/tests/tools_tests/ppx/TestPpx.res index 5ac14dbddb..8cf9d4c5f3 100644 --- a/tests/tools_tests/ppx/TestPpx.res +++ b/tests/tools_tests/ppx/TestPpx.res @@ -24,3 +24,8 @@ module Arity = { let two = (x, y) => x + y let n = two(one(1), 5) } + +@module("react") +external useState: (unit => 'state) => string = "useState" + +let _ = useState(() => 0) diff --git a/tests/tools_tests/src/expected/TestPpx.res.jsout b/tests/tools_tests/src/expected/TestPpx.res.jsout index 37e7eac983..e69de29bb2 100644 --- a/tests/tools_tests/src/expected/TestPpx.res.jsout +++ b/tests/tools_tests/src/expected/TestPpx.res.jsout @@ -1,45 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -'use strict'; - - -console.log("ppx test"); - -console.log("ppx test"); - -let M = { - v: 10 -}; - -let OptionalFields = { - r: { - y: 1.0 - } -}; - -function one(x) { - return x; -} - -function two(x, y) { - return x + y | 0; -} - -let Arity = { - one: one, - two: two, - n: 6 -}; - -let a = "A"; - -let b = "B"; - -let vv = 10; - -exports.a = a; -exports.b = b; -exports.M = M; -exports.vv = vv; -exports.OptionalFields = OptionalFields; -exports.Arity = Arity; -/* Not a pure module */ From 0d82a3e3b3680e59933053a912227eec81097bdd Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 15 Dec 2024 16:36:34 +0100 Subject: [PATCH 12/17] Adapt ppx ast conversion that was still missing. --- compiler/ml/ast_mapper_from0.ml | 13 ++-- compiler/ml/ast_mapper_to0.ml | 60 ++++++++++--------- .../src/expected/TestPpx.res.jsout | 50 ++++++++++++++++ 3 files changed, 85 insertions(+), 38 deletions(-) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 051517062c..92349dbdaa 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -319,16 +319,11 @@ module E = struct | [] -> assert false in match arg1 with - | Some ({pexp_desc = Pexp_fun (l, eo, p, e, _)} as e1) -> + | Some + ({pexp_desc = Pexp_fun (l, eo, p, e, _); pexp_attributes = attrs} as + e1) -> let arity = attributes_to_arity attrs in - { - e1 with - pexp_desc = - Pexp_construct - ( lid1, - Some {e with pexp_desc = Pexp_fun (l, eo, p, e, Some arity)} - ); - } + {e1 with pexp_desc = Pexp_fun (l, eo, p, e, Some arity)} | _ -> exp1) | _ -> exp1) | Pexp_variant (lab, eo) -> diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index c45974a95d..7d8e50ba30 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -283,41 +283,43 @@ module E = struct | Pexp_constant x -> constant ~loc ~attrs (map_constant x) | Pexp_let (r, vbs, e) -> let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) (sub.expr sub e) - | Pexp_fun (lab, def, p, e, _) -> - fun_ ~loc ~attrs lab - (map_opt (sub.expr sub) def) - (sub.pat sub p) (sub.expr sub e) + | Pexp_fun (lab, def, p, e, arity) -> ( + let e = + fun_ ~loc ~attrs lab + (map_opt (sub.expr sub) def) + (sub.pat sub p) (sub.expr sub e) + in + match arity with + | None -> e + | Some arity -> + let arity_to_attributes arity = + [ + ( Location.mknoloc "res.arity", + Parsetree0.PStr + [ + Ast_helper0.Str.eval + (Ast_helper0.Exp.constant + (Pconst_integer (string_of_int arity, None))); + ] ); + ] + in + let e = + { + e with + pexp_attributes = arity_to_attributes arity @ e.pexp_attributes; + } + in + Ast_helper0.Exp.construct + (Location.mkloc (Longident.Lident "Function$") e.pexp_loc) + (Some e)) | Pexp_apply (e, l) -> apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) | Pexp_match (e, pel) -> match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) - | Pexp_construct (lid, arg) -> ( - let exp0 = - construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) - in - match lid.txt with - | Lident "Function$" -> ( - match arg with - | Some {pexp_desc = Pexp_fun (_, _, _, _, Some arity)} -> - let arity_to_attributes arity = - [ - ( Location.mknoloc "res.arity", - Parsetree0.PStr - [ - Ast_helper0.Str.eval - (Ast_helper0.Exp.constant - (Pconst_integer (string_of_int arity, None))); - ] ); - ] - in - { - exp0 with - pexp_attributes = arity_to_attributes arity @ exp0.pexp_attributes; - } - | _ -> assert false) - | _ -> exp0) + | Pexp_construct (lid, arg) -> + construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) | Pexp_variant (lab, eo) -> variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) | Pexp_record (l, eo) -> diff --git a/tests/tools_tests/src/expected/TestPpx.res.jsout b/tests/tools_tests/src/expected/TestPpx.res.jsout index e69de29bb2..f6ac674064 100644 --- a/tests/tools_tests/src/expected/TestPpx.res.jsout +++ b/tests/tools_tests/src/expected/TestPpx.res.jsout @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +let React = require("react"); + +console.log("ppx test"); + +console.log("ppx test"); + +let M = { + v: 10 +}; + +let OptionalFields = { + r: { + y: 1.0 + } +}; + +function one(x) { + return x; +} + +function two(x, y) { + return x + y | 0; +} + +let n = 6; + +let Arity = { + one: one, + two: two, + n: n +}; + +React.useState(() => 0); + +let a = "A"; + +let b = "B"; + +let vv = 10; + +exports.a = a; +exports.b = b; +exports.M = M; +exports.vv = vv; +exports.OptionalFields = OptionalFields; +exports.Arity = Arity; +/* Not a pure module */ From ee7484d362104b062f3f4aabda09e312cfe338cf Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 15 Dec 2024 20:17:14 +0100 Subject: [PATCH 13/17] Remove what's now the identity function. --- compiler/ml/ast_uncurried.ml | 5 ----- compiler/syntax/src/res_parens.ml | 3 --- 2 files changed, 8 deletions(-) diff --git a/compiler/ml/ast_uncurried.ml b/compiler/ml/ast_uncurried.ml index 4f4c271d45..9305d67d88 100644 --- a/compiler/ml/ast_uncurried.ml +++ b/compiler/ml/ast_uncurried.ml @@ -38,11 +38,6 @@ let expr_extract_uncurried_fun (expr : Parsetree.expression) = | Pexp_fun (_, _, _, _, Some _) -> expr | _ -> assert false -let remove_fun (expr : Parsetree.expression) = - match expr.pexp_desc with - | Pexp_construct ({txt = Lident "Function$"}, Some e) -> e - | _ -> expr - let core_type_is_uncurried_fun (typ : Parsetree.core_type) = match typ.ptyp_desc with | Ptyp_constr ({txt = Lident "function$"}, [{ptyp_desc = Ptyp_arrow _}; _]) -> diff --git a/compiler/syntax/src/res_parens.ml b/compiler/syntax/src/res_parens.ml index ad6256d9ea..836b98c3f4 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -83,7 +83,6 @@ let unary_expr_operand expr = match opt_braces with | Some ({Location.loc = braces_loc}, _) -> Braced braces_loc | None -> ( - let expr = Ast_uncurried.remove_fun expr in match expr with | {Parsetree.pexp_attributes = attrs} when match ParsetreeViewer.filter_parsing_attrs attrs with @@ -167,7 +166,6 @@ let rhs_binary_expr_operand parent_operator rhs = | _ -> false let flatten_operand_rhs parent_operator rhs = - let rhs = Ast_uncurried.remove_fun rhs in match rhs.Parsetree.pexp_desc with | Parsetree.Pexp_apply ( { @@ -241,7 +239,6 @@ let is_negative_constant constant = | _ -> false let field_expr expr = - let expr = Ast_uncurried.remove_fun expr in let opt_braces, _ = ParsetreeViewer.process_braces_attr expr in match opt_braces with | Some ({Location.loc = braces_loc}, _) -> Braced braces_loc From 816e61c881eec197fd578b85f9eca7af4a99830b Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sun, 15 Dec 2024 20:32:21 +0100 Subject: [PATCH 14/17] Fix ppx mapper and add example. The arity attribute goes on the `Function$` ast node, not the `Pexp_fun` one. --- compiler/ml/ast_mapper_from0.ml | 4 +--- compiler/ml/ast_mapper_to0.ml | 7 +------ tests/tools_tests/ppx/TestPpx.res | 2 ++ tests/tools_tests/src/expected/TestPpx.res.jsout | 5 +++++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/ml/ast_mapper_from0.ml b/compiler/ml/ast_mapper_from0.ml index 92349dbdaa..22934888ca 100644 --- a/compiler/ml/ast_mapper_from0.ml +++ b/compiler/ml/ast_mapper_from0.ml @@ -319,9 +319,7 @@ module E = struct | [] -> assert false in match arg1 with - | Some - ({pexp_desc = Pexp_fun (l, eo, p, e, _); pexp_attributes = attrs} as - e1) -> + | Some ({pexp_desc = Pexp_fun (l, eo, p, e, _)} as e1) -> let arity = attributes_to_arity attrs in {e1 with pexp_desc = Pexp_fun (l, eo, p, e, Some arity)} | _ -> exp1) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index 7d8e50ba30..30b0834735 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -303,13 +303,8 @@ module E = struct ] ); ] in - let e = - { - e with - pexp_attributes = arity_to_attributes arity @ e.pexp_attributes; - } - in Ast_helper0.Exp.construct + ~attrs:(arity_to_attributes arity) (Location.mkloc (Longident.Lident "Function$") e.pexp_loc) (Some e)) | Pexp_apply (e, l) -> diff --git a/tests/tools_tests/ppx/TestPpx.res b/tests/tools_tests/ppx/TestPpx.res index 8cf9d4c5f3..88cd500f37 100644 --- a/tests/tools_tests/ppx/TestPpx.res +++ b/tests/tools_tests/ppx/TestPpx.res @@ -29,3 +29,5 @@ module Arity = { external useState: (unit => 'state) => string = "useState" let _ = useState(() => 0) + +let fpromise = async (promise, _x) => await promise diff --git a/tests/tools_tests/src/expected/TestPpx.res.jsout b/tests/tools_tests/src/expected/TestPpx.res.jsout index f6ac674064..653567ba05 100644 --- a/tests/tools_tests/src/expected/TestPpx.res.jsout +++ b/tests/tools_tests/src/expected/TestPpx.res.jsout @@ -35,6 +35,10 @@ let Arity = { React.useState(() => 0); +async function fpromise(promise, _x) { + return await promise; +} + let a = "A"; let b = "B"; @@ -47,4 +51,5 @@ exports.M = M; exports.vv = vv; exports.OptionalFields = OptionalFields; exports.Arity = Arity; +exports.fpromise = fpromise; /* Not a pure module */ From bb03d2352e57766f6cd99ba959b2724f8ba78f18 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 16 Dec 2024 08:30:33 +0100 Subject: [PATCH 15/17] Remove difference on termination analysis tests. --- analysis/reanalyze/src/Arnold.ml | 2 +- .../termination/expected/termination.txt | 59 ++++++++++++------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index f9598cd0dc..e4dd423e2f 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -545,7 +545,7 @@ module FindFunctionsCalled = struct let findCallees (expression : Typedtree.expression) = let isFunction = match expression.exp_desc with - | Texp_function _ -> true + | Texp_function {arity = None} -> true | _ -> false in let callees = ref StringSet.empty in diff --git a/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt b/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt index 5852d6ee99..63e15f8134 100644 --- a/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt +++ b/tests/analysis_tests/tests-reanalyze/termination/expected/termination.txt @@ -70,16 +70,15 @@ Termination Analysis for butSecondArgumentIsAlwaysEvaluated Function Table - 1 parseExpression: [_ || _]; [+Parser.next; parseExpression; parseExpression; _ || parseInt] - 2 parseInt: [_ || _]; +Parser.next; _ - 3 parseList: parseList$loop - 4 parseList$loop: [_ || f; parseList$loop; _] - 5 parseListExpression: _ - 6 parseListExpression2: parseExpression; parseList - 7 parseListInt: parseList - 8 parseListIntTailRecursive: parseListIntTailRecursive$loop - 9 parseListIntTailRecursive$loop: [_ || parseInt; parseListIntTailRecursive$loop] - 10 parseListListInt: parseList + 1 parseExpression: [_ || _]; [+Parser.next; parseExpression; parseExpression; _ || _] + 2 parseList: parseList$loop + 3 parseList$loop: [_ || f; parseList$loop; _] + 4 parseListExpression: _ + 5 parseListExpression2: parseExpression; parseList + 6 parseListInt: _ + 7 parseListIntTailRecursive: parseListIntTailRecursive$loop + 8 parseListIntTailRecursive$loop: [_ || parseListIntTailRecursive$loop] + 9 parseListListInt: parseList Termination Analysis for parseListInt @@ -112,13 +111,10 @@ Function Table 1 alwaysReturnNone: [+Parser.next; alwaysReturnNone || None] - 2 parseIntO: [+Parser.next; Some || None] - 3 parseIntOWrapper: parseIntO - 4 parseListIntO: parseListO - 5 parseListO: parseListO$loop - 6 parseListO$loop: [+Parser.next; _ || switch f {some: parseListO$loop, none: _}] - 7 testAlwaysReturnNone: alwaysReturnNone - 8 thisMakesNoProgress: None; [_ || +Parser.next; Some] + 2 parseIntOWrapper: _ + 3 parseListIntO: _ + 4 testAlwaysReturnNone: alwaysReturnNone + 5 thisMakesNoProgress: None; [_ || +Parser.next; Some] Termination Analysis for parseListIntO @@ -153,10 +149,10 @@ Termination Analysis Stats Files:1 Recursive Blocks:21 - Functions:49 - Infinite Loops:10 - Hygiene Errors:2 - Cache Hits:7/30 + Functions:45 + Infinite Loops:12 + Hygiene Errors:3 + Cache Hits:4/21 Error Termination @@ -211,6 +207,10 @@ TestCyberTruck.res:217:32-73 Call must have named argument f + Error Hygiene + TestCyberTruck.res:198:29-53 + Named argument f must be passed a recursive function + Error Termination TestCyberTruck.res:180:15-21 Possible infinite loop when calling parseList$loop which is parseList$loop @@ -219,6 +219,21 @@ 2 parseList (TestCyberTruck.res 201) 1 parseListListInt (TestCyberTruck.res 201) + Error Termination + TestCyberTruck.res:180:15-21 + Possible infinite loop when calling parseList$loop which is parseList$loop + CallStack: + 3 parseList$loop (TestCyberTruck.res 183) + 2 parseList (TestCyberTruck.res 220) + 1 parseListExpression2 (TestCyberTruck.res 220) + + Error Termination + TestCyberTruck.res:228:7-38 + Possible infinite loop when calling parseListIntTailRecursive$loop + CallStack: + 2 parseListIntTailRecursive$loop (TestCyberTruck.res 230) + 1 parseListIntTailRecursive (TestCyberTruck.res 223) + Error Termination TestCyberTruck.res:238:31-49 Possible infinite loop when calling loopAfterProgress @@ -231,4 +246,4 @@ CallStack: 1 countRendersCompiled (TestCyberTruck.res 283) - Analysis reported 12 issues (Error Hygiene:2, Error Termination:10) + Analysis reported 15 issues (Error Hygiene:3, Error Termination:12) From b2638f8a6da858b29cf0fe8be726973ba558089e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 16 Dec 2024 08:56:59 +0100 Subject: [PATCH 16/17] Added test that components with type vars do compile. --- .../tests/src/expected/Completion.res.txt | 10 +++++++++ .../src/expected/CompletionJsxProps.res.txt | 10 +++++++++ .../tests/src/expected/typeConstraint.res.txt | 0 .../tests/src/typeConstraint.res | 21 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/analysis_tests/tests/src/expected/typeConstraint.res.txt create mode 100644 tests/analysis_tests/tests/src/typeConstraint.res diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 574174fd8b..785f9b00b7 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -2037,6 +2037,16 @@ Path T "modulePath": "TypeAtPosCompletion", "filePath": "src/Completion.res" } + }, { + "label": "TypeConstraint", + "kind": 9, + "tags": [], + "detail": "module TypeConstraint", + "documentation": null, + "data": { + "modulePath": "TypeConstraint", + "filePath": "src/Completion.res" + } }, { "label": "TypeDefinition", "kind": 9, diff --git a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt index c4b4a49a7c..8e745b7073 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt @@ -89,6 +89,16 @@ Path CompletionSupport.TestComponent.make "modulePath": "TypeAtPosCompletion", "filePath": "src/CompletionJsxProps.res" } + }, { + "label": "TypeConstraint", + "kind": 9, + "tags": [], + "detail": "module TypeConstraint", + "documentation": null, + "data": { + "modulePath": "TypeConstraint", + "filePath": "src/CompletionJsxProps.res" + } }, { "label": "TypeDefinition", "kind": 9, diff --git a/tests/analysis_tests/tests/src/expected/typeConstraint.res.txt b/tests/analysis_tests/tests/src/expected/typeConstraint.res.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/analysis_tests/tests/src/typeConstraint.res b/tests/analysis_tests/tests/src/typeConstraint.res new file mode 100644 index 0000000000..f40fd322bf --- /dev/null +++ b/tests/analysis_tests/tests/src/typeConstraint.res @@ -0,0 +1,21 @@ +@@jsxConfig({version: 4, mode: "classic"}) + +module V4C = { + @react.component + let make: + type a. (~a: a, ~b: a, a) => React.element = + (~a, ~b, _) =>
+} + +let v4c = + +@@jsxConfig({version: 4, mode: "automatic"}) + +module V4A = { + @react.component + let make: + type a. (~a: a, ~b: a, a) => React.element = + (~a, ~b, _) =>
+} + +let v4a = From 0196c82e370df8e5b9cb08c6f0eda041cc318f88 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 18 Dec 2024 12:00:16 +0100 Subject: [PATCH 17/17] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f893536f57..bec1230c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ - AST cleanup: Remove Pexp_function from the AST. https://github.com/rescript-lang/rescript/pull/7198 - Remove unused code from Location and Rescript_cpp modules. https://github.com/rescript-lang/rescript/pull/7150 - Build with OCaml 5.2.1. https://github.com/rescript-lang/rescript-compiler/pull/7201 +- AST cleanup: Remove `Function$` entirely for function definitions. https://github.com/rescript-lang/rescript/pull/7200 + # 12.0.0-alpha.5