Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#### :house: Internal

- Clean up usage of `Ast_uncurried` helpers. https://github.com/rescript-lang/rescript/pull/7987

# 12.0.0-rc.2

#### :boom: Breaking Change
Expand Down
37 changes: 15 additions & 22 deletions compiler/frontend/ast_derive_js_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ let init () =
in
let to_js_body body =
Ast_comb.single_non_rec_value pat_to_js
(Ast_uncurried.uncurried_fun ~arity:1
(Ast_compatible.fun_ ~arity:None
(Pat.constraint_ (Pat.var pat_param) core_type)
body))
(Ast_compatible.fun_ ~arity:(Some 1)
(Pat.constraint_ (Pat.var pat_param) core_type)
body)
in
let ( +> ) a ty = Exp.constraint_ (erase_type a) ty in
let ( +: ) a ty = erase_type (Exp.constraint_ a ty) in
Expand Down Expand Up @@ -227,16 +226,12 @@ let init () =
in
let from_js =
Ast_comb.single_non_rec_value pat_from_js
(Ast_uncurried.uncurried_fun ~arity:1
(Ast_compatible.fun_ ~arity:(Some 1) (Pat.var pat_param)
(if create_type then
Exp.let_ Nonrecursive
[
Vb.mk (Pat.var pat_param)
(exp_param +: new_type);
]
(Exp.constraint_ obj_exp core_type)
else Exp.constraint_ obj_exp core_type)))
(Ast_compatible.fun_ ~arity:(Some 1) (Pat.var pat_param)
(if create_type then
Exp.let_ Nonrecursive
[Vb.mk (Pat.var pat_param) (exp_param +: new_type)]
(Exp.constraint_ obj_exp core_type)
else Exp.constraint_ obj_exp core_type))
in
let rest = [to_js; from_js] in
if create_type then erase_type_str :: new_type_str :: rest
Expand Down Expand Up @@ -273,14 +268,12 @@ 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 ~arity:1
(Ast_compatible.fun_ ~arity:(Some 1)
(Pat.var pat_param)
(let result =
app2 unsafe_index_get_exp rev_exp_map exp_param
in
if create_type then raise_when_not_found result
else result)));
(Ast_compatible.fun_ ~arity:(Some 1) (Pat.var pat_param)
(let result =
app2 unsafe_index_get_exp rev_exp_map exp_param
in
if create_type then raise_when_not_found result
else result));
]
in
if create_type then new_type_str :: v else v
Expand Down
5 changes: 2 additions & 3 deletions compiler/frontend/ast_derive_projector.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ let init () =
->
let txt = "param" in
Ast_comb.single_non_rec_value ?attrs:gentype_attrs pld_name
(* arity will always be 1 since these are single param functions *)
(Ast_compatible.fun_ ~arity:(Some 1)
(Pat.constraint_ (Pat.var {txt; loc}) core_type)
(Exp.field
(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))
{txt = Longident.Lident pld_label; loc})))
| Ptype_variant constructor_declarations ->
Ext_list.map constructor_declarations
(fun
Expand Down
8 changes: 1 addition & 7 deletions compiler/frontend/ast_exp_handle_external.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ let handle_ffi ~loc ~payload =
Ast_helper.Typ.arrows ~loc args any
in
match !is_function with
| Some arity ->
let type_ =
Ast_uncurried.uncurried_type
~arity:(if arity = 0 then 1 else arity)
(arrow ~arity)
in
Ast_helper.Exp.constraint_ ~loc e type_
| Some arity -> Ast_helper.Exp.constraint_ ~loc e (arrow ~arity)
| _ -> err ()
in
wrap_type_constraint
Expand Down
19 changes: 5 additions & 14 deletions compiler/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
(* let make = React.forwardRef({
let \"App" = (props, ref) => make({...props, ref: @optional (Js.Nullabel.toOption(ref))})
})*)
Exp.fun_ ~arity:None Nolabel None
let total_arity = if has_forward_ref then 2 else 1 in
Exp.fun_ ~arity:(Some total_arity) Nolabel None
(match core_type_of_attr with
| None -> make_props_pattern named_type_list
| Some _ -> make_props_pattern typ_vars_of_core_type)
Expand All @@ -639,10 +640,6 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
else inner_expression)
~attrs:binding.pvb_expr.pexp_attributes
in
let full_expression =
full_expression
|> Ast_uncurried.uncurried_fun ~arity:(if has_forward_ref then 2 else 1)
in
let full_expression =
match full_module_name with
| "" -> full_expression
Expand Down Expand Up @@ -764,7 +761,8 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
in
let expression =
(* Shape internal implementation to match wrapper: uncurried when using forwardRef. *)
Exp.fun_ ~arity:(Some 1) ~async:is_async Nolabel None
let total_arity = if has_forward_ref then 2 else 1 in
Exp.fun_ ~arity:(Some total_arity) ~async:is_async Nolabel None
(Pat.constraint_ record_pattern
(Typ.constr ~loc:empty_loc
{txt = Lident "props"; loc = empty_loc}
Expand All @@ -779,10 +777,6 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
| _ -> [Typ.any ()]))))
expression
in
let expression =
if has_forward_ref then expression |> Ast_uncurried.uncurried_fun ~arity:2
else expression
in
let expression =
(* Add new tupes (type a,b,c) to make's definition *)
newtypes
Expand Down Expand Up @@ -887,12 +881,9 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
in
let applied_expression = constrain_jsx_return applied_expression in
let wrapper_expr =
Exp.fun_ ~arity:None Nolabel None props_pattern
Exp.fun_ ~arity:(Some 1) Nolabel None props_pattern
~attrs:binding.pvb_expr.pexp_attributes applied_expression
in

let wrapper_expr = Ast_uncurried.uncurried_fun ~arity:1 wrapper_expr in

let internal_expression =
Exp.let_ Nonrecursive
[Vb.mk (Pat.var {txt = full_module_name; loc}) wrapper_expr]
Expand Down
5 changes: 1 addition & 4 deletions compiler/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,7 @@ let process_underscore_application args =
(Ppat_var (Location.mkloc hidden_var loc))
~loc:Location.none
in
let fun_expr =
Ast_helper.Exp.fun_ ~loc ~arity:(Some 1) Nolabel None pattern exp_apply
in
Ast_uncurried.uncurried_fun ~arity:1 fun_expr
Ast_helper.Exp.fun_ ~loc ~arity:(Some 1) Nolabel None pattern exp_apply
| None -> exp_apply
in
(args, wrap)
Expand Down
2 changes: 1 addition & 1 deletion compiler/syntax/src/res_parsetree_viewer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ let partition_doc_comment_attributes attrs =
let is_fun_newtype expr =
match expr.pexp_desc with
| Pexp_fun _ | Pexp_newtype _ -> true
| _ -> Ast_uncurried.expr_is_uncurried_fun expr
| _ -> false

let requires_special_callback_printing_last_arg args =
let rec loop args =
Expand Down
Loading