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 {
23612361 do {
23622362 var keepGoing : RawTokenSyntax ? = nil
23632363 var loopProgress = LoopProgressCondition ( )
2364+ var unexpectedPrePatternCase : RawUnexpectedNodesSyntax ? = nil
23642365 repeat {
23652366 let ( pattern, whereClause) = self . parseGuardedCasePattern ( )
23662367 keepGoing = self . consume ( if: . comma)
23672368 caseItems. append (
23682369 RawSwitchCaseItemSyntax (
2370+ unexpectedPrePatternCase,
23692371 pattern: pattern,
23702372 whereClause: whereClause,
23712373 trailingComma: keepGoing,
23722374 arena: self . arena
23732375 )
23742376 )
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+ }
23752386 } while keepGoing != nil && self . hasProgressed ( & loopProgress)
23762387 }
23772388 let ( unexpectedBeforeColon, colon) = self . expect ( . colon)
Original file line number Diff line number Diff line change @@ -1351,4 +1351,17 @@ final class SwitchTests: ParserTestCase {
13511351 """
13521352 )
13531353 }
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+ }
13541367}
You can’t perform that action at this time.
0 commit comments