Skip to content

Commit 2c90924

Browse files
authored
Merge pull request #85939 from xedin/rdar-159408715
[Diagnostics] Don't attempt to synthesize arguments when destructurin…
2 parents cb8d672 + 1f88720 commit 2c90924

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,12 @@ static bool fixMissingArguments(ConstraintSystem &cs, ASTNode anchor,
27472747
args.pop_back();
27482748
for (const auto &elt : tuple->getElements())
27492749
args.emplace_back(elt.getType(), elt.getName());
2750+
2751+
// If unpacking a tuple results in more arguments than parameters
2752+
// it would be diagnosed as a general mismatch because it's unclear
2753+
// whether it's a problem with missing or extraneous parameters.
2754+
if (args.size() > params.size())
2755+
return true;
27502756
} else if (auto *typeVar = argType->getAs<TypeVariableType>()) {
27512757
auto isParam = [](const Expr *expr) {
27522758
if (auto *DRE = dyn_cast<DeclRefExpr>(expr)) {

validation-test/compiler_crashers/fixMissingArguments-ef29fe.swift renamed to validation-test/compiler_crashers_fixed/fixMissingArguments-ef29fe.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// {"kind":"typecheck","languageMode":6,"signature":"fixMissingArguments(swift::constraints::ConstraintSystem&, swift::ASTNode, llvm::SmallVectorImpl<swift::AnyFunctionType::Param>&, llvm::ArrayRef<swift::AnyFunctionType::Param>, unsigned int, swift::constraints::ConstraintLocatorBuilder)","signatureAssert":"Assertion failed: (Index < Length && \"Invalid index!\"), function operator[]"}
2-
// RUN: not --crash %target-swift-frontend -typecheck -swift-version 6 %s
2+
// RUN: not %target-swift-frontend -typecheck -swift-version 6 %s
33
func a((Int, Int, Int)) a > {
44
b, c in

0 commit comments

Comments
 (0)