Skip to content

Fix PR 6148 #6153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2023
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
35 changes: 13 additions & 22 deletions res_syntax/src/res_parsetree_viewer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ let collectListExpressions expr =

(* (__x) => f(a, __x, c) -----> f(a, _, c) *)
let rewriteUnderscoreApply expr =
match expr.pexp_desc with
let expr_fun =
if Ast_uncurried.exprIsUncurriedFun expr then
Ast_uncurried.exprExtractUncurriedFun expr
else expr
in
match expr_fun.pexp_desc with
| Pexp_fun
( Nolabel,
None,
Expand Down Expand Up @@ -154,27 +159,13 @@ let funExpr expr =
let rec collect ~uncurried ~nFun attrsBefore acc expr =
match expr with
| {
pexp_desc =
Pexp_fun
( Nolabel,
None,
{ppat_desc = Ppat_var {txt = "__x"}},
{pexp_desc = Pexp_apply _} );
}
| {
pexp_desc =
Pexp_construct
( {txt = Lident "Function$"},
Some
{
pexp_desc =
Pexp_fun
( Nolabel,
None,
{ppat_desc = Ppat_var {txt = "__x"}},
{pexp_desc = Pexp_apply _} );
} );
} ->
pexp_desc =
Pexp_fun
( Nolabel,
None,
{ppat_desc = Ppat_var {txt = "__x"}},
{pexp_desc = Pexp_apply _} );
} ->
(uncurried, attrsBefore, List.rev acc, rewriteUnderscoreApply expr)
| {pexp_desc = Pexp_newtype (stringLoc, rest); pexp_attributes = attrs} ->
let stringLocs, returnExpr = collectNewTypes [stringLoc] rest in
Expand Down
2 changes: 2 additions & 0 deletions res_syntax/tests/printer/expr/UncurriedByDefault.res
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,5 @@ type callback6 = (ReactEvent.Mouse.t => unit) as 'callback
let fooU = () => ()
let fnU = (_x): ((unit) => unit) => fooC
let aU = (() => "foo")->Ok

Ok("_")->Belt.Result.map(concatStrings(_, "foo"))
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,5 @@ type callback6 = (ReactEvent.Mouse.t => unit) as 'callback
let fooU = () => ()
let fnU = (_x): (unit => unit) => fooC
let aU = (() => "foo")->Ok

Ok("_")->Belt.Result.map(concatStrings(_, "foo"))