Swift: dictionaries containing dictionaries cannot be stored in an optional
| Originator: | kyle | ||
| Number: | rdar://17436899 | Date Originated: | 6/24/2014 |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | 6.0 |
| Classification: | Crash | Reproducible: | Always |
Summary:
In the Swift language, a Dictionary variable may contain, as a value, another Dictionary. However, if the variable is declared to be a Dictionary? (optional Dictionary) rather than a Dictionary, it will crash Xcode.
Steps to Reproduce:
1. Create an empty project
2. Add a Swift Playground file
3. Add the following line of code:
var x:Dictionary = ["foobar": [ "foo" : "bar" ]]
4. Now, add a ? after the word Dictionary, so the line reads
var x:Dictionary? = ["foobar": [ "foo" : "bar" ]]
5. Crash
Expected Results:
No crash. If a dictionary can contain a value (line 3), then an optional-wrapped dictionary should also (line 4)
Actual Results:
As soon as the file is parsed after making the variable declaration optional, Xcode crashes and disappears. The crash handler/exception reporter does not even show up.
Version:
Xcode 6.0-Beta2 (6A216f)
OS X 10.9.3
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!