Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trivial tests and a fix #21342

Merged
merged 3 commits into from Dec 15, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/SILGen/SILGenExpr.cpp
Expand Up @@ -4283,9 +4283,6 @@ namespace {

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

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

// But avoid this in the common case.
if (!isa<TupleType>(destType)) {
Expand Down
9 changes: 9 additions & 0 deletions test/SILGen/assignment.swift
Expand Up @@ -49,3 +49,12 @@ func copyRightToLeft(p: inout P) {
// CHECK: end_access [[WRITE]] : $*P
p.left = p.right
}

// SR-5919
func stupidGames() -> ((), ()) {
return ((), ())
}

func assignToNestedVoid() {
let _: ((), ()) = stupidGames()
}
16 changes: 16 additions & 0 deletions test/SILGen/default_arguments.swift
Expand Up @@ -367,3 +367,19 @@ func callThem() throws {
defaultEscaping()
autoclosureDefaultEscaping()
}

func tupleDefaultArg(x: (Int, Int) = (1, 2)) {}

// CHECK-LABEL: sil hidden @$s17default_arguments19callTupleDefaultArgyyF : $@convention(thin) () -> ()
// CHECK: function_ref @$s17default_arguments15tupleDefaultArg1xySi_Sit_tFfA_ : $@convention(thin) () -> (Int, Int)
// CHECK: function_ref @$s17default_arguments15tupleDefaultArg1xySi_Sit_tF : $@convention(thin) (Int, Int) -> ()
// CHECK: return
func callTupleDefaultArg() {
tupleDefaultArg()
}

// FIXME: Should this be banned?
func stupidGames(x: Int = 3) -> Int {
return x
}
stupidGames(x:)()