Files
swift-mirror/test/Constraints/rdar113025351.swift
Hamish Knight 2210ea6856 [CS] Avoid emitting invalid binding diagnostic in more cases
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
2023-07-28 11:22:27 +01:00

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}}
}