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

Swift 6 typed-throws unable to detect exhaustive catch statements #74555

Open
NachoSoto opened this issue Jun 19, 2024 · 0 comments
Open

Swift 6 typed-throws unable to detect exhaustive catch statements #74555

NachoSoto opened this issue Jun 19, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. typed throws Feature → error handling → throws & rethrows: Typed throws

Comments

@NachoSoto
Copy link
Contributor

Description

Consider the example below. Both Error.a and Error.b are caught, but the compiler is unable to infer that.

Reproduction

enum Error: Swift.Error {
  case a
  case b
}

func f() throws(Error) {
  throw .a
}

func g() {
  do {
    // Errors thrown from here are not handled because the enclosing catch is not exhaustive
    try f()
  } catch .a {
  } catch .b {
  }
}

Expected behavior

Code compiles

Environment

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0

Additional information

No response

@NachoSoto NachoSoto added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 19, 2024
@hborla hborla added typed throws Feature → error handling → throws & rethrows: Typed throws and removed triage needed This issue needs more specific labels labels Jul 14, 2024
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. typed throws Feature → error handling → throws & rethrows: Typed throws
Projects
None yet
Development

No branches or pull requests

2 participants