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