File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2689,6 +2689,9 @@ extension Parser {
26892689 } else if allowStandaloneStmtRecovery && ( self . atStartOfExpression ( ) || self . atStartOfStatement ( ) || self . atStartOfDeclaration ( ) ) {
26902690 // Synthesize a label for the stamenent or declaration that isn't coverd by a case right now.
26912691 let statements = parseSwitchCaseBody ( )
2692+ if statements. isEmpty {
2693+ break
2694+ }
26922695 elements. append (
26932696 . switchCase(
26942697 RawSwitchCaseSyntax (
Original file line number Diff line number Diff line change @@ -1231,4 +1231,15 @@ final class StatementExpressionTests: XCTestCase {
12311231 ]
12321232 )
12331233 }
1234+
1235+ func testStandaloneAtCaseInSwitch( ) {
1236+ AssertParse (
1237+ """
1238+ switch x {
1239+ 1️⃣@case
1240+ }
1241+ """ ,
1242+ diagnostics: [ DiagnosticSpec ( message: " unexpected code '@case' in 'switch' statement " ) ]
1243+ )
1244+ }
12341245}
You can’t perform that action at this time.
0 commit comments