Skip to content

Commit 17b3dcd

Browse files
committed
One more syntax sync.
1 parent fd46313 commit 17b3dcd

File tree

2 files changed

+52
-20
lines changed

2 files changed

+52
-20
lines changed

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269911,6 +269911,7 @@ val hasOptionalAttribute : Parsetree.attributes -> bool
269911269911
val shouldIndentBinaryExpr : Parsetree.expression -> bool
269912269912
val shouldInlineRhsBinaryExpr : Parsetree.expression -> bool
269913269913
val hasPrintableAttributes : Parsetree.attributes -> bool
269914+
val filterPrintableAttributes : Parsetree.attributes -> Parsetree.attributes
269914269915
val partitionPrintableAttributes :
269915269916
Parsetree.attributes -> Parsetree.attributes * Parsetree.attributes
269916269917

@@ -270500,6 +270501,8 @@ let isPrintableAttribute attr =
270500270501

270501270502
let hasPrintableAttributes attrs = List.exists isPrintableAttribute attrs
270502270503

270504+
let filterPrintableAttributes attrs = List.filter isPrintableAttribute attrs
270505+
270503270506
let partitionPrintableAttributes attrs =
270504270507
List.partition isPrintableAttribute attrs
270505270508

@@ -275160,7 +275163,7 @@ val subBinaryExprOperand : string -> string -> bool
275160275163
val rhsBinaryExprOperand : string -> Parsetree.expression -> bool
275161275164
val flattenOperandRhs : string -> Parsetree.expression -> bool
275162275165

275163-
val lazyOrAssertExprRhs : Parsetree.expression -> kind
275166+
val lazyOrAssertOrAwaitExprRhs : Parsetree.expression -> kind
275164275167

275165275168
val fieldExpr : Parsetree.expression -> kind
275166275169

@@ -275364,7 +275367,7 @@ let flattenOperandRhs parentOperator rhs =
275364275367
| _ when ParsetreeViewer.isTernaryExpr rhs -> true
275365275368
| _ -> false
275366275369

275367-
let lazyOrAssertExprRhs expr =
275370+
let lazyOrAssertOrAwaitExprRhs expr =
275368275371
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
275369275372
match optBraces with
275370275373
| Some ({Location.loc = bracesLoc}, _) -> Braced bracesLoc
@@ -278742,7 +278745,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278742278745
| Pexp_assert expr ->
278743278746
let rhs =
278744278747
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
278745-
match Parens.lazyOrAssertExprRhs expr with
278748+
match Parens.lazyOrAssertOrAwaitExprRhs expr with
278746278749
| Parens.Parenthesized -> addParens doc
278747278750
| Braced braces -> printBraces doc expr braces
278748278751
| Nothing -> doc
@@ -278751,7 +278754,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278751278754
| Pexp_lazy expr ->
278752278755
let rhs =
278753278756
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
278754-
match Parens.lazyOrAssertExprRhs expr with
278757+
match Parens.lazyOrAssertOrAwaitExprRhs expr with
278755278758
| Parens.Parenthesized -> addParens doc
278756278759
| Braced braces -> printBraces doc expr braces
278757278760
| Nothing -> doc
@@ -278929,7 +278932,24 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
278929278932
in
278930278933
let exprWithAwait =
278931278934
if ParsetreeViewer.hasAwaitAttribute e.pexp_attributes then
278932-
Doc.concat [Doc.text "await "; printedExpression]
278935+
let rhs =
278936+
match
278937+
Parens.lazyOrAssertOrAwaitExprRhs
278938+
{
278939+
e with
278940+
pexp_attributes =
278941+
List.filter
278942+
(function
278943+
| {Location.txt = "res.await" | "ns.braces"}, _ -> false
278944+
| _ -> true)
278945+
e.pexp_attributes;
278946+
}
278947+
with
278948+
| Parens.Parenthesized -> addParens printedExpression
278949+
| Braced braces -> printBraces printedExpression e braces
278950+
| Nothing -> printedExpression
278951+
in
278952+
Doc.concat [Doc.text "await "; rhs]
278933278953
else printedExpression
278934278954
in
278935278955
let shouldPrintItsOwnAttributes =
@@ -279327,11 +279347,7 @@ and printBinaryExpression ~customLayout (expr : Parsetree.expression) cmtTbl =
279327279347
{
279328279348
expr with
279329279349
pexp_attributes =
279330-
List.filter
279331-
(fun attr ->
279332-
match attr with
279333-
| {Location.txt = "ns.braces"}, _ -> false
279334-
| _ -> true)
279350+
ParsetreeViewer.filterPrintableAttributes
279335279351
expr.pexp_attributes;
279336279352
}
279337279353
with

lib/4.06.1/whole_compiler.ml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275656,6 +275656,7 @@ val hasOptionalAttribute : Parsetree.attributes -> bool
275656275656
val shouldIndentBinaryExpr : Parsetree.expression -> bool
275657275657
val shouldInlineRhsBinaryExpr : Parsetree.expression -> bool
275658275658
val hasPrintableAttributes : Parsetree.attributes -> bool
275659+
val filterPrintableAttributes : Parsetree.attributes -> Parsetree.attributes
275659275660
val partitionPrintableAttributes :
275660275661
Parsetree.attributes -> Parsetree.attributes * Parsetree.attributes
275661275662

@@ -276245,6 +276246,8 @@ let isPrintableAttribute attr =
276245276246

276246276247
let hasPrintableAttributes attrs = List.exists isPrintableAttribute attrs
276247276248

276249+
let filterPrintableAttributes attrs = List.filter isPrintableAttribute attrs
276250+
276248276251
let partitionPrintableAttributes attrs =
276249276252
List.partition isPrintableAttribute attrs
276250276253

@@ -280905,7 +280908,7 @@ val subBinaryExprOperand : string -> string -> bool
280905280908
val rhsBinaryExprOperand : string -> Parsetree.expression -> bool
280906280909
val flattenOperandRhs : string -> Parsetree.expression -> bool
280907280910

280908-
val lazyOrAssertExprRhs : Parsetree.expression -> kind
280911+
val lazyOrAssertOrAwaitExprRhs : Parsetree.expression -> kind
280909280912

280910280913
val fieldExpr : Parsetree.expression -> kind
280911280914

@@ -281109,7 +281112,7 @@ let flattenOperandRhs parentOperator rhs =
281109281112
| _ when ParsetreeViewer.isTernaryExpr rhs -> true
281110281113
| _ -> false
281111281114

281112-
let lazyOrAssertExprRhs expr =
281115+
let lazyOrAssertOrAwaitExprRhs expr =
281113281116
let optBraces, _ = ParsetreeViewer.processBracesAttr expr in
281114281117
match optBraces with
281115281118
| Some ({Location.loc = bracesLoc}, _) -> Braced bracesLoc
@@ -284487,7 +284490,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
284487284490
| Pexp_assert expr ->
284488284491
let rhs =
284489284492
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
284490-
match Parens.lazyOrAssertExprRhs expr with
284493+
match Parens.lazyOrAssertOrAwaitExprRhs expr with
284491284494
| Parens.Parenthesized -> addParens doc
284492284495
| Braced braces -> printBraces doc expr braces
284493284496
| Nothing -> doc
@@ -284496,7 +284499,7 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
284496284499
| Pexp_lazy expr ->
284497284500
let rhs =
284498284501
let doc = printExpressionWithComments ~customLayout expr cmtTbl in
284499-
match Parens.lazyOrAssertExprRhs expr with
284502+
match Parens.lazyOrAssertOrAwaitExprRhs expr with
284500284503
| Parens.Parenthesized -> addParens doc
284501284504
| Braced braces -> printBraces doc expr braces
284502284505
| Nothing -> doc
@@ -284674,7 +284677,24 @@ and printExpression ~customLayout (e : Parsetree.expression) cmtTbl =
284674284677
in
284675284678
let exprWithAwait =
284676284679
if ParsetreeViewer.hasAwaitAttribute e.pexp_attributes then
284677-
Doc.concat [Doc.text "await "; printedExpression]
284680+
let rhs =
284681+
match
284682+
Parens.lazyOrAssertOrAwaitExprRhs
284683+
{
284684+
e with
284685+
pexp_attributes =
284686+
List.filter
284687+
(function
284688+
| {Location.txt = "res.await" | "ns.braces"}, _ -> false
284689+
| _ -> true)
284690+
e.pexp_attributes;
284691+
}
284692+
with
284693+
| Parens.Parenthesized -> addParens printedExpression
284694+
| Braced braces -> printBraces printedExpression e braces
284695+
| Nothing -> printedExpression
284696+
in
284697+
Doc.concat [Doc.text "await "; rhs]
284678284698
else printedExpression
284679284699
in
284680284700
let shouldPrintItsOwnAttributes =
@@ -285072,11 +285092,7 @@ and printBinaryExpression ~customLayout (expr : Parsetree.expression) cmtTbl =
285072285092
{
285073285093
expr with
285074285094
pexp_attributes =
285075-
List.filter
285076-
(fun attr ->
285077-
match attr with
285078-
| {Location.txt = "ns.braces"}, _ -> false
285079-
| _ -> true)
285095+
ParsetreeViewer.filterPrintableAttributes
285080285096
expr.pexp_attributes;
285081285097
}
285082285098
with

0 commit comments

Comments
 (0)