Swift: compiler hangs trying to derive a type from an arithmetic expression

Originator:t.nick.a
Number:rdar://17569160 Date Originated:06-Jul-2014 03:59 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.0 (6A216f)
Classification:Hang Reproducible:Always
 
Summary:
There is an issue with compilation of fairly long arithmetic expressions. Code containing expressions up to 5 operands is compiled instantly, 6 or 7 takes like up to minute to compile, 8 takes few minutes, and 9 seems to take even more. Indexing also hangs in Xcode.

Important note: this only happens when a type should be derived from the expression.

Steps to Reproduce:
Create an empty project or a playground and enter this code:

let test = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9

Expected Results:
Code compiles fine, test is an Int constant with value of 45.

Actual Results:
Compilation hangs indefinitely.

Version:
Xcode 6.0 (6A216f), OS X 10.9.3 (13D65)

Notes:
The issue doesn't occur if the type is specified explicitly, i.e.:

let test: Int = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9

or:

func foobar(test: Int) { print(test) }
foobar(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9)

Configuration:
Tested in OSX 10.9.3 running on MacBook Pro, Late 2013.

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!