Skip to content

Commit 8d88441

Browse files
authored
Merge pull request #22572 from dcci/rdar47982630-50
[5.0][DebuggerSupport] Unbreak closures in the expression parser.
2 parents f92b43e + 0271b66 commit 8d88441

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/Parse/Lexer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,6 @@ void Lexer::lexDollarIdent() {
953953
// independent of language mode.
954954
return formToken(tok::identifier, tokStart);
955955
} else {
956-
if (LangOpts.EnableDollarIdentifiers && !LangOpts.Playground)
957-
return formToken(tok::identifier, tokStart);
958956
return formToken(tok::dollarident, tokStart);
959957
}
960958
}

lib/Parse/ParseExpr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,12 @@ Expr *Parser::parseExprAnonClosureArg() {
29152915
auto closure = dyn_cast_or_null<ClosureExpr>(
29162916
dyn_cast<AbstractClosureExpr>(CurDeclContext));
29172917
if (!closure) {
2918+
if (Context.LangOpts.DebuggerSupport) {
2919+
auto refKind = DeclRefKind::Ordinary;
2920+
auto identifier = Context.getIdentifier(Name);
2921+
return new (Context) UnresolvedDeclRefExpr(DeclName(identifier), refKind,
2922+
DeclNameLoc(Loc));
2923+
}
29182924
diagnose(Loc, diag::anon_closure_arg_not_in_closure);
29192925
return new (Context) ErrorExpr(Loc);
29202926
}

test/Parse/closure-debugger.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: not %target-swift-frontend %s -typecheck -debugger-support 2>&1 | %FileCheck %s --check-prefix=DEBUG
2+
// RUN: not %target-swift-frontend %s -typecheck 2>&1 | %FileCheck %s --check-prefix=NODEBUG
3+
4+
// DEBUG: error: use of unresolved identifier '$0'
5+
// NODEBUG: error: anonymous closure argument not contained in a closure
6+
$0

0 commit comments

Comments
 (0)