Swift 1.2b2: Compiler crash with recursive function returning coalesced optional returns and .map

Originator:rix.rob
Number:rdar://19925136 Date Originated:23-Feb-2015 03:00 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (6D532l)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
See below.


Steps to Reproduce:
1. Compile this:
func next<T>(outer: () -> ()?, inner: () -> T?) -> T? {
	return inner() ?? outer().map { _ in next(outer, inner) } ?? nil
}


Expected Results:
Successful compilation.


Actual Results:
Crash.


Regression:
This has regressed since 1.2b1.

I’m aware of two workarounds:

1. Use `if` statements instead of nil coalescing.
2. Change outer to return `Bool` and use a ternary instead of nil coalescing.


Notes:
N/A

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!