Xcode-beta (7A121l): Swift cannot find members for the result of inlined lambdas with branches

Originator:owensd
Number:rdar://21675896 Date Originated:05-Jul-2015 12:04 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A121l)
Classification:Other Bug Reproducible:Always
 
Given the following code:

    let file = "path/to/foo.swift"

    let x: String = {
        if file.pathExtension == "swift" {
            return file.stringByDeletingLastPathComponent
        }
        else {
            return file
        }
    }().pathExtension

This results in a compiler error: “Could not find member ‘pathExtension’.”

However, this simplified version works:

    let file = "path/to/foo.swift"

    let x: String = {
        return file.stringByDeletingLastPathComponent
    }().pathExtension

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!