Skip to content

hoistPatternLet --patternlet inline rule changes switch case from nil to let nil #940

@calda

Description

@calda

We're adopting the hoistPatternLet rule, with --patternlet inline, and I found a case where it causes a compile failure:

Before

let foo: String? = "foo"
let bar: String? = nil

switch (foo, bar) {
case let (.some(unwrapedFoo), nil):
  print(unwrapedFoo)
default:
  break
}

After running swiftformat . --rules hoistPatternLet --patternlet inline

let foo: String? = "foo"
let bar: String? = nil

switch (foo, bar) {
case (.some(let unwrapedFoo), let nil): // let nil is invalid
  print(unwrapedFoo)
default:
  break
}

Expected

let foo: String? = "foo"
let bar: String? = nil

switch (foo, bar) {
case (.some(let unwrapedFoo), nil):
  print(unwrapedFoo)
default:
  break
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfixed in developbug/feature resolved in the develop branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions