Swift 2b4: “Constraint system missed a conformance?” swiftc crash working around mutual protocol recursion crash
Originator: | rix.rob | ||
Number: | rdar://22064859 | Date Originated: | 29-Jul-2015 09:59 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode-beta (7A165t) |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: Trying to work around rdar://22064783, swiftc died another death instead. Steps to Reproduce: This code: protocol A: _A { typealias O : B } protocol _A { typealias O init(_ : O) var out: O { get } } protocol B { typealias O : _A } enum Expr<T>: B { typealias O = T case Null func map<U>(transform: T -> U) -> Expr<U> { return .Null } } func out<Fix: A>(v: Fix) -> Fix.O { return v.out } func cata<T, Fix: A where Fix.O == Expr<Fix>>(f: Expr<T> -> T)(_ term: Fix) -> T { return f({ $0.map(cata(f)) }(out(term))) } Expected Results: should not crash swiftc Actual Results: but totally does: rob@Resonance ~/Desktop> swiftc -v boom.swift Apple Swift version 2.0 (swiftlang-700.0.47.4 clang-700.0.59.1) Target: x86_64-apple-darwin14.4.0 /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file boom.swift -target x86_64-apple-darwin14.4.0 -enable-objc-interop -color-diagnostics -module-name boom -o /var/folders/9y/f7n4rvx901nctm_5d16c1wm40000gn/T/boom-57cfd6.o boom.swift:23:33: error: same-type constraint type '<<error type>>' does not conform to required protocol '_A' func cata<T, Fix: A where Fix.O == Expr<Fix>>(f: Expr<T> -> T)(_ term: Fix) -> T { ^ boom.swift:23:33: error: same-type constraint type '<<error type>>' does not conform to required protocol '_A' func cata<T, Fix: A where Fix.O == Expr<Fix>>(f: Expr<T> -> T)(_ term: Fix) -> T { ^ boom.swift:15:6: error: type 'Expr<T>' does not conform to protocol 'B' enum Expr<T>: B { ^ boom.swift:12:12: note: protocol requires nested type 'O' typealias O : _A ^ boom.swift:16:12: note: possibly intended match 'O' does not conform to '_A' typealias O = T ^ Assertion failed: ((conforms || firstArchetype->getIsRecursive() || isOpenedAnyObject(replacement) || replacement->is<GenericTypeParamType>()) && "Constraint system missed a conformance?"), function computeSubstitutions, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.47.4/src/swift/lib/Sema/CSApply.cpp, line 145. 0 swift 0x000000010b876b8b llvm::sys::PrintStackTrace(__sFILE*) + 43 1 swift 0x000000010b8772cb SignalHandler(int) + 379 2 libsystem_platform.dylib 0x00007fff86e08f1a _sigtramp + 26 3 libc++.1.dylib 0x00007fff8b20043e operator new(unsigned long) + 30 4 libsystem_c.dylib 0x00007fff905e3b53 abort + 129 5 libsystem_c.dylib 0x00007fff905abc39 basename + 0 6 swift 0x0000000109e567e5 swift::constraints::Solution::computeSubstitutions(swift::Type, swift::DeclContext*, swift::Type, swift::constraints::ConstraintLocator*, llvm::SmallVectorImpl<swift::Substitution>&) const + 2117 7 swift 0x0000000109e6c7fd (anonymous namespace)::ExprRewriter::buildDeclRef(swift::ValueDecl*, swift::SourceLoc, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool, bool, swift::AccessSemantics) + 557 8 swift 0x0000000109e68839 swift::ASTVisitor<(anonymous namespace)::ExprRewriter, swift::Expr*, void, void, void, void, void>::visit(swift::Expr*) + 11129 9 swift 0x0000000109e628c6 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 22 10 swift 0x0000000109fa96bc (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 76 11 swift 0x0000000109fa78eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 219 12 swift 0x0000000109fa7890 (anonymous namespace)::Traversal::visit(swift::Expr*) + 128 13 swift 0x0000000109fa96f0 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 128 14 swift 0x0000000109fa78eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 219 15 swift 0x0000000109fa7890 (anonymous namespace)::Traversal::visit(swift::Expr*) + 128 16 swift 0x0000000109fa96f0 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 128 17 swift 0x0000000109fa78eb (anonymous namespace)::Traversal::visit(swift::Expr*) + 219 18 swift 0x0000000109fa6cd5 swift::Expr::walk(swift::ASTWalker&) + 53 19 swift 0x0000000109e56d94 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 484 20 swift 0x0000000109ee40af swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::Type, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*) + 399 21 swift 0x0000000109f492f2 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 4242 22 swift 0x0000000109f48399 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 313 23 swift 0x0000000109f47769 (anonymous namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25 24 swift 0x0000000109f4682f swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 415 25 swift 0x0000000109f46641 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 49 26 swift 0x0000000109f4736a swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 138 27 swift 0x0000000109ecc258 typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 200 28 swift 0x0000000109eccf53 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int) + 1731 29 swift 0x0000000109cd66d5 swift::CompilerInstance::performSema() + 4149 30 swift 0x000000010985a9d5 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 725 31 swift 0x000000010985a4e3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2627 32 swift 0x00000001098565af main + 2015 33 libdyld.dylib 0x00007fff86cb45c9 start + 1 34 libdyld.dylib 0x000000000000000d start + 2033498693 Stack dump: 0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file boom.swift -target x86_64-apple-darwin14.4.0 -enable-objc-interop -color-diagnostics -module-name boom -o /var/folders/9y/f7n4rvx901nctm_5d16c1wm40000gn/T/boom-57cfd6.o 1. While type-checking 'cata' at boom.swift:23:1 2. While type-checking expression at [boom.swift:24:9 - line:24:41] RangeText="f({ $0.map(cata(f)) }(out(term)))" <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: N/A 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!