Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8820,8 +8820,8 @@ ConstraintSystem::simplifyPackElementOfConstraint(Type first, Type second,

if (shouldAttemptFixes()) {
auto *loc = getConstraintLocator(locator);
auto *fix = AllowInvalidPackElement::create(*this, packType, loc);
if (!recordFix(fix))
if (elementType->isPlaceholder() ||
!recordFix(AllowInvalidPackElement::create(*this, packType, loc)))
return SolutionKind::Solved;
}

Expand Down Expand Up @@ -12920,6 +12920,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyShapeOfConstraint(
return SolutionKind::Unsolved;
};

// Don't try computing the shape of a type variable.
if (type1->isTypeVariableOrMember())
return formUnsolved();

// We can't compute a reduced shape if the input type still
// contains type variables that might bind to pack archetypes.
SmallPtrSet<TypeVariableType *, 2> typeVars;
Expand Down
11 changes: 11 additions & 0 deletions test/Constraints/pack-expansion-expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@ func packElementInvalidBinding<each T>(_ arg: repeat each T) {
repeat print(each x)
// expected-error@-1 {{'each' cannot be applied to non-pack type 'Int'}}
}

func copyIntoTuple<each T>(_ arg: repeat each T) -> (repeat each T) {
return (repeat each arg)
}
func callCopyAndBind<T>(_ arg: repeat each T) {
// expected-error@-1 {{'each' cannot be applied to non-pack type 'T'}}
// expected-error@-2 {{variadic expansion 'T' must contain at least one variadic generic parameter}}

// Don't propagate errors for invalid declaration reference
let result = copyIntoTuple(repeat each arg)
}