Skip to content

Commit 3634b43

Browse files
committed
[Parse] Mark closure parameters as definitively not destructured in
parseClosureSignatureIfPresent. Otherwise, closure parameters that were parsed as "potentially destructured" will fail constraint generation, even after the parser has decided they are not destructured.
1 parent 6b01603 commit 3634b43

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,8 +2738,10 @@ parseClosureSignatureIfPresent(SourceRange &bracketRange,
27382738

27392739
for (unsigned i = 0, e = params->size(); i != e; ++i) {
27402740
auto *param = params->get(i);
2741-
if (!isTupleDestructuring(param))
2741+
if (!isTupleDestructuring(param)) {
2742+
param->setDestructured(false);
27422743
continue;
2744+
}
27432745

27442746
auto argName = "arg" + std::to_string(i);
27452747

test/Constraints/closures.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,3 +992,10 @@ func rdar_59741308() {
992992
}
993993
}
994994
}
995+
996+
func r60074136() {
997+
func takesClosure(_ closure: ((Int) -> Void) -> Void) {}
998+
999+
takesClosure { ((Int) -> Void) -> Void in // expected-warning {{unnamed parameters must be written with the empty name '_'}}
1000+
}
1001+
}

0 commit comments

Comments
 (0)