Opaque thrown error types is not working

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
}

I think you should just simply omit the error type:

func throwSampleError() throws {
    throw SampleError.first
}

This works fine.

EDIT:
any Error also works as it is the actual default. That is what the second error is basically saying.

1 Like

Thank you for your response. I know there are other ways to solve the issue I mentioned, but I’m curious why the feature described in the official documentation isn’t working. Could it be a temporary bug?

1 Like

Sorry, I've misunderstood what you were saying.

Something similar has been reported Generic typed errors cannot be used without appearing outside the "`throws` argument". · Issue #74383 · swiftlang/swift · GitHub so I would assume it's a bug.

Thank you!