Trailing closures are wrongly accepted for enum-case-patterns #79047
Labels
accepts invalid
Bug: Accepts invalid
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
closures
Feature: closures
compiler
The Swift compiler itself
enum case patterns
Feature → patterns: Enumeration case patterns
patterns
Feature: patterns
Swift 6.2-dev
type checker
Area → compiler: Semantic analysis
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.
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/patterns/#Enumeration-Case-Pattern
But, matching patterns like
case .foo { true }:
is accepted.Reproduction
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
The text was updated successfully, but these errors were encountered: