Swift 1.2b2: Compiler crash in ArchetypeBuilder with recursive type constraints through protocol

Originator:rix.rob
Number:rdar://20000145 Date Originated:01-Mar-2015 01:50 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (6D532l)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Trying to make a fixpoint type while working around Swift’s lack of second order types.


Steps to Reproduce:
1. Compile this
public protocol P { typealias T }
public struct S<A: P where A.T == S<A>> {}


Expected Results:
I expected it to compile.


Actual Results:
Compiler crashes


Regression:
I haven’t found any workarounds yet. Haven’t tested older versions. Too tired. Send… send chocolate…!


Notes:
4  swift                    0x0000000105013959 swift::ArchetypeBuilder::resolveArchetype(swift::Type) + 25
5  swift                    0x0000000105015435 swift::ArchetypeBuilder::addSameTypeRequirement(swift::Type, swift::Type, swift::RequirementSource) + 37
6  swift                    0x0000000105015511 swift::ArchetypeBuilder::addRequirement(swift::RequirementRepr const&) + 65
7  swift                    0x0000000104f9ce69 checkGenericParameters(swift::TypeChecker&, swift::ArchetypeBuilder*, swift::GenericParamList*, swift::DeclContext*, swift::GenericTypeResolver&) + 889
8  swift                    0x0000000104f9c7d2 swift::TypeChecker::validateGenericSignature(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, std::__1::function<bool (swift::ArchetypeBuilder&)>, bool&) + 130
9  swift                    0x0000000104f9cf3e swift::TypeChecker::validateGenericTypeSignature(swift::NominalTypeDecl*) + 78
10 swift                    0x0000000104f7ed05 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 245
11 swift                    0x0000000104f890b0 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 640
12 swift                    0x0000000104f8222c swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 124
13 swift                    0x0000000104f64a38 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1128
14 swift                    0x000000010461ce2c swift::CompilerInstance::performSema() + 2428
15 swift                    0x00000001042faaf4 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2148
16 swift                    0x00000001042fa0e6 main + 1814

Comments

No longer crashes (after changing typealias to associatedtype) with DEVELOPMENT-SNAPSHOT-2016-05-03-a (LLVM dffa09ffd8, Clang 1e6cba3ce3, Swift d2aee43220).

No longer crashes (after changing typealias to associatedtype) with DEVELOPMENT-SNAPSHOT-2016-05-03-a (LLVM dffa09ffd8, Clang 1e6cba3ce3, Swift d2aee43220).

also crashes with Swift 1.1, jfyi

By dieter.komendera at March 1, 2015, 7:13 p.m. (reply...)

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!