Skip to content

Commit 4c4bf08

Browse files
author
David Ungar
authored
Merge pull request #30968 from davidungar/rdar-61461187-tolerate-nonempty-brace-in-brace
[ASTScope lookup] Tolerate non-empty braces in braces
2 parents 1af01ed + a2a60e0 commit 4c4bf08

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,10 @@ class ScopeCreator final {
658658
ASTScopeAssert(!n.isDecl(DeclKind::Accessor),
659659
"Should not see accessors here");
660660
// Can occur in illegal code
661+
// non-empty brace stmt could define a new insertion point
661662
if (auto *const s = n.dyn_cast<Stmt *>()) {
662663
if (auto *const bs = dyn_cast<BraceStmt>(s))
663-
ASTScopeAssert(bs->empty(), "Might mess up insertion point");
664+
return !bs->empty();
664665
}
665666
return !n.isDecl(DeclKind::Var);
666667
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: not %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s --check-prefix=CHECK-NO-ASSERTION
2+
3+
// Used to trip an assertion
4+
5+
public struct Foo {
6+
func bar() {
7+
var copySelf = self
8+
repeat { copySelf
9+
10+
private extension String {}
11+
12+
// CHECK-NO-ASSERTION-NOT: Assertion

0 commit comments

Comments
 (0)