Swift: frontend crashes with recursive typealias

Originator:rix.rob
Number:rdar://18405200 Date Originated:20-Sep-2014 09:05 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-Beta (6A1030)
Classification:Serious Bug Reproducible:Always
 
Summary:
If you have a protocol with an associated type that isn’t used in a method or something, you have to explicitly specify it with typealias in your conforming type. You cannot for example specify it with a type parameter of the same name, i.e.:

protocol P { typealias T }
struct S<T> : P {}

does not compile because S does not provide the associated type T.

One obvious thing to try is just `typealias T`, which also doesn’t compile because it doesn’t have `= …` following it.

The next thing to try is `typealias T = T`, which crashes the compiler.


Steps to Reproduce:
1. Compile this code:
struct S<T> {
	typealias T = T
}


Expected Results:
I didn’t really expect it to work but I certainly didn’t expect the compiler to crash.


Actual Results:
Among Swift’s weaponry are such diverse elements as fear, surprise, ruthless efficiency, and compiler crashes.


Regression:
If you do typealias T = T at the top level it correctly informs you that it’s a circular reference.


Notes:
This crash occurred while I was trying to reduce another crash that was in the way of what I’m trying to do. The yaks have gone recursive here, people!

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!