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

Originator:owensd
Number:rdar://21820924 Date Originated:14-Jul-2015 01:54 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A152u)
Classification:Other Bug Reproducible:Always
 
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!