Optional of type [T : Y]/[T] can not be compared to .None/.Some
| Originator: | morten | ||
| Number: | rdar://23124439 | Date Originated: | 15-Oct-2015 12:04 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Swift 2.1 / Xcode 7.1 beta 3 (7B85) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Given an optional array, dictionary or set it is not possible to do a “==“ comparison to Optional.None or Optional.Some
Steps to Reproduce:
1. Open a Playground
2. Write the following code
```
let dictionary: [String: AnyObject]? = nil
dictionary == .None
let array: [Bool]? = nil
array == .None
```
Expected Results:
dictionary == .None => true
array == .None => true
Actual Results:
dictionary == .None => Error: “Type of expression is ambiguous without more context”
array == .None => Error: “Type of expression is ambiguous without more context”
Notes:
If a `switch` statement is used it matches `.None` and `.Some` as expected.
Like this:
```
let dictionary: [String: AnyObject]? = nil
switch dictionary {
case .None: print("None")
case .Some: print("Some")
}
```
Also not working in Xcode 7.0(.1) - Swift 2.0
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!