Files
swift-mirror/test/Constraints/rdar106598067.swift
Hamish Knight c6dd3ad839 [CS] Diagnose UnresolvedPatternExprs as part of constraint solving
Instead of diagnosing in CSApply, let's create a
fix and diagnose in the solver instead.
Additionally, make sure we assign ErrorTypes to
any VarDecls bound by the invalid pattern, which
fixes a crash.

rdar://110638279
2023-06-13 12:14:25 +01:00

13 lines
525 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// RUN: %target-typecheck-verify-swift
enum E: Error { case e }
// rdar://106598067 Make sure we don't crash.
// FIXME: We ought to have a tailored diagnostic to change to 'as' instead of 'as?'
let fn = {
do {} catch let x as? E {}
// expected-error@-1 {{pattern variable binding cannot appear in an expression}}
// expected-error@-2 {{expression pattern of type 'E?' cannot match values of type 'any Error'}}
// expected-warning@-3 {{'catch' block is unreachable because no errors are thrown in 'do' block}}
}