File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2361,17 +2361,28 @@ extension Parser {
2361
2361
do {
2362
2362
var keepGoing : RawTokenSyntax ? = nil
2363
2363
var loopProgress = LoopProgressCondition ( )
2364
+ var unexpectedPrePatternCase : RawUnexpectedNodesSyntax ? = nil
2364
2365
repeat {
2365
2366
let ( pattern, whereClause) = self . parseGuardedCasePattern ( )
2366
2367
keepGoing = self . consume ( if: . comma)
2367
2368
caseItems. append (
2368
2369
RawSwitchCaseItemSyntax (
2370
+ unexpectedPrePatternCase,
2369
2371
pattern: pattern,
2370
2372
whereClause: whereClause,
2371
2373
trailingComma: keepGoing,
2372
2374
arena: self . arena
2373
2375
)
2374
2376
)
2377
+
2378
+ if keepGoing != nil , let caseToken = self . consume ( if: . keyword( . case) ) {
2379
+ unexpectedPrePatternCase = RawUnexpectedNodesSyntax (
2380
+ elements: [ RawSyntax ( caseToken) ] ,
2381
+ arena: self . arena
2382
+ )
2383
+ } else {
2384
+ unexpectedPrePatternCase = nil
2385
+ }
2375
2386
} while keepGoing != nil && self . hasProgressed ( & loopProgress)
2376
2387
}
2377
2388
let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
Original file line number Diff line number Diff line change @@ -1351,4 +1351,17 @@ final class SwitchTests: ParserTestCase {
1351
1351
"""
1352
1352
)
1353
1353
}
1354
+
1355
+ func testSwitch84( ) {
1356
+ assertParse (
1357
+ """
1358
+ switch x {
1359
+ case 1, 1️⃣case 2, 3:
1360
+ }
1361
+ """ ,
1362
+ diagnostics: [
1363
+ DiagnosticSpec ( message: " unexpected 'case' keyword in switch case " )
1364
+ ]
1365
+ )
1366
+ }
1354
1367
}
You can’t perform that action at this time.
0 commit comments