Skip to content

[SR-8019] Conditional conformance typealias segfault #50552

@stephencelis

Description

@stephencelis
Previous ID SR-8019
Radar rdar://problem/41216423
Original Reporter @stephencelis
Type Bug
Status Resolved
Resolution Done
Environment

Swift 4.15 (Xcode 8 beta)

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

md5: 3aa5f0bde3771054f7a549acb48e1558

Issue Description:

The following code segfaults:

struct A<C: Collection> {
  typealias Element = C.Element
}

extension A: Equatable where C: Equatable, Element: Equatable {
  public static func == (lhs: A, rhs: A) -> Bool {
    return true
  }
}

With:

error: associated type 'Element' can only be used with a concrete type or generic parameter base
  typealias Element = Collection.Element
                                 ^
0  swift                    0x000000010af94c5a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010af94066 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff7d995d9a _sigtramp + 26
3  swift                    0x00000001087322d6 swift::GenericSignature::enumeratePairedRequirements(llvm::function_ref<bool (swift::Type, llvm::ArrayRef<swift::Requirement>)>) const + 1446
4  swift                    0x00000001086618f0 swift::ASTContext::getConformance(swift::Type, swift::ProtocolDecl*, swift::SourceLoc, swift::DeclContext*, swift::ProtocolConformanceState) + 656
5  swift                    0x00000001086fd51f swift::ConformanceLookupTable::getConformance(swift::NominalTypeDecl*, swift::ConformanceLookupTable::ConformanceEntry*) + 1199
6  swift                    0x000000010879469c swift::NominalTypeDecl::lookupConformance(swift::ModuleDecl*, swift::ProtocolDecl*, llvm::SmallVectorImpl<swift::ProtocolConformance*>&) const + 684
7  swift                    0x0000000108774bd4 swift::ModuleDecl::lookupConformance(swift::Type, swift::ProtocolDecl*) + 1892
8  swift                    0x0000000108745583 swift::GenericSignatureBuilder::lookupConformance(swift::CanType, swift::Type, swift::ProtocolType*) + 227
9  swift                    0x00000001087423b2 swift::GenericSignatureBuilder::addTypeRequirement(llvm::PointerUnion<swift::GenericSignatureBuilder::PotentialArchetype*, swift::Type>, llvm::PointerUnion<swift::GenericSignatureBuilder::PotentialArchetype*, swift::Type>, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::GenericSignatureBuilder::UnresolvedHandlingKind, swift::ModuleDecl*) + 3266
10 swift                    0x000000010874a1cf swift::GenericSignatureBuilder::addRequirement(swift::RequirementRepr const*, swift::GenericSignatureBuilder::FloatingRequirementSource, swift::SubstitutionMap const*, swift::ModuleDecl*) + 1807
11 swift                    0x00000001083b9646 swift::TypeChecker::checkGenericParamList(swift::GenericSignatureBuilder*, swift::GenericParamList*, swift::GenericSignature*, swift::GenericTypeResolver*) + 646
12 swift                    0x00000001083bf45d swift::TypeChecker::checkGenericEnvironment(swift::GenericParamList*, swift::DeclContext*, swift::GenericSignature*, bool, swift::ExtensionDecl*, llvm::function_ref<void (swift::GenericSignatureBuilder&)>, bool) + 1421
13 swift                    0x0000000108382803 swift::TypeChecker::validateExtension(swift::ExtensionDecl*) + 563
14 swift                    0x000000010839dafc (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 332
15 swift                    0x0000000108435616 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1830
16 swift                    0x000000010806c995 swift::CompilerInstance::performSema() + 4933
17 swift                    0x00000001072678db performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 731
18 swift                    0x000000010726410f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
19 swift                    0x000000010720dc48 main + 13144
20 libdyld.dylib            0x00007fff7d793ee1 start + 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions