Skip to content

Commit 6d00a57

Browse files
committed
Disallow default values for patterns binding multiple variables
lets not add !
1 parent 6f7d20b commit 6d00a57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,9 +1706,10 @@ ConstructorDecl *swift::createImplicitConstructor(TypeChecker &tc,
17061706
arg->setInterfaceType(varInterfaceType);
17071707
arg->setImplicit();
17081708

1709-
// If this is a var that has a default value, lets assign a default value
1709+
// If this is a var that has a default value, and is only binding one var,
1710+
// i.e, var (a, b) = (3, 3) is not allowed, lets assign a default value
17101711
// to the parameter with the same expression.
1711-
if (!var->isLet()) {
1712+
if (!var->isLet() && var->getParentPattern()->getSingleVar()) {
17121713
if (auto init = var->getParentInitializer()) {
17131714
// Give this some bogus context right now, we'll fix it after making
17141715
// the constructor.

0 commit comments

Comments
 (0)