Swift: Specifying a type variable in a protocol causes a segfault when an object conforms to that protocol

Originator:paulyoungonline
Number:rdar://17986478 Date Originated:11-Aug-2014 11:56 PM
Status:Closed Resolved:Yes
Product:Developer Tools Product Version:Xcode6-Beta5 (6A279r)
Classification:Serious Bug Reproducible:Always
 
Summary:
A type variable can be specified as part of a protocol but any attempt to conform to that protocol by implementing the type variable in other objects causes a segfault.

Steps to Reproduce:
1. Create a new Swift file
2. Define a protocol
3. Add a type variable to the protocol
4. Define an object that conforms to the protocol
5. Implement the type variable in the object
6. Execute the file using `xcrun swift` or add it to a target in an Xcode project and attempt to build.

Expected Results:
The type variable can be accessed on objects that implement the protocol.

Actual Results:
0  swift                    0x000000010900fb58 llvm::sys::PrintStackTrace(__sFILE*) + 40
1  swift                    0x0000000109010044 SignalHandler(int) + 452
2  libsystem_platform.dylib 0x00007fff8d4775aa _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff57870f68 _sigtramp + 3393165784
4  swift                    0x00000001084af078 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::RValueSource&&, swift::Lowering::AbstractionPattern) + 424
5  swift                    0x00000001084a8c18 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1080
6  swift                    0x00000001084ab246 swift::Lowering::SILGenFunction::emitGetAccessor(swift::SILLocation, swift::AbstractStorageDecl*, llvm::ArrayRef<swift::Substitution>, swift::Lowering::RValueSource&&, bool, swift::Lowering::RValue&&, swift::Lowering::SGFContext) + 1254
7  swift                    0x00000001084c0da1 swift::Lowering::SILGenFunction::emitRValueForDecl(swift::SILLocation, swift::ConcreteDeclRef, swift::Type, swift::Lowering::SGFContext) + 1745
8  swift                    0x00000001084c11a8 swift::Lowering::SILGenFunction::emitRValueForPropertyLoad(swift::SILLocation, swift::Lowering::ManagedValue, bool, swift::VarDecl*, llvm::ArrayRef<swift::Substitution>, bool, swift::Type, swift::Lowering::SGFContext) + 248
9  swift                    0x00000001084d54c2 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 27298
10 swift                    0x00000001084bf096 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 22
11 swift                    0x00000001084f36c7 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 359
12 swift                    0x00000001084f627d swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 141
13 swift                    0x00000001084f3368 swift::Lowering::SILGenFunction::visitBraceStmt(swift::BraceStmt*) + 232
14 swift                    0x00000001084f6284 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 148
15 swift                    0x00000001084c41d3 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 243
16 swift                    0x00000001084a4096 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 230
17 swift                    0x00000001084be073 swift::ASTVisitor<SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 355
18 swift                    0x00000001084bc9fb SILGenType::emitType() + 203
19 swift                    0x00000001084b79de swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
20 swift                    0x00000001084a600b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 411
2

Version:
Xcode6-Beta5 (6A279r)

Attachments:
'SwiftProtocolTypeVariableBug.swift' and 'SwiftProtocolTypeVariableBug.png' were successfully uploaded.

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!