[swift-users] Vague error description when trying to match an instance in a switch statement
hello at jtorhoff.com
hello at jtorhoff.com
Thu Sep 15 13:53:07 CDT 2016
The following code
struct A {}
let x = A()
let y = A()
switch x {
case y:
break
default:
break
}
produces "error: expression pattern of type 'A' cannot match values of
type 'A'".
This is kind of a vague description of what is really going on,
the compiler actually expects A to adopt Equatable protocol.
I'm using:
Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
Target: x86_64-apple-macosx10.9
I wasn't sure where to post this.
It would be nice if the error message could be improved to spare
confusion for
the other developers.
More information about the swift-users
mailing list