Swift 1.2 CVarArgType array casting crash

Originator:keithbsmiley
Number:rdar://21435430 Date Originated:17-Jun-2015 09:12 PM
Status:Open Resolved:
Product:iOS SDK Product Version:8.3
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Converting an array of type `[String]` to a `[CVarArgType]` doesn't work as expected. Converting literal arrays works fine but converting existing array references crashes.

Steps to Reproduce:
See the attached playground.
1. let array = ["a", "b"].map { $0 as CVarArgType } // Works fine
2. let brokenArray = ["a", "b"]
3. brokenArray as [CVarArgType] // Doesn't work
4. brokenArray.map { $0 as CVarArgType } // Works fine

Expected Results:
You should be able to cast a `[String]` to `[CVarArgType]`

Actual Results:
You have to map the conversion over the array rather than casting with `as`

Comments

Example project here: https://github.com/keith/radars/tree/master/CVarArgTypeArrayIssue

By keithbsmiley at June 18, 2015, 4:14 a.m. (reply...)

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!