Skip to content

Commit 2df3b30

Browse files
committed
Remove uses of "Function$".
1 parent 2423ad0 commit 2df3b30

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

compiler/ml/ast_uncurried.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ let expr_extract_uncurried_fun (expr : Parsetree.expression) =
4646
e
4747
| _ -> assert false
4848

49+
let remove_fun (expr : Parsetree.expression) =
50+
match expr.pexp_desc with
51+
| Pexp_construct ({txt = Lident "Function$"}, Some e) -> e
52+
| _ -> expr
53+
4954
let core_type_is_uncurried_fun (typ : Parsetree.core_type) =
5055
match typ.ptyp_desc with
5156
| Ptyp_constr ({txt = Lident "function$"}, [{ptyp_desc = Ptyp_arrow _}; _]) ->

compiler/syntax/src/res_parens.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ let unary_expr_operand expr =
8383
match opt_braces with
8484
| Some ({Location.loc = braces_loc}, _) -> Braced braces_loc
8585
| None -> (
86+
let expr = Ast_uncurried.remove_fun expr in
8687
match expr with
8788
| {Parsetree.pexp_attributes = attrs}
8889
when match ParsetreeViewer.filter_parsing_attrs attrs with
@@ -111,11 +112,6 @@ let unary_expr_operand expr =
111112
Parenthesized
112113
| _ when ParsetreeViewer.has_await_attribute expr.pexp_attributes ->
113114
Parenthesized
114-
| {pexp_desc = Pexp_construct ({txt = Lident "Function$"}, Some expr)}
115-
when ParsetreeViewer.is_underscore_apply_sugar expr ->
116-
Nothing
117-
| {pexp_desc = Pexp_construct ({txt = Lident "Function$"}, Some _)} ->
118-
Parenthesized
119115
| _ -> Nothing)
120116

121117
let binary_expr_operand ~is_lhs expr =

compiler/syntax/src/res_printer.ml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,19 +2793,7 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl =
27932793
None,
27942794
{ppat_desc = Ppat_var {txt = "__x"}},
27952795
{pexp_desc = Pexp_apply _},
2796-
_ )
2797-
| Pexp_construct
2798-
( {txt = Lident "Function$"},
2799-
Some
2800-
{
2801-
pexp_desc =
2802-
Pexp_fun
2803-
( Nolabel,
2804-
None,
2805-
{ppat_desc = Ppat_var {txt = "__x"}},
2806-
{pexp_desc = Pexp_apply _},
2807-
_ );
2808-
} ) ->
2796+
_ ) ->
28092797
(* (__x) => f(a, __x, c) -----> f(a, _, c) *)
28102798
print_expression_with_comments ~state
28112799
(ParsetreeViewer.rewrite_underscore_apply e_fun)

0 commit comments

Comments
 (0)