Files
swift-mirror/test/Constraints/rdar108738034.swift
Hamish Knight 6fffd96a18 [Parse] Avoid creating binding patterns in a couple more positions
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
2023-06-16 21:37:47 +01:00

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