Skip to content

Commit 672b438

Browse files
authored
Merge pull request swiftlang#21342 from slavapestov/trivial-tests-and-fixes
Trivial tests and a fix
2 parents 34113d1 + 98659c6 commit 672b438

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-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+
}

test/SILGen/default_arguments.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,19 @@ func callThem() throws {
367367
defaultEscaping()
368368
autoclosureDefaultEscaping()
369369
}
370+
371+
func tupleDefaultArg(x: (Int, Int) = (1, 2)) {}
372+
373+
// CHECK-LABEL: sil hidden @$s17default_arguments19callTupleDefaultArgyyF : $@convention(thin) () -> ()
374+
// CHECK: function_ref @$s17default_arguments15tupleDefaultArg1xySi_Sit_tFfA_ : $@convention(thin) () -> (Int, Int)
375+
// CHECK: function_ref @$s17default_arguments15tupleDefaultArg1xySi_Sit_tF : $@convention(thin) (Int, Int) -> ()
376+
// CHECK: return
377+
func callTupleDefaultArg() {
378+
tupleDefaultArg()
379+
}
380+
381+
// FIXME: Should this be banned?
382+
func stupidGames(x: Int = 3) -> Int {
383+
return x
384+
}
385+
stupidGames(x:)()

0 commit comments

Comments
 (0)