Uploaded image for project: 'Swift'
  1. Swift
  2. SR-2900

binary operator `==` cannot be applied to two MyEnum operands

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Xcode 8. Swift 3

      Description

      enum WeatherType {
          case cloudy(coverage: Int)
          case sunny
          case windy
      }
      let w = WeatherType.sunny
      if w == .sunny {} // error
      if WeatherType.sunny == w {} // error
      

      This seems unnecessarily severe. Use of `==` with enum instances is a natural convenience; in fact, it's kind of the point of enums. Telling me I can't do it just because some case has an associated value is a bit rough.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            mattneub Matt Neuburg
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: