mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Also avoid emitting the diagnostic for an out of place binding pattern if there's an existing fix on a parent call expression, as that's the real source of the failure. rdar://113025351
24 lines
699 B
Swift
24 lines
699 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
struct S {
|
|
enum E: Error {
|
|
case e(Int)
|
|
case f
|
|
}
|
|
}
|
|
|
|
func foo() throws {}
|
|
|
|
// rdar://113025351: Avoid emitting a separate diagnostic complaining that a
|
|
// 'let' cannot be nested in an expression, as it just adds noise.
|
|
func bar() throws {
|
|
do {
|
|
try foo()
|
|
} catch S.E(let x) {} // expected-error {{'S.E' cannot be constructed because it has no accessible initializers}}
|
|
}
|
|
|
|
func baz(_ x: S.E) {
|
|
if case S.E(let y) = x {} // expected-error {{'S.E' cannot be constructed because it has no accessible initializers}}
|
|
if case S.E(S.E.e(let y)) = x {} // expected-error {{'S.E' cannot be constructed because it has no accessible initializers}}
|
|
}
|