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

callAsFunction + rethrows is broken. #66236

Open
JessyCatterwaul opened this issue May 31, 2023 · 1 comment
Open

callAsFunction + rethrows is broken. #66236

JessyCatterwaul opened this issue May 31, 2023 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. error handling throw Feature → error handling: Throw statements

Comments

@JessyCatterwaul
Copy link

I don't remember if it ever worked. Paul Hudson's article says it did/should.

struct Struct {
  typealias Closure = () throws -> Void
  func ƒ(_: Closure) rethrows { }
  func callAsFunction(_: Closure) rethrows { }
}

Struct().ƒ { }
Struct() { } // Call can throw but is not marked with 'try'
@JessyCatterwaul JessyCatterwaul added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 31, 2023
@grynspan grynspan added error handling throw Feature → error handling: Throw statements labels May 31, 2023
@hborla hborla removed the triage needed This issue needs more specific labels label Apr 27, 2024
@JessyCatterwaul
Copy link
Author

While this is still broken in Swift 6, it doesn't really matter, because you can completely get around it using the new solution.

struct Struct {
  typealias Closure<Error> = () throws(Error) -> Void
  func ƒ(_: Closure<Error>) { }
  func callAsFunction(_: Closure<some Error>) { }
}
Struct().ƒ { }
Struct() { } // Compiles.

There are still some issues, e.g. #74273, but maybe rethrows should just be deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. error handling throw Feature → error handling: Throw statements
Projects
None yet
Development

No branches or pull requests

3 participants