Swift 2: “Substitution conformances don’t match archetype” crasher
| Originator: | rix.rob | ||
| Number: | rdar://21333511 | Date Originated: | 10-Jun-2015 10:35 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-7-beta (7A120f) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
This is another one where the compiler correctly reports that it can’t compile but then crashes trying anyway
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
func map<U>(transform: T -> U) -> Expr<U> {return .Null}
}
func out<Fix: FixpointType>(v: Fix) -> Fix.Recur {return v.out}
func cata<T, Fix: FixpointType where Fix.Recur == Expr<Fix>>(f: Expr<T> -> T)(_ term: Fix) -> T {
return f({ $0.map(cata(f)) }(out(term)))
}
struct Term: FixpointType, CustomDebugStringConvertible {
typealias Algebra = Expr<Term>
var debugDescription: String {return cata(Term.toDebugString)(self)}
static func toDebugString(expression: Expr<String>) -> String {return ""}
}
Expected Results:
should not crash the compiler
Actual Results:
but totally does:
…errors…
…
3 swift 0x0000000100b503e6 swift::Type::transform(std::__1::function<swift::Type (swift::Type)> const&) const + 54
4 libsystem_c.dylib 0x00007fff86f90b53 abort + 129
5 libsystem_c.dylib 0x00007fff86f58c39 basename + 0
6 swift 0x0000000100b45c9f swift::Substitution::Substitution(swift::ArchetypeType*, swift::Type, llvm::ArrayRef<swift::ProtocolConformance*>) + 271
…
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-42ee18.o
1. While type-checking getter for debugDescription at recur.swift:17:31
2. While type-checking expression at [recur.swift:17:39 - line:17:68] RangeText="cata(Term.toDebugString)(self)"
<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)
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!