Xcode-Beta (6D520o): Swift for-pattern loop should not require () for mutatable item

Originator:owensd
Number:rdar://19871275 Date Originated:17-Feb-2015 09:26 PM
Status:Closed Resolved:Fixed
Product:Developer Tools Product Version:Xcode-Beta (6D520o)
Classification:Serious Bug Reproducible:Always
 
The for-pattern should allow mutable var without requiring parens.

    let items = [obj1, obj2, obj3]
    for var item in items {
        items.foo = 12
    }

However, the required syntax is:

    let items = [obj1, obj2, obj3]
    for (var item) in items {
        items.foo = 12
    }

This seems like a parser bug.

Especially when these two forms are allowed:

    for var i = 0, j = 0; i < 10 && j > -10; i++, j-- {
        println("\(i), \(j)")
    }

And

    for (var i = 0, j = 0; i < 10 && j > -10; i++, j--) {
        println("\(i), \(j)")
    }

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!