@@ -751,7 +751,7 @@ extension Parser {
751
751
let args = self . parseArgumentListElements (
752
752
pattern: pattern,
753
753
flavor: flavor. callArgumentFlavor,
754
- allowTrailingComma: experimentalFeatures . contains ( . trailingComma )
754
+ allowTrailingComma: true
755
755
)
756
756
let ( unexpectedBeforeRParen, rparen) = self . expect ( . rightParen)
757
757
@@ -788,7 +788,10 @@ extension Parser {
788
788
if self . at ( . rightSquare) {
789
789
args = [ ]
790
790
} else {
791
- args = self . parseArgumentListElements ( pattern: pattern, allowTrailingComma: false )
791
+ args = self . parseArgumentListElements (
792
+ pattern: pattern,
793
+ allowTrailingComma: true
794
+ )
792
795
}
793
796
let ( unexpectedBeforeRSquare, rsquare) = self . expect ( . rightSquare)
794
797
@@ -1021,7 +1024,10 @@ extension Parser {
1021
1024
if self . at ( . rightSquare) {
1022
1025
args = [ ]
1023
1026
} else {
1024
- args = self . parseArgumentListElements ( pattern: pattern, allowTrailingComma: false )
1027
+ args = self . parseArgumentListElements (
1028
+ pattern: pattern,
1029
+ allowTrailingComma: true
1030
+ )
1025
1031
}
1026
1032
let ( unexpectedBeforeRSquare, rsquare) = self . expect ( . rightSquare)
1027
1033
@@ -1313,7 +1319,10 @@ extension Parser {
1313
1319
let unexpectedBeforeRightParen : RawUnexpectedNodesSyntax ?
1314
1320
let rightParen : RawTokenSyntax ?
1315
1321
if leftParen != nil {
1316
- args = parseArgumentListElements ( pattern: pattern, allowTrailingComma: false )
1322
+ args = parseArgumentListElements (
1323
+ pattern: pattern,
1324
+ allowTrailingComma: true
1325
+ )
1317
1326
( unexpectedBeforeRightParen, rightParen) = self . expect ( . rightParen)
1318
1327
} else {
1319
1328
args = [ ]
@@ -1429,7 +1438,7 @@ extension Parser {
1429
1438
let ( unexpectedBeforeLParen, lparen) = self . expect ( . leftParen)
1430
1439
let elements = self . parseArgumentListElements (
1431
1440
pattern: pattern,
1432
- allowTrailingComma: experimentalFeatures . contains ( . trailingComma )
1441
+ allowTrailingComma: true
1433
1442
)
1434
1443
let ( unexpectedBeforeRParen, rparen) = self . expect ( . rightParen)
1435
1444
return RawTupleExprSyntax (
@@ -1730,7 +1739,7 @@ extension Parser {
1730
1739
arena: arena
1731
1740
)
1732
1741
)
1733
- } while keepGoing != nil && self . hasProgressed ( & loopProgress)
1742
+ } while keepGoing != nil && ! self . atCaptureListTerminator ( ) && self . hasProgressed ( & loopProgress)
1734
1743
}
1735
1744
// We were promised a right square bracket, so we're going to get it.
1736
1745
var unexpectedNodes = [ RawSyntax] ( )
@@ -1817,6 +1826,10 @@ extension Parser {
1817
1826
)
1818
1827
}
1819
1828
1829
+ mutating func atCaptureListTerminator( ) -> Bool {
1830
+ return self . at ( . rightSquare)
1831
+ }
1832
+
1820
1833
mutating func parseClosureCaptureSpecifiers( ) -> RawClosureCaptureSpecifierSyntax ? {
1821
1834
// Check for the strength specifier: "weak", "unowned", or
1822
1835
// "unowned(safe/unsafe)".
@@ -1928,7 +1941,7 @@ extension Parser {
1928
1941
}
1929
1942
1930
1943
mutating func atArgumentListTerminator( _ allowTrailingComma: Bool ) -> Bool {
1931
- return allowTrailingComma && self . at ( . rightParen)
1944
+ return allowTrailingComma && ( self . at ( . rightParen) || self . at ( . rightSquare ) )
1932
1945
}
1933
1946
}
1934
1947
@@ -2367,7 +2380,7 @@ extension Parser {
2367
2380
} else {
2368
2381
unexpectedPrePatternCase = nil
2369
2382
}
2370
- } while keepGoing != nil && self . hasProgressed ( & loopProgress)
2383
+ } while keepGoing != nil && ! self . atSwitchCaseListTerminator ( ) && self . hasProgressed ( & loopProgress)
2371
2384
}
2372
2385
let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
2373
2386
return RawSwitchCaseLabelSyntax (
@@ -2380,6 +2393,10 @@ extension Parser {
2380
2393
)
2381
2394
}
2382
2395
2396
+ mutating func atSwitchCaseListTerminator( ) -> Bool {
2397
+ return self . experimentalFeatures. contains ( . trailingComma) && self . at ( . colon)
2398
+ }
2399
+
2383
2400
/// Parse a switch case with a 'default' label.
2384
2401
mutating func parseSwitchDefaultLabel(
2385
2402
_ handle: RecoveryConsumptionHandle
0 commit comments