Optional enum parameters in closures crash Swift compiler

Originator:invalidname
Number:rdar://19631066 Date Originated:1/28/15
Status:closed/duplicate Resolved:Duplicate of 18841652
Product:iOS SDK Product Version:6.1.1
Classification:crash Reproducible:always
 
Summary:
The use of optional enums as parameters to closures in Swift code (such as for completion handlers) crashes the Swift compiler with a segmentation fault

Steps to Reproduce:
Build the attached CompilerCrasherExperiment with Xcode 6.1.1. It's an iOS project with an EnumThing.swift file:
enum EnumThing {
    case Foo,
    Bar
}

func doSomething (completion: (thing: EnumThing?) -> Void) {
    completion (thing: .Foo)
}

which is then called from ViewController.viewDidLoad() as follows:

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        doSomething { (thing: EnumThing?) -> Void in
            let msg = thing == .Foo ? "Foo" : "Bar"
        }
    }



Expected Results:
When run, this should do nothing (although a breakpoint would allow you to see that the msg variable is being set in doSomething()).

Actual Results:
Crashes the Xcode build. Swift Compiler Error: Command failed due to signal: Segmentation fault: 11

(too much text to paste - will attach as CompileSwift-crash-log.txt)

Version:
Mac OS X 10.10.1 (14B25), Xcode Version 6.1.1 (6A2008a)

Notes:
I have found that using non-optional enums as parameters eliminates crashes like this.

I've had similar swiftc crashes passing structs as optionals, but don't have a buglet put together for that.

Configuration:
MacBook Pro (Retina, 15-inch, Late 2013)

Attachments:
'CompilerCrasherExperiment.zip' and 'CompileSwift-crash-log.txt' were successfully uploaded.

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!