In the explanation of the new Typed Throws feature added in Swift 6.0, it is stated that opaque thrown error types can be used, as shown in the following code. I understood this feature to be similar to the Opaque Result Type of existing functions, where the compiler infers the concrete type based on the error type returned by the function.
func doSomething() throws(some Error) { ... }
However, when I wrote the following code, it did not compile and showed an error as in the picture below. Could anyone explain why this error occurs?
The code was executed on Xcode Version 16.0 beta 5 (16A5221g).
enum SampleError: Error {
case first
}
func throwSampleError() throws(some Error) {
throw SampleError.first
}