Unexpected

Originator:gothick.fysh
Number:rdar://18198185 Date Originated:2 Sep 2014
Status:Closed Resolved:4 Sep 2014
Product:Developer Tools Product Version:Xcode 6 beta 6 6A280e
Classification: Reproducible:
 
(Resolved in beta 7)

When attempting to assign the result of the nil coalescing operator to an Optional value (implicitly unwrapped or not) I see an unexpected "Ambiguous Use of '??'" error from the Swift compiler.

Steps to Reproduce:
In Xcode 6 beta 6:

var foo: String?
var test: String?

// "Ambiguous use of '??'"
foo = test ?? "ValueIfNil"

(Playground attached).

Expected Results:
I'd expect that foo would be set to "ValueIfNil". If test had a value, I'd expect foo to be set to that value. I can see why this might be considered technical ambiguous, but the desired result of this code seems pretty obvious and unambiguous, so I'm guessing this is actually a bug.

Actual Results:
Compiler error.

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!