Skip to content

[SR-14529] swift-format-ignore inside switch causes linter to crash #309

Open
@swift-ci

Description

@swift-ci
Previous ID SR-14529
Radar None
Original Reporter afannin (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: 7cb3c42b9551dc52aa2896c609bb2f3e

Issue Description:

Adding // swift-format-ignore inside a case in a switch statement causes the linter to crash with the following message:

Fatal error: At least one .break(.open) was not matched by a .break(.close): file SwiftFormatPrettyPrint/PrettyPrint.swift, line 689

Example code that causes the crash is below (running swift-format -r -m lint .):

class Test {
 enum FooBar: String {
     case foo
     case bar
 }
 
 func myFunc(_ val: FooBar) {
     switch val {
     case .foo:
         // swift-format-ignore
         print("Foo")
     case .bar:
         print("Bar")
     }
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions