Open
Description
Description
According to the document, if an enum case pattern includes a sub-pattern, it must be a tuple pattern, which should always be enclosed in parentheses.
enum-case-pattern → type-identifier?
.
enum-case-name tuple-pattern?
tuple-pattern →(
tuple-pattern-element-list?)
But, matching patterns like case .foo { true }:
is accepted.
Reproduction
func ~= <T>(_ lhs: () -> Bool, rhs: T) -> Bool { true }
enum E {
case foo(Int)
}
func test(v: E) {
switch v {
case .foo { true } : break
default: break
}
}
Expected behavior
Compiler should diagnose it, or documentation should be corrected to accept trailing closures.
Environment
Swift version 6.0.3
Additional information
No response