Syntax error testing Swift 3 enum value

Originator:james.walter.matthews
Number:rdar://27906400 Date Originated:18-Aug-2016 11:59 AM
Status:Open Resolved:
Product:Developer Tools Product Version:8.0 beta 6 (8S201h)
Classification: Reproducible:Yes
 
Summary:
It does not appear possible to have a boolean test (e.g. in an if statement) to see if a Swift enum has a certain simple value, if the enum type has values with associated information.

Steps to Reproduce:
Open the attached playground, which contains the code:

enum Storm {
    case Rain
    case Tropical(String)
}

let storm: Storm = .Rain
if storm == .Rain {
}


Expected Results:
The code compiles

Actual Results:
The next to last line triggers a syntax error: 

Binary operator '==' cannot be applied to operands of type Storm and '_'

Version:
Version 8.0 beta 6 (8S201h)

Notes:
The code gets a slightly different error, "Binary operator '==' cannot be applied to operands of type Storm and Storm", if the enum literal is fully qualified:

enum Storm {
    case Rain
    case Tropical(String)
}

let storm: Storm = .Rain
if storm == Storm.Rain {
}

The code compiles if there is no associated value, e.g.:

enum Storm {
    case Rain
    case Tropical
}

let storm: Storm = .Rain
if storm == .Rain {
}


Configuration:


Attachments:
'EnumAssociatedValue.playground.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!