Skip to content

Commit

Permalink
Fix bug that caused necessary braces to be removed (#2481)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored and jordwalke committed Oct 29, 2019
1 parent b555665 commit affdf4c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
32 changes: 32 additions & 0 deletions formatTest/unit_tests/expected_output/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,35 @@ let v =
}),
}
/>;

<Component
prop={
name:
x
++ Option.map(x => {
let y = x;
y ++ y;
}),
}
/>;

<Component
prop={
name:
x##Option.map(x => {
let y = x;
y ++ y;
}),
}
/>;

<Component
prop={
name:
x
|> Option.map(x => {
let y = x;
y ++ y;
}),
}
/>;
18 changes: 18 additions & 0 deletions formatTest/unit_tests/input/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,21 @@ let v =
name: x->Option.map(x => {let y = x; y ++ y})
}}
/>;

<Component
prop={{
name: x ++ Option.map(x => {let y = x; y ++ y})
}}
/>;

<Component
prop={{
name: x##Option.map(x => {let y = x; y ++ y})
}}
/>;

<Component
prop={{
name: x |> Option.map(x => {let y = x; y ++ y})
}}
/>;
3 changes: 2 additions & 1 deletion src/reason-parser/reason_pprint_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3753,7 +3753,7 @@ let printer = object(self:'self)
{exp with pexp_loc = { exp.pexp_loc with loc_end = loc_end } }
in
makeList (
self#reset_request_braces#formatFunAppl
self#formatFunAppl
?prefix
~jsxAttrs:[]
~args
Expand Down Expand Up @@ -3967,6 +3967,7 @@ let printer = object(self:'self)
match self#simplest_expression x with
| Some se -> Simple se
| None ->
let self = self#reset_request_braces in
match x.pexp_desc with
| Pexp_apply (e, ls) -> (
let ls = List.map (fun (l,expr) -> (l, self#process_underscore_application expr)) ls in
Expand Down

0 comments on commit affdf4c

Please sign in to comment.