From cd1b24a47127e4fe69f03ae8ae4871a56b976fc3 Mon Sep 17 00:00:00 2001 From: Zheyu Zhang Date: Fri, 24 Feb 2023 17:51:19 +0800 Subject: [PATCH 1/2] fix formatting of jsx spread props --- src/res_printer.ml | 2 +- tests/printer/expr/expected/jsx.res.txt | 7 +++++++ tests/printer/expr/jsx.res | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/res_printer.ml b/src/res_printer.ml index f63bfa77..0ac8d4cc 100644 --- a/src/res_printer.ml +++ b/src/res_printer.ml @@ -4337,7 +4337,7 @@ and printJsxProp ~customLayout arg cmtTbl = | Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident]) | Asttypes.Labelled "_spreadProps", expr -> let doc = printExpressionWithComments ~customLayout expr cmtTbl in - Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace] + Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace] | lbl, expr -> let argLoc, expr = match expr.pexp_attributes with diff --git a/tests/printer/expr/expected/jsx.res.txt b/tests/printer/expr/expected/jsx.res.txt index bdc104ff..4b9e5f97 100644 --- a/tests/printer/expr/expected/jsx.res.txt +++ b/tests/printer/expr/expected/jsx.res.txt @@ -410,3 +410,10 @@ let v = let x = + +// https://github.com/rescript-lang/rescript-compiler/issues/6002 +let x = props => + diff --git a/tests/printer/expr/jsx.res b/tests/printer/expr/jsx.res index 4b96f6c9..95a7e14c 100644 --- a/tests/printer/expr/jsx.res +++ b/tests/printer/expr/jsx.res @@ -402,4 +402,11 @@ let v = -let x = \ No newline at end of file +let x = + +// https://github.com/rescript-lang/rescript-compiler/issues/6002 +let x = props => + \ No newline at end of file From b5e0e4cf1c24d4a85a24a1deeaa5127d2d4eabe7 Mon Sep 17 00:00:00 2001 From: Zheyu Zhang Date: Fri, 24 Feb 2023 20:19:34 +0800 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abc98cf..14c3b02f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ - Fix issue with overlapping labelled argument with default value https://github.com/rescript-lang/syntax/pull/734 - Fix issue with using alias and default value together https://github.com/rescript-lang/syntax/pull/734 - Fix formatting of `switch` expressions that contain braced `cases` inside https://github.com/rescript-lang/syntax/pull/735 +- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/syntax/pull/736 #### :eyeglasses: Spec Compliance