diff --git a/CHANGELOG.md b/CHANGELOG.md index c2b0737621..c87dbcc694 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/jscomp/syntax/src/res_parens.ml b/jscomp/syntax/src/res_parens.ml index 5fc2ab9ff8..4c699c9a31 100644 --- a/jscomp/syntax/src/res_parens.ml +++ b/jscomp/syntax/src/res_parens.ml @@ -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 diff --git a/jscomp/syntax/tests/printer/expr/expected/smartPipe.res.txt b/jscomp/syntax/tests/printer/expr/expected/smartPipe.res.txt index f67034fc4e..90b24b0144 100644 --- a/jscomp/syntax/tests/printer/expr/expected/smartPipe.res.txt +++ b/jscomp/syntax/tests/printer/expr/expected/smartPipe.res.txt @@ -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 diff --git a/jscomp/syntax/tests/printer/expr/smartPipe.res b/jscomp/syntax/tests/printer/expr/smartPipe.res index 0f1d03531f..2bc8183937 100644 --- a/jscomp/syntax/tests/printer/expr/smartPipe.res +++ b/jscomp/syntax/tests/printer/expr/smartPipe.res @@ -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