Skip to content

Commit da4232e

Browse files
committed
[Diagnostics] Fix checking for presence of type variables in closure return expression
Instead of validating sub-expressions included in the closure's result `diagnoseAmbiguousMultiStatementClosure` was only checking parent expression by mistake.
1 parent 9c1e975 commit da4232e

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8390,9 +8390,9 @@ diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) {
83908390
// constraint system through declaration types.
83918391
bool hasUnresolvedParams = false;
83928392
resultExpr->forEachChildExpr([&](Expr *childExpr) -> Expr *{
8393-
if (auto DRE = dyn_cast<DeclRefExpr>(resultExpr)) {
8393+
if (auto DRE = dyn_cast<DeclRefExpr>(childExpr)) {
83948394
if (auto param = dyn_cast<ParamDecl>(DRE->getDecl())) {
8395-
auto paramType = param->getType();
8395+
auto paramType = param->hasType() ? param->getType() : Type();
83968396
if (!paramType || paramType->hasTypeVariable()) {
83978397
hasUnresolvedParams = true;
83988398
return nullptr;

validation-test/compiler_crashers/28663-impl-getgraphindex-typevariables-size-out-of-bounds-index.swift renamed to validation-test/compiler_crashers_fixed/28663-impl-getgraphindex-typevariables-size-out-of-bounds-index.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
(_==_{return($0)u
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
[.s{return($0
1110
protocol r

0 commit comments

Comments
 (0)