Swift 1.2b2: Compiler crash evaluating three nil coalesced expressions with a map lacking arguments
| Originator: | rix.rob | ||
| Number: | rdar://19924870 | Date Originated: | 23-Feb-2015 02:45 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (6D532l) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
Weird corner case.
Steps to Reproduce:
1. Compile this:
func unit<T>(x: T) -> T? { return x }
func f() -> Int? {
return unit(1) ?? unit(2).map { 1 } ?? nil
}
Expected Results:
A clear error describing the fact that I’m passing () -> IntegerLiteralConvertible to map which expects Int -> Int.
Actual Results:
The compiler crashed.
Regression:
It doesn’t crash if you:
- remove the map
- only use two operands, and not three
It still crashes but doesn’t dump the stack trace if you use `unit(1)` as the third expression instead of nil:
return unit(1) ?? unit(2).map { 1 } ?? unit(1)
It hangs the front-end outright (indefinitely) if you do that and also place the map on the first expression:
return unit(1).map { 1 } ?? unit(1) ?? unit(1)
Notes:
This makes it look like the new front-end is a bit buggy too.
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!