Skip to content

Commit 98659c6

Browse files
committed
SILGen: Remove over-eager assertions in assignment lowering
We already assert that each element of the tuple is an lvalue; asserting that the tuple itself has an lvalue or is Void is incorrect because the tuple might have zero non-tuple elements recursively but itself not be Void, eg ((), ()). Fixes <https://bugs.swift.org/browse/SR-5919>.
1 parent 2c4a23c commit 98659c6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4283,9 +4283,6 @@ namespace {
42834283

42844284
// If the destination is a tuple, recursively destructure.
42854285
void visitTupleExpr(TupleExpr *E) {
4286-
auto *TTy = E->getType()->castTo<TupleType>();
4287-
assert(TTy->hasLValueType() || TTy->isVoid());
4288-
(void)TTy;
42894286
for (auto &elt : E->getElements()) {
42904287
visit(elt);
42914288
}
@@ -4398,7 +4395,6 @@ static void emitSimpleAssignment(SILGenFunction &SGF, SILLocation loc,
43984395

43994396
// Handle tuple destinations by destructuring them if present.
44004397
CanType destType = dest->getType()->getCanonicalType();
4401-
assert(!destType->isMaterializable() || destType->isVoid());
44024398

44034399
// But avoid this in the common case.
44044400
if (!isa<TupleType>(destType)) {

test/SILGen/assignment.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ func copyRightToLeft(p: inout P) {
4949
// CHECK: end_access [[WRITE]] : $*P
5050
p.left = p.right
5151
}
52+
53+
// SR-5919
54+
func stupidGames() -> ((), ()) {
55+
return ((), ())
56+
}
57+
58+
func assignToNestedVoid() {
59+
let _: ((), ()) = stupidGames()
60+
}

0 commit comments

Comments
 (0)