Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4203] [3.1] no relation found that declares conformance to target #46786

Closed
karwa opened this issue Mar 9, 2017 · 3 comments
Closed

[SR-4203] [3.1] no relation found that declares conformance to target #46786

karwa opened this issue Mar 9, 2017 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@karwa
Copy link
Contributor

karwa commented Mar 9, 2017

Previous ID SR-4203
Radar None
Original Reporter @karwa
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.1 (swiftlang-802.0.31.3 clang-802.0.30.2)
OSX 10.12

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression, CompilerCrash
Assignee None
Priority Medium

md5: 4be486bba1151e72ccbdb128b716e78d

Issue Description:

The following code crashes the latest 3.1 snapshot.

protocol SomeProto {
    associatedtype ThingType
    func getThing() -> ThingType
}

protocol SpecialThing: RandomAccessCollection {
}

protocol Castable {
    associatedtype Source
    static func cast(from: Source) -> Self
}

struct ThingGetter<P: SomeProto, T> {
    let thing: P
}

extension ThingGetter where P.ThingType: SpecialThing, T: Castable, P.ThingType.Iterator.Element == T.Source {

    func getView() -> ThingView {
        return ThingView(thing: thing.getThing())
    }
    
    struct ThingView: SpecialThing {
        let thing: P.ThingType

        typealias Index = P.ThingType.Index
        typealias IndexDistance = P.ThingType.IndexDistance
        var startIndex: Index    { return thing.startIndex }
        var endIndex:   Index    { return thing.startIndex }
        var count: IndexDistance { return thing.count }
        func index(after i: Index) -> Index {
            return thing.index(after: i)
        }
        func index(before i: Index) -> Index {
            return thing.index(before: i)
        }
        subscript(i: Index) -> T {
            return T.cast(from: thing[i])
        }
    }
}

To duplicate:

xcrun -toolchain 3.1-snapshot swiftc -emit-ir ~/Desktop/test.swift

Stack trace:

no relation found that declares conformance to target
UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-3.1-package-osx/swift/lib/IRGen/GenArchetype.cpp:141!
0  swift                    0x0000000107c1e5b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000107c1d7d6 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x0000000107c1ec09 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fffa144eb3a _sigtramp + 26
4  libsystem_platform.dylib 0x0000000000000004 _sigtramp + 1589318884
5  libsystem_c.dylib        0x00007fffa12d3420 abort + 129
6  swift                    0x0000000107bbf267 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
7  swift                    0x0000000104e25006 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 390
8  swift                    0x0000000104eee01b swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 251
9  swift                    0x0000000104e22a4c swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 172
10 swift                    0x0000000104e22889 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>) + 137
11 swift                    0x0000000104ef2512 swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 2034
12 swift                    0x0000000104eea89d swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 381
13 swift                    0x0000000104e5eac2 swift::irgen::IRGenerator::emitGlobalTopLevel() + 834
14 swift                    0x0000000104f25851 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1041
15 swift                    0x0000000104f25dc6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 86
16 swift                    0x0000000104de699c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 15084
17 swift                    0x0000000104da1a10 main + 3312
18 libdyld.dylib            0x00007fffa123f235 start + 1
19 libdyld.dylib            0x0000000000000061 start + 1591479853
@karwa
Copy link
Contributor Author

karwa commented Mar 9, 2017

Also ran in to this one while reducing the test case:

should have substituted dependent type into context
UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-3.1-package-osx/swift/lib/SIL/TypeLowering.cpp:250!
0  swift                    0x000000010da9d5b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010da9c7d6 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x000000010da9dc09 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fffa144eb3a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fff54fddae0 _sigtramp + 3015241664
5  libsystem_c.dylib        0x00007fffa12d3420 abort + 129
6  swift                    0x000000010da3e267 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 471
7  swift                    0x000000010b717dbf (anonymous namespace)::TypeClassifierBase<(anonymous namespace)::TypeClassifier, LoweredTypeKind>::visitAbstractTypeParamType(swift::CanType) + 175
8  swift                    0x000000010b71726b LoweredTypeKind swift::CanTypeVisitor<(anonymous namespace)::TypeClassifier, LoweredTypeKind>::visit<>(swift::CanType) + 155
9  swift                    0x000000010b71a889 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 201
10 swift                    0x000000010b713a7a swift::Lowering::TypeLowering const* swift::CanTypeVisitor<(anonymous namespace)::LowerType, swift::Lowering::TypeLowering const*>::visit<>(swift::CanType) + 1274
11 swift                    0x000000010b712fae swift::Lowering::TypeConverter::getTypeLoweringForUncachedLoweredType(swift::Lowering::TypeConverter::TypeKey) + 462
12 swift                    0x000000010b711a9c swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, unsigned int) + 732
13 swift                    0x000000010ad8d91c swift::irgen::IRGenModule::getTypeInfoForUnlowered(swift::Type) + 188
14 swift                    0x000000010ad981ac swift::irgen::hasDependentValueWitnessTable(swift::irgen::IRGenModule&, swift::CanType) + 28
15 swift                    0x000000010ad4325e swift::irgen::emitStructMetadata(swift::irgen::IRGenModule&, swift::StructDecl*) + 382
16 swift                    0x000000010ad7c702 swift::irgen::IRGenModule::emitStructDecl(swift::StructDecl*) + 18
17 swift                    0x000000010ace5093 swift::irgen::IRGenModule::emitNestedTypeDecls(swift::IteratorRange<swift::DeclIterator>) + 99
18 swift                    0x000000010ace044a swift::irgen::IRGenModule::emitExtension(swift::ExtensionDecl*) + 42
19 swift                    0x000000010acd9735 swift::irgen::IRGenModule::emitSourceFile(swift::SourceFile&, unsigned int) + 117
20 swift                    0x000000010ada4872 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1074
21 swift                    0x000000010ada4dc6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 86
22 swift                    0x000000010ac6599c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 15084
23 swift                    0x000000010ac20a10 main + 3312
24 libdyld.dylib            0x00007fffa123f235 start + 1
25 libdyld.dylib            0x0000000000000061 start + 1591479853

@belkadan
Copy link
Contributor

belkadan commented Mar 9, 2017

Since that doesn't actually compile in 3.0 it's not an urgent regression, but at least we got a real error message there. cc @slavapestov

@slavapestov
Copy link
Member

This works in 5.4 and was probably fixed a long time ago. I'll add a regression test.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants