Swift 1.2b1: Compiler crashes doing IR generation for Equatable struct’s == function with booleans & things

Originator:rix.rob
Number:rdar://19791100 Date Originated:10-Feb-2015 08:40 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-Beta (6D520o)
Classification:Serious Bug Reproducible:Always
 
Summary:
Trying to implement equality over an Equatable struct with a dictionary of ints to arrays of ints crashes the compiler.


Steps to Reproduce:
1. Attempt to compile this code:

struct A: Equatable {
	var v: [Int: [Int]]
}

func == <T> (left: A, right: A) -> Bool {
	return reduce(map(Set(left.v.keys).union(right.v.keys)) {
			(left.v[$0] ?? []) == (right.v[$0] ?? [])
		}, true) { $0 && $1 }
}



Expected Results:
“Build succeeded”


Actual Results:
S̢҉̴̢͍̤̬͙͔̝̮̳̱̻̪͕͍̱̟́ͅĮ̫̲̯͓̦̥͙̦̝̗̘̝͘͜G̩̤̻̪̤̭͕̠̹̩͚͙͔̀͘ͅS̶̢̳͎̻̗̠̥̖͓͚̼̘̟̟͈̜̗̳̺͍̀E̶̴̴͓̝͈̪̻̠̣̮̣͓̲̘̣̱̳͈̤̝͖͘͜G̛̺̖͓̥̟̦͓̭͎̲͉͘͘V̷̢̻̮̝̩̺̻̟͖̰̮̼̥̼





(Compiler crash in swift::irgen::emitPolymorphicArguments.)

Regression:
It doesn’t crash if you remove the struct’s conformance to Equatable.


Notes:
This is a blocker for me at present and I don’t have a good workaround yet. I am writing this struct at all (vs. using raw dictionaries) because I need the thing to be Equatable, and it can’t be Equatable because Swift can’t express constrained extensions.

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!