Skip to content

Instantly share code, notes, and snippets.

@amw amw/compile.log
Created Mar 27, 2016

Embed
What would you like to do?
Swift compiler crashes on incorrect code: type defined inside protocol extension
swiftc -v test.swift
Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)
Target: x86_64-apple-macosx10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name test -o /var/folders/0y/7j1jzys50dx1dwrs60r_5d9r0000gn/T/test-23b3ad.o
test.swift:6:8: error: type 'Error' cannot be defined within a protocol extension
enum Error: ErrorType {case IsntOk}
^
test.swift:10:13: error: initializing from a metatype value must reference 'init' explicitly
throw Error.IsntOk
^
.init
0 swift 0x000000010b6934eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010b6927d6 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010b693b4f SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff9574352a _sigtramp + 26
4 libsystem_platform.dylib 0x00007ff0840c7348 _sigtramp + 4002954808
5 swift 0x00000001099b4120 (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 1664
6 swift 0x00000001099b3a68 (anonymous namespace)::ExprRewriter::buildMemberRef(swift::Expr*, swift::Type, swift::SourceLoc, swift::ValueDecl*, swift::SourceLoc, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder, bool, swift::AccessSemantics, bool) + 3992
7 swift 0x00000001099bcb12 swift::ASTVisitor<(anonymous namespace)::ExprRewriter, swift::Expr*, void, void, void, void, void>::visit(swift::Expr*) + 19346
8 swift 0x00000001099b4ff2 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 18
9 swift 0x0000000109ae32ec swift::Expr::walk(swift::ASTWalker&) + 76
10 swift 0x00000001099aee57 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 471
11 swift 0x0000000109a35a24 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 756
12 swift 0x00000001099ce5c4 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*) + 1012
13 swift 0x00000001099c5a84 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 148
14 swift 0x00000001099c9941 swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4113
15 swift 0x0000000109a301a0 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 736
16 swift 0x0000000109a3593d swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 525
17 swift 0x0000000109a89005 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 2389
18 swift 0x0000000109a887df swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 303
19 swift 0x0000000109a889c7 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 791
20 swift 0x0000000109a887df swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 303
21 swift 0x0000000109a8747f swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 335
22 swift 0x0000000109a87cea swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 154
23 swift 0x0000000109a1eb02 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 178
24 swift 0x0000000109a1f745 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1765
25 swift 0x00000001098a19ca swift::CompilerInstance::performSema() + 4090
26 swift 0x00000001093e5326 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 934
27 swift 0x00000001093e441d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
28 swift 0x00000001093dfe3c main + 1932
29 libdyld.dylib 0x00007fff970d55ad start + 1
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name test -o /var/folders/0y/7j1jzys50dx1dwrs60r_5d9r0000gn/T/test-23b3ad.o
1. While type-checking 'ensureIsOk' at test.swift:8:3
2. While type-checking expression at [test.swift:10:13 - line:10:19] RangeText="Error.I"
3. While type-checking expression at [test.swift:10:13 - line:10:19] RangeText="Error.I"
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
protocol MyType {
func isOk() -> Bool
}
extension MyType {
enum Error: ErrorType {case IsntOk}
func ensureIsOk() throws {
if !isOk() {
throw Error.IsntOk
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.