Skip to content

Commit f828fb5

Browse files
authored
Sync latest syntax (#6016)
1 parent f76ee88 commit f828fb5

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
- Fix issue in `Js.Promise2` where `then` and `catch` were returning `undefined` https://github.com/rescript-lang/rescript-compiler/pull/5996
3030
- Fix issue in the compiler back-end where async functions passed to an `@uncurry` external would be inlined and transformed in a way that loses async https://github.com/rescript-lang/rescript-compiler/pull/6011
3131
- Fix location issue for the treatment of `async` functions where hovering on the body with a type error would show `'a => promise<'a>` everywhere https://github.com/rescript-lang/rescript-compiler/pull/6014
32+
- Fix formatting of `switch` expressions that contain braced `cases` inside https://github.com/rescript-lang/syntax/pull/735
33+
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/syntax/pull/736
3234

3335
#### :rocket: New Feature
3436

jscomp/napkin/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
- Fix support for recursive components in JSX V4 https://github.com/rescript-lang/syntax/pull/733
6363
- Fix issue with overlapping labelled argument with default value https://github.com/rescript-lang/syntax/pull/734
6464
- Fix issue with using alias and default value together https://github.com/rescript-lang/syntax/pull/734
65+
- Fix formatting of `switch` expressions that contain braced `cases` inside https://github.com/rescript-lang/syntax/pull/735
66+
- Fix formatting of props spread for multiline JSX expression https://github.com/rescript-lang/syntax/pull/736
6567

6668
#### :eyeglasses: Spec Compliance
6769

lib/4.06.1/unstable/js_compiler.ml

+12-3
Original file line numberDiff line numberDiff line change
@@ -50599,7 +50599,13 @@ let getLoc node =
5059950599
let open Parsetree in
5060050600
match node with
5060150601
| Case case ->
50602-
{case.pc_lhs.ppat_loc with loc_end = case.pc_rhs.pexp_loc.loc_end}
50602+
{
50603+
case.pc_lhs.ppat_loc with
50604+
loc_end =
50605+
(match ParsetreeViewer.processBracesAttr case.pc_rhs with
50606+
| None, _ -> case.pc_rhs.pexp_loc.loc_end
50607+
| Some ({loc}, _), _ -> loc.Location.loc_end);
50608+
}
5060350609
| CoreType ct -> ct.ptyp_loc
5060450610
| ExprArgument expr -> (
5060550611
match expr.Parsetree.pexp_attributes with
@@ -57439,7 +57445,7 @@ and printJsxProp ~customLayout arg cmtTbl =
5743957445
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
5744057446
| Asttypes.Labelled "_spreadProps", expr ->
5744157447
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
57442-
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
57448+
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
5744357449
| lbl, expr ->
5744457450
let argLoc, expr =
5744557451
match expr.pexp_attributes with
@@ -57845,7 +57851,10 @@ and printCases ~customLayout (cases : Parsetree.case list) cmtTbl =
5784557851
~getLoc:(fun n ->
5784657852
{
5784757853
n.Parsetree.pc_lhs.ppat_loc with
57848-
loc_end = n.pc_rhs.pexp_loc.loc_end;
57854+
loc_end =
57855+
(match ParsetreeViewer.processBracesAttr n.pc_rhs with
57856+
| None, _ -> n.pc_rhs.pexp_loc.loc_end
57857+
| Some ({loc}, _), _ -> loc.Location.loc_end);
5784957858
})
5785057859
~print:(printCase ~customLayout) ~nodes:cases cmtTbl;
5785157860
];

lib/4.06.1/unstable/js_playground_compiler.ml

+12-3
Original file line numberDiff line numberDiff line change
@@ -50599,7 +50599,13 @@ let getLoc node =
5059950599
let open Parsetree in
5060050600
match node with
5060150601
| Case case ->
50602-
{case.pc_lhs.ppat_loc with loc_end = case.pc_rhs.pexp_loc.loc_end}
50602+
{
50603+
case.pc_lhs.ppat_loc with
50604+
loc_end =
50605+
(match ParsetreeViewer.processBracesAttr case.pc_rhs with
50606+
| None, _ -> case.pc_rhs.pexp_loc.loc_end
50607+
| Some ({loc}, _), _ -> loc.Location.loc_end);
50608+
}
5060350609
| CoreType ct -> ct.ptyp_loc
5060450610
| ExprArgument expr -> (
5060550611
match expr.Parsetree.pexp_attributes with
@@ -57439,7 +57445,7 @@ and printJsxProp ~customLayout arg cmtTbl =
5743957445
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
5744057446
| Asttypes.Labelled "_spreadProps", expr ->
5744157447
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
57442-
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
57448+
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
5744357449
| lbl, expr ->
5744457450
let argLoc, expr =
5744557451
match expr.pexp_attributes with
@@ -57845,7 +57851,10 @@ and printCases ~customLayout (cases : Parsetree.case list) cmtTbl =
5784557851
~getLoc:(fun n ->
5784657852
{
5784757853
n.Parsetree.pc_lhs.ppat_loc with
57848-
loc_end = n.pc_rhs.pexp_loc.loc_end;
57854+
loc_end =
57855+
(match ParsetreeViewer.processBracesAttr n.pc_rhs with
57856+
| None, _ -> n.pc_rhs.pexp_loc.loc_end
57857+
| Some ({loc}, _), _ -> loc.Location.loc_end);
5784957858
})
5785057859
~print:(printCase ~customLayout) ~nodes:cases cmtTbl;
5785157860
];

lib/4.06.1/whole_compiler.ml

+12-3
Original file line numberDiff line numberDiff line change
@@ -226571,7 +226571,13 @@ let getLoc node =
226571226571
let open Parsetree in
226572226572
match node with
226573226573
| Case case ->
226574-
{case.pc_lhs.ppat_loc with loc_end = case.pc_rhs.pexp_loc.loc_end}
226574+
{
226575+
case.pc_lhs.ppat_loc with
226576+
loc_end =
226577+
(match ParsetreeViewer.processBracesAttr case.pc_rhs with
226578+
| None, _ -> case.pc_rhs.pexp_loc.loc_end
226579+
| Some ({loc}, _), _ -> loc.Location.loc_end);
226580+
}
226575226581
| CoreType ct -> ct.ptyp_loc
226576226582
| ExprArgument expr -> (
226577226583
match expr.Parsetree.pexp_attributes with
@@ -233411,7 +233417,7 @@ and printJsxProp ~customLayout arg cmtTbl =
233411233417
| Optional _lbl -> Doc.concat [Doc.question; printIdentLike ident])
233412233418
| Asttypes.Labelled "_spreadProps", expr ->
233413233419
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
233414-
Doc.concat [Doc.lbrace; Doc.dotdotdot; Doc.softLine; doc; Doc.rbrace]
233420+
Doc.concat [Doc.lbrace; Doc.dotdotdot; doc; Doc.rbrace]
233415233421
| lbl, expr ->
233416233422
let argLoc, expr =
233417233423
match expr.pexp_attributes with
@@ -233817,7 +233823,10 @@ and printCases ~customLayout (cases : Parsetree.case list) cmtTbl =
233817233823
~getLoc:(fun n ->
233818233824
{
233819233825
n.Parsetree.pc_lhs.ppat_loc with
233820-
loc_end = n.pc_rhs.pexp_loc.loc_end;
233826+
loc_end =
233827+
(match ParsetreeViewer.processBracesAttr n.pc_rhs with
233828+
| None, _ -> n.pc_rhs.pexp_loc.loc_end
233829+
| Some ({loc}, _), _ -> loc.Location.loc_end);
233821233830
})
233822233831
~print:(printCase ~customLayout) ~nodes:cases cmtTbl;
233823233832
];

0 commit comments

Comments
 (0)