Swift compiler crashes when self ownership is specified in closure in auto_closure

Originator:brian.nickel
Number:rdar://17219440 Date Originated:07-Jun-2014 06:34 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 6.0 (6A215l)
Classification: Reproducible:
 
Summary:
Background: I discovered that if I want to pass a complex closure into an auto_closure, I'll get an error but I can pass something like ({ ... })() meaning creating a closure then executing it immediately but we're in an auto_closure so it's delayed. :)

Anyway, I have one that references self, so I want to reset the ownership to unowned.  Doing so stops SourceKitService and segfaults the compiler.

Steps to Reproduce:
See the attached Xcode project.

Expected Results:
Code should compile.

Actual Results:
Segmentation fault.

Comments

Code sample from project

import Foundation

class Something {
    let nameLoader:() -> String
    init(name: @auto_closure () -> String) {
        nameLoader = name
    }

    var name:String {
    get {
        return nameLoader()
    }
    }
}

class Caller {
    var a = "a"
    var b = "b"
    var something:Something?

    init() {
        something = Something(name: ({[unowned(unsafe) self] in "\(self.a) \(self.b)"})())
    }

}
By brian.nickel at June 9, 2014, 4:04 p.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!