Skip to content

Fix parens removed in series of pipes for anonymous uncurried function #6766

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
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
- Fix indent in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6747
- In generated code, use `let` instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6102
- Turn off transformation for closures inside loops when capturing loop variables, now that `let` is emitted instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6480
- Fix formatter eats comments on the first argument of a uncurried function. https://github.com/rescript-lang/rescript-compiler/pull/6763
- Fix formatter removes parens in pipe operator with anonymous uncurried function. https://github.com/rescript-lang/rescript-compiler/pull/6766

# 11.1.0

Expand Down
1 change: 1 addition & 0 deletions jscomp/syntax/src/res_parens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ let flattenOperandRhs parentOperator rhs =
let precParent = ParsetreeViewer.operatorPrecedence parentOperator in
let precChild = ParsetreeViewer.operatorPrecedence operator in
precParent >= precChild || rhs.pexp_attributes <> []
| Pexp_construct ({txt = Lident "Function$"}, Some _) -> true
| Pexp_constraint ({pexp_desc = Pexp_pack _}, {ptyp_desc = Ptyp_package _}) ->
false
| Pexp_fun _ when ParsetreeViewer.isUnderscoreApplySugar rhs -> false
Expand Down
8 changes: 8 additions & 0 deletions jscomp/syntax/tests/printer/expr/expected/smartPipe.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ let messages = React.useMemo(() =>
->Array.filter(ChatMessage.isVisibleInSimpleFilter)
->Array.toSorted(ChatMessage.compareByDateAsc)
, [messagesById])

f->(v => g(x))->g

f->v->g

x->(v => g(x))->f->(v => g(x)->k)->g

f->(v => g(x)->k->(x => s(x)))->g
7 changes: 7 additions & 0 deletions jscomp/syntax/tests/printer/expr/smartPipe.res
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ let messages = React.useMemo(() =>
->Array.toSorted(ChatMessage.compareByDateAsc)
, [messagesById])

f->(v => g(x))->g

f->(v)->g

x->(v => g(x))->f->(v => g(x)->k)->g

f->(v => g(x)->k->(x => s(x)))->g
Loading