Skip to content

Commit bfa8c49

Browse files
committed
Fix PR 6148
Fix #6148
1 parent cde772a commit bfa8c49

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

res_syntax/src/res_parsetree_viewer.ml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ let collectListExpressions expr =
109109

110110
(* (__x) => f(a, __x, c) -----> f(a, _, c) *)
111111
let rewriteUnderscoreApply expr =
112-
match expr.pexp_desc with
112+
let expr_fun =
113+
if Ast_uncurried.exprIsUncurriedFun expr then
114+
Ast_uncurried.exprExtractUncurriedFun expr
115+
else expr
116+
in
117+
match expr_fun.pexp_desc with
113118
| Pexp_fun
114119
( Nolabel,
115120
None,
@@ -154,27 +159,13 @@ let funExpr expr =
154159
let rec collect ~uncurried ~nFun attrsBefore acc expr =
155160
match expr with
156161
| {
157-
pexp_desc =
158-
Pexp_fun
159-
( Nolabel,
160-
None,
161-
{ppat_desc = Ppat_var {txt = "__x"}},
162-
{pexp_desc = Pexp_apply _} );
163-
}
164-
| {
165-
pexp_desc =
166-
Pexp_construct
167-
( {txt = Lident "Function$"},
168-
Some
169-
{
170-
pexp_desc =
171-
Pexp_fun
172-
( Nolabel,
173-
None,
174-
{ppat_desc = Ppat_var {txt = "__x"}},
175-
{pexp_desc = Pexp_apply _} );
176-
} );
177-
} ->
162+
pexp_desc =
163+
Pexp_fun
164+
( Nolabel,
165+
None,
166+
{ppat_desc = Ppat_var {txt = "__x"}},
167+
{pexp_desc = Pexp_apply _} );
168+
} ->
178169
(uncurried, attrsBefore, List.rev acc, rewriteUnderscoreApply expr)
179170
| {pexp_desc = Pexp_newtype (stringLoc, rest); pexp_attributes = attrs} ->
180171
let stringLocs, returnExpr = collectNewTypes [stringLoc] rest in

res_syntax/tests/printer/expr/UncurriedByDefault.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,5 @@ type callback6 = (ReactEvent.Mouse.t => unit) as 'callback
155155
let fooU = () => ()
156156
let fnU = (_x): ((unit) => unit) => fooC
157157
let aU = (() => "foo")->Ok
158+
159+
Ok("_")->Belt.Result.map(concatStrings(_, "foo"))

res_syntax/tests/printer/expr/expected/UncurriedByDefault.res.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,5 @@ type callback6 = (ReactEvent.Mouse.t => unit) as 'callback
155155
let fooU = () => ()
156156
let fnU = (_x): (unit => unit) => fooC
157157
let aU = (() => "foo")->Ok
158+
159+
Ok("_")->Belt.Result.map(concatStrings(_, "foo"))

0 commit comments

Comments
 (0)