Skip to content

Commit 0d55af8

Browse files
committed
SIL: Fix another bug in verifyDynamicPackIndexStructuralEquality()
Fixes rdar://problem/109911237.
1 parent ee29a4f commit 0d55af8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5757,8 +5757,15 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
57575757
// Provide substitution functions that replace the pack archetypes
57585758
// we found above with the corresponding lane of the pack substitution.
57595759
auto substTypes = [&](SubstitutableType *type) -> Type {
5760+
auto archetype = dyn_cast<ElementArchetypeType>(type);
5761+
if (!archetype)
5762+
return type;
5763+
if (!archetype->isRoot())
5764+
return Type();
5765+
57605766
auto it = allOpened.find(type->getCanonicalType());
5761-
if (it == allOpened.end()) return Type();
5767+
assert(it != allOpened.end());
5768+
57625769
auto pack = it->second;
57635770
auto packElementType = pack.getElementType(componentIndex);
57645771
if (auto exp = dyn_cast<PackExpansionType>(packElementType)) {

test/SILGen/pack_expansion_type.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ func variadicMetatypes<each T>(_: repeat each T) {
4646
// CHECK-LABEL: sil [ossa] @$s19pack_expansion_type18sameExpansionTwice2us05more_G02vsyxxQp_xxQpq_q_QptRvzRv_r0_lF : $@convention(thin) <each U, each V> (@pack_guaranteed Pack{repeat each U}, @pack_guaranteed Pack{repeat each U}, @pack_guaranteed Pack{repeat each V}) -> () {
4747
public func sameExpansionTwice<each U, each V>(us: repeat each U, more_us: repeat each U, vs: repeat each V) {}
4848

49+
// SILVerifier bug
50+
public func nonPackAndPackParameterInExpansion<each T, U, V>(t: repeat each T, u: U, v: V) -> (repeat (each T, U, V)) {
51+
return (repeat (each t, u, v))
52+
}

0 commit comments

Comments
 (0)