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-4008] Same-type constraint crasher in extension #46593

Closed
airspeedswift opened this issue Feb 19, 2017 · 8 comments
Closed

[SR-4008] Same-type constraint crasher in extension #46593

airspeedswift opened this issue Feb 19, 2017 · 8 comments
Assignees
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

@airspeedswift
Copy link
Member

Previous ID SR-4008
Radar rdar://problem/30596897
Original Reporter @airspeedswift
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 482df2673f2c353e75467686aadc8313

Issue Description:

Inside a type extension, constraining a generic parameter to be equal to another type that uses a generic argument from the function as a generic argument to the constraint crashes the compiler:

extension Array {
  func f<S: Sequence>() where Element == Array<S.Iterator.Element> {
    
  } 
}

This doesn't appear to happen with protocol extensions, this compiles OK:

extension Sequence {
  func f<S: Sequence>() where Iterator.Element == Array<S.Iterator.Element> {
    
  } 
}
@airspeedswift
Copy link
Member Author

@swift-ci create

@ole
Copy link
Contributor

ole commented Feb 20, 2017

Thanks for filing this. It's got nothing to do with "protocol extensions", though, right?

@airspeedswift
Copy link
Member Author

Ah right, just extensions, yeah. Wonder if it crashes with a protocol in fact.

@airspeedswift
Copy link
Member Author

Nope, it doesn't. This compiles just fine:

extension Sequence {
  func f<S: Sequence>() where Iterator.Element == Array<S.Iterator.Element> {
    
  } 
}

@belkadan
Copy link
Contributor

Ben and I talked a little about this and realized this is technically looking for a new feature, since now we have a member with constrained applicability instead of an entire extension. Unfortunately, we can't write this as a constrained extension today; it would look something like this:

extension <NestedElement> Array where Element == Array<NestedElement> {
  func f<S: Sequence>(_ seq: S) where NestedElement == S.Iterator.Element {}
}

The compiler still shouldn't crash, though. Running the test case under LLDB shows we're blowing out the stack:

  * frame #&#8203;0: 0x0000000100f9e141 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(derivedType=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;1: 0x0000000100f9e11e swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3063 [opt]
    frame #&#8203;2: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734791418696, params=<unavailable>)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;3: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;4: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5f4003e8, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;5: 0x0000000100f9e175 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(derivedType=Type @ 0x00007fff5f4003e8)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;6: 0x0000000100f9e11e swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3063 [opt]
    frame #&#8203;7: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734791420176, params=<unavailable>)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;8: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;9: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5f400798, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;10: 0x0000000100f9b5c1 swift`swift::Type::transformRec(this=<unavailable>, fn=<unavailable>)>) const at Type.cpp:3526 [opt]
    frame #&#8203;11: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5f400948)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;12: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;13: 0x0000000100f3e519 swift`swift::GenericEnvironment::mapTypeIntoContext(this=<unavailable>, type=Type @ 0x00007fff5f400970, lookupConformance=<unavailable>)>) const at GenericEnvironment.cpp:292 [opt]
    frame #&#8203;14: 0x0000000100f46522 swift`swift::GenericSignatureBuilder::PotentialArchetype::getTypeInContext(this=<unavailable>, builder=<unavailable>, genericEnv=<unavailable>) at GenericSignatureBuilder.cpp:691 [opt]
    frame #&#8203;15: 0x0000000100f3e413 swift`swift::GenericEnvironment::QueryInterfaceTypeSubstitutions::operator(this=<unavailable>, type=<unavailable>)(swift::SubstitutableType*) const at GenericEnvironment.cpp:208 [opt]
    frame #&#8203;16: 0x0000000100f3dfc3 swift`swift::GenericEnvironment::QueryArchetypeToInterfaceSubstitutions::operator()(swift::SubstitutableType*) const [inlined] swift::GenericEnvironment::mapTypeIntoContext(type=0x00000001073b2d78) const at GenericEnvironment.cpp:309 [opt]
    frame #&#8203;17: 0x0000000100f3dfb3 swift`swift::GenericEnvironment::QueryArchetypeToInterfaceSubstitutions::operator(this=0x00007fff5f400ed8, type=<unavailable>)(swift::SubstitutableType*) const at GenericEnvironment.cpp:242 [opt]
    frame #&#8203;18: 0x0000000100f9e1c3 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] llvm::function_ref<swift::Type (swift::SubstitutableType*)>::operator(this=<unavailable>)(swift::SubstitutableType*) const at STLExtras.h:105 [opt]
    frame #&#8203;19: 0x0000000100f9e1ba swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3079 [opt]
    frame #&#8203;20: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734791421552, params=0x00000001073d6290)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;21: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;22: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5f400ea8, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;23: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5f400ea8)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;24: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;25: 0x0000000100f3e2e5 swift`swift::GenericEnvironment::mapTypeOutOfContext(this=<unavailable>, type=Type @ 0x00007fff5f400ee0) const at GenericEnvironment.cpp:180 [opt]
    frame #&#8203;26: 0x0000000100f46ea8 swift`swift::ArchetypeType::resolveNestedType(this=0x00000001073d6290, nested=0x00000001073d62c8) const at GenericSignatureBuilder.cpp:841 [opt]
    frame #&#8203;27: 0x0000000100f98f85 swift`swift::ArchetypeType::getNestedType(this=0x00000001073d6290, Name=<unavailable>) const at Type.cpp:2692 [opt]
    frame #&#8203;28: 0x0000000100f9a144 swift`getMemberForBaseType(lookupConformances=<unavailable>, origBase=<unavailable>, substBase=<unavailable>, assocType=0x000000010682a470, name=<unavailable>, options=<unavailable>)>, swift::Type, swift::Type, swift::AssociatedTypeDecl*, swift::Identifier, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:2901 [opt]
    frame #&#8203;29: 0x0000000100f9e257 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3116 [opt]
    frame #&#8203;30: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734791423456, params=<unavailable>)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;31: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;32: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5f401468, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;33: 0x0000000100f9b5c1 swift`swift::Type::transformRec(this=<unavailable>, fn=<unavailable>)>) const at Type.cpp:3526 [opt]
    frame #&#8203;34: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5f401618)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;35: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;36: 0x0000000100f3e519 swift`swift::GenericEnvironment::mapTypeIntoContext(this=<unavailable>, type=Type @ 0x00007fff5f401640, lookupConformance=<unavailable>)>) const at GenericEnvironment.cpp:292 [opt]
    frame #&#8203;37: 0x0000000100f46522 swift`swift::GenericSignatureBuilder::PotentialArchetype::getTypeInContext(this=<unavailable>, builder=<unavailable>, genericEnv=<unavailable>) at GenericSignatureBuilder.cpp:691 [opt]
    frame #&#8203;38: 0x0000000100f3e413 swift`swift::GenericEnvironment::QueryInterfaceTypeSubstitutions::operator(this=<unavailable>, type=<unavailable>)(swift::SubstitutableType*) const at GenericEnvironment.cpp:208 [opt]
    frame #&#8203;39: 0x0000000100f3dfc3 swift`swift::GenericEnvironment::QueryArchetypeToInterfaceSubstitutions::operator()(swift::SubstitutableType*) const [inlined] swift::GenericEnvironment::mapTypeIntoContext(type=0x00000001073b2d78) const at GenericEnvironment.cpp:309 [opt]
    frame #&#8203;40: 0x0000000100f3dfb3 swift`swift::GenericEnvironment::QueryArchetypeToInterfaceSubstitutions::operator(this=0x00007fff5f401ba8, type=<unavailable>)(swift::SubstitutableType*) const at GenericEnvironment.cpp:242 [opt]
    frame #&#8203;41: 0x0000000100f9e1c3 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] llvm::function_ref<swift::Type (swift::SubstitutableType*)>::operator(this=<unavailable>)(swift::SubstitutableType*) const at STLExtras.h:105 [opt]
    frame #&#8203;42: 0x0000000100f9e1ba swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3079 [opt]
    frame #&#8203;43: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734791424832, params=0x00000001073d6290)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;44: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;45: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5f401b78, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;46: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5f401b78)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;47: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;48: 0x0000000100f3e2e5 swift`swift::GenericEnvironment::mapTypeOutOfContext(this=<unavailable>, type=Type @ 0x00007fff5f401bb0) const at GenericEnvironment.cpp:180 [opt]
    frame #&#8203;49: 0x0000000100f46ea8 swift`swift::ArchetypeType::resolveNestedType(this=0x00000001073d6290, nested=0x00000001073d62c8) const at GenericSignatureBuilder.cpp:841 [opt]
    frame #&#8203;50: 0x0000000100f98f85 swift`swift::ArchetypeType::getNestedType(this=0x00000001073d6290, Name=<unavailable>) const at Type.cpp:2692 [opt]
…

    frame #&#8203;58701: 0x0000000100f9a144 swift`getMemberForBaseType(lookupConformances=<unavailable>, origBase=<unavailable>, substBase=<unavailable>, assocType=0x000000010682a470, name=<unavailable>, options=<unavailable>)>, swift::Type, swift::Type, swift::AssociatedTypeDecl*, swift::Identifier, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:2901 [opt]
    frame #&#8203;58702: 0x0000000100f9e257 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3116 [opt]
    frame #&#8203;58703: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734799790736, params=<unavailable>)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;58704: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;58705: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5fbfc118, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;58706: 0x0000000100f9b5c1 swift`swift::Type::transformRec(this=<unavailable>, fn=<unavailable>)>) const at Type.cpp:3526 [opt]
    frame #&#8203;58707: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5fbfc2c8)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;58708: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;58709: 0x0000000100f3e519 swift`swift::GenericEnvironment::mapTypeIntoContext(this=<unavailable>, type=Type @ 0x00007fff5fbfc2f0, lookupConformance=<unavailable>)>) const at GenericEnvironment.cpp:292 [opt]
    frame #&#8203;58710: 0x0000000100f46522 swift`swift::GenericSignatureBuilder::PotentialArchetype::getTypeInContext(this=<unavailable>, builder=<unavailable>, genericEnv=<unavailable>) at GenericSignatureBuilder.cpp:691 [opt]
    frame #&#8203;58711: 0x0000000100f3e413 swift`swift::GenericEnvironment::QueryInterfaceTypeSubstitutions::operator(this=<unavailable>, type=<unavailable>)(swift::SubstitutableType*) const at GenericEnvironment.cpp:208 [opt]
    frame #&#8203;58712: 0x0000000100f9e1c3 swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] llvm::function_ref<swift::Type (swift::SubstitutableType*)>::operator(this=<unavailable>)(swift::SubstitutableType*) const at STLExtras.h:105 [opt]
    frame #&#8203;58713: 0x0000000100f9e1ba swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) [inlined] substType(this=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14::operator()(swift::TypeBase*) const at Type.cpp:3079 [opt]
    frame #&#8203;58714: 0x0000000100f9e04d swift`llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (callable=140734799792640, params=0x00000001073b29b0)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_14>(long, swift::TypeBase*) at STLExtras.h:92 [opt]
    frame #&#8203;58715: 0x0000000100f9b336 swift`swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const [inlined] llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::operator(params=<unavailable>)(swift::TypeBase*) const at STLExtras.h:105 [opt]
    frame #&#8203;58716: 0x0000000100f9b32d swift`swift::Type::transformRec(this=0x00007fff5fbfc888, fn=<unavailable>)>) const at Type.cpp:3379 [opt]
    frame #&#8203;58717: 0x0000000100f9b5c1 swift`swift::Type::transformRec(this=<unavailable>, fn=<unavailable>)>) const at Type.cpp:3526 [opt]
    frame #&#8203;58718: 0x0000000100f99c79 swift`swift::Type::subst(llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const [inlined] substType(derivedType=Type @ 0x00007fff5fbfca38)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) at Type.cpp:3030 [opt]
    frame #&#8203;58719: 0x0000000100f99c34 swift`swift::Type::subst(this=<unavailable>, substitutions=<unavailable>, conformances=<unavailable>, options=<unavailable>)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const at Type.cpp:3133 [opt]
    frame #&#8203;58720: 0x0000000100f3e0f5 swift`swift::GenericEnvironment::mapTypeIntoContext(swift::GenericEnvironment*, swift::Type) [inlined] swift::GenericEnvironment::mapTypeIntoContext(type=Type @ 0x00007fff5fbfca60, lookupConformance=<unavailable>)>) const at GenericEnvironment.cpp:292 [opt]
    frame #&#8203;58721: 0x0000000100f3e0c4 swift`swift::GenericEnvironment::mapTypeIntoContext(swift::GenericEnvironment*, swift::Type) [inlined] swift::GenericEnvironment::mapTypeIntoContext(type=<unavailable>) const at GenericEnvironment.cpp:304 [opt]
    frame #&#8203;58722: 0x0000000100f3e0b9 swift`swift::GenericEnvironment::mapTypeIntoContext(env=<unavailable>, type=Type @ 0x00007fff5fbfca78) at GenericEnvironment.cpp:165 [opt]
    frame #&#8203;58723: 0x0000000100e0da85 swift`(anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) [inlined] recordSelfContextType(swift::AbstractFunctionDecl*) at TypeCheckDecl.cpp:1127 [opt]

@slavapestov
Copy link
Member

We do allow where clauses to place constraints on outer generic parameters now, and @DougGregor and @huonw have been fixing up same type constraints to work in their full generality.

@huonw
Copy link
Mannequin

huonw mannequin commented Mar 30, 2017

With 3.1 this gets an error that the constraint is recursive (“same-type constraint 'Element' == 'Array<S.Iterator.Element>' is recursive”), so this is a regression in detecting handling the recursion.

@slavapestov
Copy link
Member

Works on master.

@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

5 participants