Skip to content

Commit ff833da

Browse files
committed
[ASTScopes] Remove ErrorExpr check from condition scope expansion
This appears unnecessary and incorrectly meant the ErrorExpr would be placed outside the condition, meaning we could find the binding in its own initializer.
1 parent 1923037 commit ff833da

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,8 @@ AnnotatedInsertionPoint
959959
ConditionalClausePatternUseScope::expandAScopeThatCreatesANewInsertionPoint(
960960
ScopeCreator &scopeCreator) {
961961
auto *initializer = sec.getInitializer();
962-
if (!isa<ErrorExpr>(initializer)) {
963-
scopeCreator
964-
.constructExpandAndInsert<ConditionalClauseInitializerScope>(
965-
this, initializer);
966-
}
962+
scopeCreator.constructExpandAndInsert<ConditionalClauseInitializerScope>(
963+
this, initializer);
967964

968965
return {this,
969966
"Succeeding code must be in scope of conditional clause pattern bindings"};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// {"kind":"typecheck","signature":"swift::constraints::TypeVarRefCollector::walkToStmtPre(swift::Stmt*)","signatureAssert":"Assertion failed: (result), function getClosureType"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
{
4+
guard let a = (a if{
5+
return
6+
}
7+
) "

0 commit comments

Comments
 (0)