Swift ternary operator request space between ? character and the condition

Originator:jotel
Number:rdar://17646656 Date Originated:11-Jul-2014 10:55 PM
Status:Closed/Behaves correctly Resolved:15-Jul-2014 05:06 PM
Product:Developer Tools Product Version:Version 6.0 (6A254o)
Classification:Serious Bug Reproducible:Always
 
Summary:
The following expression is reported as error in Xcode Swift compilator

let test = true?"true":"false"

Steps to Reproduce:
1. Create any Swift file in Xcode project
2. Add the following line

let a = true?"true":"false"

3. Compile

Expected Results:
Compilation success

Actual Results:
Compilation erros:

test.swift:1:23: Consecutive statements on a line must be separated by ';'
test.swift:1:17: Expressions are not allowed at the top level
test.swift:1:23: Expected expression
test.swift:1:12: Operand of postfix '?' should have optional type; type is 'Bool'

Version:
Version 6.0 (6A254o)

Notes:
Workaround add space before ? character i.e.

let test = true ?"true":"false"

Configuration:


Attachments:
'test.swift' was successfully uploaded.

Comments

Response from Apple Developer Relations

Engineering has determined that this issue behaves as intended based on the following:

Swift's operator-parsing rules intentionally require this spacing.


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!