Swift 2: Expression survives to SILGen & crashes compiler
| Originator: | rix.rob | ||
| Number: | rdar://21299477 | Date Originated: | 09-Jun-2015 09:37 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-7-beta (7A120f) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
I was messing around with enums & protocols, attempting to recover functions for enum cases, when I hit a crasher.
Steps to Reproduce:
1. Compile this test case, _if you dare_:
public protocol P {
typealias T
static func c(T) -> Self
static func C(T) -> Self
}
extension P {
public static func C(x: T) -> Self {
return .c(x)
}
}
public enum E<T>: P {
case C(T)
public static func c(x: T) -> E {
return C(x)
}
}
Expected Results:
I expected this not to crash. I didn’t expect it to do much very useful tho.
Actual Results:
It crashed when compiling E.c().
expression kind should not survive to SILGen
UNREACHABLE executed at /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/SILGen/ASTVisitor.h:49!
0 swift 0x000000010cd4ee0b llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x000000010cd4f54b SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff88493f1a _sigtramp + 26
3 swift 0x000000010d348a1f FirstTarget + 60535
4 swift 0x000000010cd4f346 abort + 22
5 swift 0x000000010cd08e21 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 481
6 swift 0x000000010af6feb3 swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 5987
7 swift 0x000000010af73d2f (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 3279
8 swift 0x000000010af64aef prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 175
9 swift 0x000000010af649ff swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 47
10 swift 0x000000010afa3c57 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 87
…
Stack dump:
0. Program arguments: /Applications/Xcode-7-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file either.swift -target x86_64-apple-darwin14.3.0 -enable-objc-interop -color-diagnostics -module-name either -o /var/folders/9y/f7n4rvx901nctm_5d16c1wm40000gn/T/either-3c4bb1.o
1. While emitting SIL for 'c' at either.swift:15:9
Regression:
It doesn’t crash if E.c() returns E.C(x) instead of just C(x).
Notes:
N/A
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!