File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -766,6 +766,9 @@ extension Parser {
766766 } else if allowStandaloneStmtRecovery && ( self . atStartOfExpression ( ) || self . atStartOfStatement ( ) || self . atStartOfDeclaration ( ) ) {
767767 // Synthesize a label for the stamenent or declaration that isn't coverd by a case right now.
768768 let statements = parseSwitchCaseBody ( )
769+ if statements. isEmpty {
770+ break
771+ }
769772 elements. append (
770773 . switchCase(
771774 RawSwitchCaseSyntax (
Original file line number Diff line number Diff line change @@ -618,4 +618,14 @@ final class StatementTests: XCTestCase {
618618 )
619619 }
620620
621+ func testStandaloneAtCaseInSwitch( ) {
622+ AssertParse (
623+ """
624+ switch x {
625+ 1️⃣@case
626+ }
627+ """ ,
628+ diagnostics: [ DiagnosticSpec ( message: " unexpected code '@case' in 'switch' statement " ) ]
629+ )
630+ }
621631}
You can’t perform that action at this time.
0 commit comments