Swift 2: Compiler crash in fixAbstractFunctionNames
| Originator: | rix.rob | ||
| Number: | rdar://21333445 | Date Originated: | 10-Jun-2015 10:27 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-7-beta (7A120f) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
Steps to Reproduce:
1. This:
protocol FixpointType {
typealias Algebra : AlgebraicType
init(_ : Algebra)
var out: Algebra { get }
}
protocol AlgebraicType {
typealias Recur
}
enum Expr<T>: AlgebraicType {
typealias Recur = T
case Null // this is quite a dull language
func map<U>(transform: T -> U) -> Expr<U> {
return .Null
}
}
struct Term: FixpointType {
let out: Expr<Term>
typealias Algebra = Expr<Term>
}
Expected Results:
should not crash
Actual Results:
but totally does:
Assertion failed: (!targetArg.empty() && "Must have a name here"), function fixAbstractFunctionNames, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/Sema/TypeCheckDecl.cpp, line 7174.
0 swift 0x000000010cc53e0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x000000010cc5454b SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff88493f1a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fff54f992e8 _sigtramp + 3434107880
4 libsystem_c.dylib 0x00007fff86f90b53 abort + 129
5 libsystem_c.dylib 0x00007fff86f58c39 basename + 0
6 swift 0x000000010b2ea079 swift::TypeChecker::fixAbstractFunctionNames(swift::InFlightDiagnostic&, swift::AbstractFunctionDecl*, swift::DeclName) + 2153
7 swift 0x000000010b31e565 std::__1::__function::__func<(anonymous namespace)::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*)::$_8, std::__1::allocator<(anonymous namespace)::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*)::$_8>, void (swift::TypeChecker&, swift::NormalProtocolConformance*)>::operator()(swift::TypeChecker&, swift::NormalProtocolConformance*&&) + 149
8 swift 0x000000010b310c9c (anonymous namespace)::ConformanceChecker::diagnoseOrDefer(swift::ValueDecl*, bool, std::__1::function<void (swift::TypeChecker&, swift::NormalProtocolConformance*)>) + 252
9 swift 0x000000010b31317f (anonymous namespace)::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 2335
…
Stack dump:
0. Program arguments: /Applications/Xcode-7-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file recur.swift -target x86_64-apple-darwin14.3.0 -enable-objc-interop -module-name recur -o /var/folders/9y/f7n4rvx901nctm_5d16c1wm40000gn/T/recur-c96d47.o
1. While type-checking 'Term' at recur.swift:17:1
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Regression:
Swift 1.2 was pretty ok with this sorta thing in general although I didn’t have the AlgebraicType protocol then so who even knows?
Notes:
This is a really productive example, I’ve hit three different new crashers trying to work around a fourth.
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!