Vague error description when trying to match an instance in a switch statement


#1

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.


(Quinn “The Eskimo!”) #2

Indeed. If you can file a bug about this, that’d be grand.

<https://bugs.swift.org/>

Share and Enjoy

···

On 15 Sep 2016, at 19:53, hello--- via swift-users <swift-users@swift.org> wrote:

It would be nice if the error message could be improved to spare confusion for
the other developers.

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware