Skip to content

Conversation

@DougGregor
Copy link
Member

The type that is caught by the catch clauses in a do..catch block is determined by the union of the thrown error types in the do statement. Compute this type and use it for the catch clauses. This does several things at once:

  • Makes the type of the implicit error be a more-specific concrete type when all throwing sites throw that same type
  • When there's a concrete type for the error, one can use patterns like .cancelled
  • Check that this error type can be rethrown in the current context
  • Verify that SIL generation involving do..catch with typed errors doesn't require any existentials.

…lock.

The type that is caught by the `catch` clauses in a `do..catch` block is
determined by the union of the thrown error types in the `do`
statement. Compute this type and use it for the catch clauses. This
does several things at once:

* Makes the type of the implicit `error` be a more-specific concrete
type when all throwing sites throw that same type
* When there's a concrete type for the error, one can use patterns
like `.cancelled`
* Check that this error type can be rethrown in the current context
* Verify that SIL generation involving do..catch with typed errors
doesn't require any existentials.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 698cfb9 into swiftlang:main Oct 5, 2023
@DougGregor DougGregor deleted the typed-do-catch branch October 5, 2023 12:06
@DougGregor DougGregor mentioned this pull request Oct 5, 2023
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant