Xcode 7.3: Swift file causes compiler crash

Originator:rsfinn
Number:rdar://25513941 Date Originated:2016-04-03
Status:Closed Resolved:
Product:Xcode Product Version:7.3
Classification:Crash Reproducible:Yes
 
A particular source file causes the Swift compiler to crash when building the project.  The file references some types (both enums and classes) that are included from Objective-C header files and then extended in Swift.

The crash occurs when type-checking the following statement:

            x = bounds.maxX - cardWidth - border - (gui.handVisible[player]) ? x_offset : 0

Comments

Fixed before Xcode 8.3.3

Using Xcode 8.3.3, converting the test project and making the minimal changes to two generic types to satisfy their conformance to Collection, it is possible to build the project without crashing. The key factor is the ternary expresssion in the line quoted above, which is parenthesized incorrectly for Swift precedence rules, so the outer expression attempts to subtract a Bool from a CGFloat. The Swift compiler in Xcode 8.3.3 correctly diagnoses this and gives an error rather than crashing.


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!