Confusing error message for closures that do not return value
Originator: | sforteln | ||
Number: | rdar://20962906 | Date Originated: | 14-May-2015 02:40 PM |
Status: | Open | Resolved: | Fixed in Xcode 7.1 beta 2 |
Product: | Developer Tools | Product Version: | Version 6.3.1 (6D1002) & Swift 1.2 |
Classification: | UI/Usability | Reproducible: | Always |
Summary: Provide a descriptive summary of the issue. Steps to Reproduce: In numbered format, detail the exact steps taken to produce the bug. See the gist https://gist.github.com/sforteln/e9fd7170a5126098af41 or attached playground for a full code example The scenario this bug is about is the last one /* If the closure has statements in it but no return you get the confusing error message : Cannot invoke 'filterMap' with an argument list of type '((String) -> Int?)' */ let transformedNoReturn : [Int] = array.filterMap({ (data: String) -> Int? in println("foo") }) Expected Results: Expected the error for the transformedNoReturn scenario to be the same as for transformedEmptyClosure that is "Missing return in a closure expected to return 'Int?'" Actual Results: the actual error message for the transformedEmptyClosure scenario is “Cannot invoke 'filterMap' with an argument list of type '((String) -> Int?)’” Regression: This always occurs both in Xcode and Playgrounds using Xcode 6.3.1 and Swift 1.2 Notes: Provide additional information, such as references to related problems, workarounds and relevant 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!