Skip to content

Commit 6f6a772

Browse files
author
David Ungar
committed
implicit checks
1 parent 8988fa9 commit 6f6a772

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ void SwitchStmtScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
800800
scopeCreator);
801801

802802
for (auto caseStmt : stmt->getCases()) {
803-
if (!scopeCreator.isDuplicate(caseStmt)) {
803+
if (!scopeCreator.isDuplicate(caseStmt) && !caseStmt->isImplicit()) {
804804
scopeCreator.createSubtree<CaseStmtScope>(this, caseStmt);
805805
}
806806
}
@@ -812,7 +812,12 @@ void ForEachStmtScope::expandAScopeThatDoesNotCreateANewInsertionPoint(
812812
scopeCreator);
813813

814814
// Add a child describing the scope of the pattern.
815-
scopeCreator.createSubtree<ForEachPatternScope>(this, stmt);
815+
// In error cases such as:
816+
// let v: C { for b : Int -> S((array: P { }
817+
// the body is implicit and it would overlap the source range of the expr
818+
// above.
819+
if (!stmt->getBody()->isImplicit())
820+
scopeCreator.createSubtree<ForEachPatternScope>(this, stmt);
816821
}
817822

818823
void ForEachPatternScope::expandAScopeThatDoesNotCreateANewInsertionPoint(

0 commit comments

Comments
 (0)