mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If we have an identifier followed by either `[` or a generic argument list, avoid turning it into a binding pattern, as that would be invalid. This is similar to the existing rule we have where a following `(` prevents a binding pattern from being formed. This allows patterns such as `let E<Int>.foo(x)` and `let (y[0], x)` to compile, where `x` is treated as a binding, but no other identifier is. rdar://108738034
22 lines
349 B
Swift
22 lines
349 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// rdar://108738034: Make sure we can type-check this.
|
|
enum E<T>: Error {
|
|
case e(T)
|
|
}
|
|
|
|
struct S {
|
|
func bar(_: (Error?) -> Void) {}
|
|
}
|
|
|
|
func foo(_ s: S) {
|
|
s.bar { error in
|
|
guard let error = error else {
|
|
return
|
|
}
|
|
if case let E<Int>.e(y) = error {
|
|
print(y)
|
|
}
|
|
}
|
|
}
|