Skip to content

Commit 5340725

Browse files
committed
[CSSimplify] Prevent merging of type expansion type variables
Even if both sides are pack expansion variables they cannot be merged because merging of them means merging of pattern and shape types as well, which is easier to do when one of both sides are bound.
1 parent c130351 commit 5340725

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6577,6 +6577,12 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
65776577
auto rep1 = getRepresentative(typeVar1);
65786578
auto rep2 = getRepresentative(typeVar2);
65796579

6580+
// Pack expansion variables cannot be merged because
6581+
// they involve other type variables.
6582+
if (rep1->getImpl().isPackExpansion() ||
6583+
rep2->getImpl().isPackExpansion())
6584+
return formUnsolvedResult();
6585+
65806586
// If exactly one of the type variables can bind to an lvalue, we
65816587
// can't merge these two type variables.
65826588
if (kind == ConstraintKind::Equal &&
@@ -6634,6 +6640,12 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
66346640
auto rep1 = getRepresentative(typeVar1);
66356641
auto rep2 = getRepresentative(typeVar2);
66366642

6643+
// Pack expansion variables cannot be merged because
6644+
// they involve other type variables.
6645+
if (rep1->getImpl().isPackExpansion() ||
6646+
rep2->getImpl().isPackExpansion())
6647+
return formUnsolvedResult();
6648+
66376649
if (!rep1->getImpl().canBindToInOut() ||
66386650
!rep2->getImpl().canBindToLValue()) {
66396651
// Merge the equivalence classes corresponding to these two variables.

0 commit comments

Comments
 (0)