Swift 2 and the Abstruse Algebraic Apomorphism Address Assertion Altercation
Originator: | rix.rob | ||
Number: | rdar://21328632 | Date Originated: | 10-Jun-2015 05:45 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode-7-beta (7A120f) |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: Algebraic types make Swift 2 sad. Steps to Reproduce: 1. Compile this _with swiftc_. I repeat, _swiftc_. It does _not_ crash with _swift_, only with _swiftc_: enum E<T> { func map<U>(_ : T -> U) -> E<U> { return .C } case C } enum Either<T, U> { case Left(T) case Right(U) func either<V>(ifLeft ifLeft: T -> V, ifRight: U -> V) -> V { switch self { case let .Left(t): return ifLeft(t) case let .Right(u): return ifRight(u) } } } protocol FixpointType { typealias Recur init(_ : Recur) var out: Recur { get } } func map<T, U>(f: T -> U)(_ c: E<T>) -> E<U> { return E.map(c)(f) } func apo<T, Fix: FixpointType where Fix.Recur == E<Fix>>(f: T -> E<Either<Fix, T>>)(_ seed: T) -> Fix { let fanin = { Either<Fix, T>.either($0)(ifLeft: {$0}, ifRight: { apo(f)($0) }) } return Fix((map(fanin))(f(seed))) } Expected Results: should not crash Actual Results: but totally does: Assertion failed: (ptr->getType()->getPointerElementType() == StorageType), function getAddressForPointer, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.38.1/src/swift/lib/IRGen/GenType.cpp, line 311. 0 swift 0x000000010d10de0b llvm::sys::PrintStackTrace(__sFILE*) + 43 1 swift 0x000000010d10e54b SignalHandler(int) + 379 2 libsystem_platform.dylib 0x00007fff88493f1a _sigtramp + 26 3 libsystem_platform.dylib 0x00007f8d24851860 _sigtramp + 2621167968 4 libsystem_c.dylib 0x00007fff86f90b53 abort + 129 5 libsystem_c.dylib 0x00007fff86f58c39 basename + 0 6 swift 0x000000010b22b7d6 swift::irgen::TypeInfo::getAddressForPointer(llvm::Value*) const + 70 7 swift 0x000000010b256caa bindParameter((anonymous namespace)::IRGenSILFunction&, swift::SILArgument*, swift::irgen::Explosion&) + 154 8 swift 0x000000010b252def (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 3279 9 swift 0x000000010b251d52 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 498 … 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-2efa8f.o 1. While emitting IR SIL function @_TFF5recur3apou0_Rq0_S_12FixpointTypezqq0_S0_5RecurGOS_1Eq0___FFq_GS1_GOS_6Eitherq0_q___Fq_q0_U_FGS2_Q0_Q__Q0_ for expression at [recur.swift:25:14 - line:25:81] RangeText="{ Either<Fix, T>.either($0)(ifLeft: {$0}, ifRight: { apo(f)($0) }) }" <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: This didn’t crash in Swift 1.2. Haven’t figured out a workaround yet. Notes: Maybe if I don’t have any functions at all, maybe then Swift 2 will love me.
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!