-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselferror handlingswift 6.2throws & rethrowsFeature → error handling: throws & rethrowsFeature → error handling: throws & rethrowstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistyped throwsFeature → error handling → throws & rethrows: Typed throwsFeature → error handling → throws & rethrows: Typed throwsunexpected errorBug: Unexpected errorBug: Unexpected error
Description
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
filiplazov, robertmryan, MartinColja, roopekv, MattHolgateSonos and 7 more
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselferror handlingswift 6.2throws & rethrowsFeature → error handling: throws & rethrowsFeature → error handling: throws & rethrowstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistyped throwsFeature → error handling → throws & rethrows: Typed throwsFeature → error handling → throws & rethrows: Typed throwsunexpected errorBug: Unexpected errorBug: Unexpected error