Skip to content

Commit ecea643

Browse files
authored
Merge pull request #64907 from xedin/avoid-infinite-rec-in-with-invalid-pack-refs
[CSSimplify] Prevent invalid pack references from causing infinite loops
2 parents 572c626 + 3714c48 commit ecea643

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,16 +4282,17 @@ ConstraintSystem::matchTypesBindTypeVar(
42824282
// pack expansion expression.
42834283
if (!typeVar->getImpl().canBindToPack() &&
42844284
(type->is<PackArchetypeType>() || type->is<PackType>())) {
4285-
if (shouldAttemptFixes()) {
4286-
auto *fix = AllowInvalidPackReference::create(*this, type,
4287-
getConstraintLocator(locator));
4288-
if (!recordFix(fix)) {
4289-
recordPotentialHole(typeVar);
4290-
return getTypeMatchSuccess();
4291-
}
4292-
}
4285+
if (!shouldAttemptFixes())
4286+
return getTypeMatchFailure(locator);
42934287

4294-
return getTypeMatchFailure(locator);
4288+
auto *fix = AllowInvalidPackReference::create(
4289+
*this, type, getConstraintLocator(locator));
4290+
if (recordFix(fix))
4291+
return getTypeMatchFailure(locator);
4292+
4293+
// Don't allow the invalid pack reference to propagate to other
4294+
// bindings.
4295+
type = PlaceholderType::get(typeVar->getASTContext(), typeVar);
42954296
}
42964297

42974298
// Binding to a pack expansion type is always an error in Swift 6 mode.

0 commit comments

Comments
 (0)