Skip to content

Commit

Permalink
Fix braces removal in JSX props when having a pipe-first call contain…
Browse files Browse the repository at this point in the history
…ing a callback (#2474)

* Fix braces removal in JSX props when having a pipe-first call containing a callback

Made with the precious help from @anmonteiro

Closes #2471

* Add a test with another case where braces were removed
  • Loading branch information
bloodyowl authored and jordwalke committed Oct 29, 2019
1 parent e8d33b8 commit a8f7d90
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions formatTest/unit_tests/expected_output/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -658,3 +658,22 @@ let v =
}}
</B>
</A>;

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

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

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

<Component
prop={{
name: x->Option.map(x => {let y = x; y ++ y})
}}
/>;
2 changes: 1 addition & 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#formatFunAppl
self#reset_request_braces#formatFunAppl
?prefix
~jsxAttrs:[]
~args
Expand Down

0 comments on commit a8f7d90

Please sign in to comment.