-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Open
Copy link
Labels
compilerThe Swift compiler itselfThe Swift compiler itself
Description
Previous ID | SR-12230 |
Radar | rdar://problem/59655515 |
Original Reporter | @jckarter |
Type | Task |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Task |
Assignee | None |
Priority | Medium |
md5: e162e203353a4b22da300ab68cf02876
Issue Description:
If you have a label mismatch in an enum case pattern like this:
enum Foo {
case foo(bar: Int)
case bar
}
func switchFoo(x: Foo) {
switch x {
case .foo(bas: let bas):
print("foo bas \(bas)")
case .bar:
print("bar")
}
}
then you get an error like this:
/Users/jgroff/foo.swift:10:13: error: tuple pattern element label 'bas' must be 'bar'
case .foo(bas: let bas):
^
But in the user's mental model, this isn't really a tuple pattern, they're trying to match against a particular enum case. Having an error with a note referring to the enum case would probably be easier to understand. Something like:
/Users/jgroff/foo.swift:10:13: error: enum type 'Foo' has no case named `foo(bas:)`, did you mean `foo(bar:)`?
case .foo(bas: let bas):
^
/Users/jgroff/foo.swift:2: note: case `foo(bar:)` declared here
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itself