Skip to content

Commit 71c44a8

Browse files
authored
Sync latest syntax. (#5775)
1 parent 0a6ec41 commit 71c44a8

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#### :bug: Bug Fix
2020

2121
- Fix issue where the last line of `rescript format --help` usage was being swallowed https://github.com/rescript-lang/rescript-compiler/pull/5760
22+
- Specialize the printing of the rhs of a record field assignment for optional values `{x: ? e}` https://github.com/rescript-lang/syntax/issues/714
2223

2324
# 10.1.0-rc.3
2425

jscomp/napkin/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
- Change the internal representation of props for the lowercase components to record. https://github.com/rescript-lang/syntax/pull/665
6262
- Change the payload of Pconst_char for type safety. https://github.com/rescript-lang/rescript-compiler/pull/5759
63+
- Specialize the printing of the rhs of a record field assignment for optional values `{x: ? e}` https://github.com/rescript-lang/syntax/issues/714
6364

6465
## ReScript 10.0
6566

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52172,6 +52172,8 @@ val arrowReturnTypExpr : Parsetree.core_type -> bool
5217252172

5217352173
val patternRecordRowRhs : Parsetree.pattern -> bool
5217452174

52175+
val exprRecordRowRhs : Parsetree.expression -> kind
52176+
5217552177
end = struct
5217652178
#1 "res_parens.ml"
5217752179
module ParsetreeViewer = Res_parsetree_viewer
@@ -52191,6 +52193,16 @@ let expr expr =
5219152193
| {pexp_desc = Pexp_constraint _} -> Parenthesized
5219252194
| _ -> Nothing)
5219352195

52196+
let exprRecordRowRhs e =
52197+
let kind = expr e in
52198+
match kind with
52199+
| Nothing when Res_parsetree_viewer.hasOptionalAttribute e.pexp_attributes
52200+
-> (
52201+
match e.pexp_desc with
52202+
| Pexp_ifthenelse _ | Pexp_fun _ -> Parenthesized
52203+
| _ -> kind)
52204+
| _ -> kind
52205+
5219452206
let callExpr expr =
5219552207
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
5219652208
match optBraces with
@@ -58265,7 +58277,7 @@ and printExpressionRecordRow ~customLayout (lbl, expr) cmtTbl punningAllowed =
5826558277
Doc.text ": ";
5826658278
printOptionalLabel expr.pexp_attributes;
5826758279
(let doc = printExpressionWithComments ~customLayout expr cmtTbl in
58268-
match Parens.expr expr with
58280+
match Parens.exprRecordRowRhs expr with
5826958281
| Parens.Parenthesized -> addParens doc
5827058282
| Braced braces -> printBraces doc expr braces
5827158283
| Nothing -> doc);

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52172,6 +52172,8 @@ val arrowReturnTypExpr : Parsetree.core_type -> bool
5217252172

5217352173
val patternRecordRowRhs : Parsetree.pattern -> bool
5217452174

52175+
val exprRecordRowRhs : Parsetree.expression -> kind
52176+
5217552177
end = struct
5217652178
#1 "res_parens.ml"
5217752179
module ParsetreeViewer = Res_parsetree_viewer
@@ -52191,6 +52193,16 @@ let expr expr =
5219152193
| {pexp_desc = Pexp_constraint _} -> Parenthesized
5219252194
| _ -> Nothing)
5219352195

52196+
let exprRecordRowRhs e =
52197+
let kind = expr e in
52198+
match kind with
52199+
| Nothing when Res_parsetree_viewer.hasOptionalAttribute e.pexp_attributes
52200+
-> (
52201+
match e.pexp_desc with
52202+
| Pexp_ifthenelse _ | Pexp_fun _ -> Parenthesized
52203+
| _ -> kind)
52204+
| _ -> kind
52205+
5219452206
let callExpr expr =
5219552207
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
5219652208
match optBraces with
@@ -58265,7 +58277,7 @@ and printExpressionRecordRow ~customLayout (lbl, expr) cmtTbl punningAllowed =
5826558277
Doc.text ": ";
5826658278
printOptionalLabel expr.pexp_attributes;
5826758279
(let doc = printExpressionWithComments ~customLayout expr cmtTbl in
58268-
match Parens.expr expr with
58280+
match Parens.exprRecordRowRhs expr with
5826958281
| Parens.Parenthesized -> addParens doc
5827058282
| Braced braces -> printBraces doc expr braces
5827158283
| Nothing -> doc);

lib/4.06.1/whole_compiler.ml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228144,6 +228144,8 @@ val arrowReturnTypExpr : Parsetree.core_type -> bool
228144228144

228145228145
val patternRecordRowRhs : Parsetree.pattern -> bool
228146228146

228147+
val exprRecordRowRhs : Parsetree.expression -> kind
228148+
228147228149
end = struct
228148228150
#1 "res_parens.ml"
228149228151
module ParsetreeViewer = Res_parsetree_viewer
@@ -228163,6 +228165,16 @@ let expr expr =
228163228165
| {pexp_desc = Pexp_constraint _} -> Parenthesized
228164228166
| _ -> Nothing)
228165228167

228168+
let exprRecordRowRhs e =
228169+
let kind = expr e in
228170+
match kind with
228171+
| Nothing when Res_parsetree_viewer.hasOptionalAttribute e.pexp_attributes
228172+
-> (
228173+
match e.pexp_desc with
228174+
| Pexp_ifthenelse _ | Pexp_fun _ -> Parenthesized
228175+
| _ -> kind)
228176+
| _ -> kind
228177+
228166228178
let callExpr expr =
228167228179
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
228168228180
match optBraces with
@@ -234237,7 +234249,7 @@ and printExpressionRecordRow ~customLayout (lbl, expr) cmtTbl punningAllowed =
234237234249
Doc.text ": ";
234238234250
printOptionalLabel expr.pexp_attributes;
234239234251
(let doc = printExpressionWithComments ~customLayout expr cmtTbl in
234240-
match Parens.expr expr with
234252+
match Parens.exprRecordRowRhs expr with
234241234253
| Parens.Parenthesized -> addParens doc
234242234254
| Braced braces -> printBraces doc expr braces
234243234255
| Nothing -> doc);

0 commit comments

Comments
 (0)