Xcode-beta (7A152u): Computed properties cannot throw

Originator:marco
Number:rdar://21832719 Date Originated:15-Jul-2015 12:00 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A152u)
Classification:Other Bug Reproducible:Always
 
This is a duplicate of rdar://21820924

I want some computed properties in Swift that can throw, however, that doesn’t seem possible.

    func g(value: Int) throws -> Int { return value }

    struct F {
        var id: Int {
            get { try g(0) }  // error, cannot throw
        }
    }

I’ve found no way to mark this property as “throwable”.

I expect to be able to to this:

    var id: Int throws {
        get { try g(0) }
    }

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!