Skip to content

Commit 97b2542

Browse files
authored
Merge pull request #25838 from nkcsgexi/fix-diag-syntax-5.1
[5.1] Parser: avoid emitting disabled var diagnostics when building syntax tree
2 parents 91bcfc5 + ec554cd commit 97b2542

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,14 +2283,16 @@ Expr *Parser::parseExprIdentifier() {
22832283
if (D) {
22842284
for (auto activeVar : DisabledVars) {
22852285
if (activeVar == D) {
2286-
diagnose(loc.getBaseNameLoc(), DisabledVarReason);
2286+
if (!Context.LangOpts.BuildSyntaxTree)
2287+
diagnose(loc.getBaseNameLoc(), DisabledVarReason);
22872288
return new (Context) ErrorExpr(loc.getSourceRange());
22882289
}
22892290
}
22902291
} else {
22912292
for (auto activeVar : DisabledVars) {
22922293
if (activeVar->getFullName() == name) {
2293-
diagnose(loc.getBaseNameLoc(), DisabledVarReason);
2294+
if (!Context.LangOpts.BuildSyntaxTree)
2295+
diagnose(loc.getBaseNameLoc(), DisabledVarReason);
22942296
return new (Context) ErrorExpr(loc.getSourceRange());
22952297
}
22962298
}

test/Syntax/Parser/diags.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@ if (5 ‒ 5) == 0 {}
2525
// CHECK-NEXT: ([[@LINE-4]]:7,[[@LINE-4]]:10) Fixit: "-"
2626
// CHECK-NEXT: [[@LINE-5]]:11 Error: expected ',' separator
2727
// CHECK-NEXT: ([[@LINE-6]]:6,[[@LINE-6]]:6) Fixit: ","
28+
29+
let dateFormatter: DateFormatter = {
30+
let dateFormatter = DateFormatter()
31+
return dateFormatter
32+
}()
33+
2834
// CHECK-NEXT: 7 error(s) 0 warnings(s) 2 note(s)

0 commit comments

Comments
 (0)