Binding same name variable work in "Apple Swift version 5.4.2" but not work in "Apple Swift version 5.5"

Install latest Xcode13 rc and set location to it.
Make sure swift --version echo "Apple Swift version 5.5".
Write below code in "demo.swift" and run swift ./demo.swift.

import Foundation

enum DoError: Error {
  case fail(String)
}

let error: Error = DoError.fail("20")
if case let .fail(num)  = error as? DoError,
    let num = Int(num) {
    print(num)
}

The terminal show:

...
Running pass 'Module Verifier' on function '@main'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it)

This work good when I use change "Location" to Xcode 12, it should print:

20

I encourage you to file a Swift bug about this. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Terms of Service

Privacy Policy

Cookie Policy