Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
calda opened this issue May 19, 2021 · 1 comment
Labels
bug fixed in develop bug/feature resolved in the develop branch

Comments

@calda
Copy link
Collaborator

calda commented May 19, 2021

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
}
@nicklockwood nicklockwood added bug fixed in develop bug/feature resolved in the develop branch labels May 19, 2021
@nicklockwood
Copy link
Owner

@calda fixed in 0.48.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in develop bug/feature resolved in the develop branch
Projects
None yet
Development

No branches or pull requests

2 participants