Combining multi-payload enums, type constraints, and generics leads to segfault
| Originator: | gordon | ||
| Number: | rdar://21341337 | Date Originated: | 11-Jun-2015 10:17 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Swift 2.0 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
If you create a multi-payload enum and give it a type constraint on one of the types, using that enum along with generics and a specific type results in a segfault.
Steps to Reproduce:
1. Create an enum and a protocol like so:
```swift
protocol Foo { }
enum Either<L: Foo, R> {
case Left(L)
case Right(R)
}
```
2. Create a simple function using the enum and generics:
```swift
func pure<T>(val: T) -> Either<Foo, T> {
return .Right(val)
}
```
Expected Results:
This should compile
Actual Results:
The compiler segfaults
Regression:
None
Notes:
Removing the type constraint or removing the generic type fixes the segfault. You can see the differences here:
https://gist.github.com/gfontenot/462b9cabfea700cccf3c
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!