Xcode Convert to Swift 1.2 does not handle nil-coalescing well
| Originator: | andrew | ||
| Number: | rdar://19779830 | Date Originated: | 2/10/2015 |
| Status: | Closed | Resolved: | Duplicate 19768761 |
| Product: | Developer Tools | Product Version: | 6.3 6D620o |
| Classification: | Other bug | Reproducible: | Always |
Summary: Code like this: self.name = jsonDictionary["name"] as? String ?? "default name string here" when run through the automated conversion to Swift 1.2 results in: self.name = jsonDictionary["name"] as? String ?? ; "default name string here" which is probably not what you want. More likely, you wanted this: self.name = (jsonDictionary["name"] as? String) ?? "default name string here" Steps to Reproduce: 1. Run code as outlined above through Convert to Swift 1.2 2. Observe the introduced ; breaks stuff Expected Results: self.name = (jsonDictionary["name"] as? String) ?? "default name string here" Actual Results: self.name = jsonDictionary["name"] as? String ?? ; "default name string here" Version: 6.3 (6D620o) Notes: Configuration: Attachments:
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!