@@ -2208,20 +2208,23 @@ Expr *Parser::parseExprIdentifier() {
22082208 // lookups, so disable this check when parsing for SwiftSyntax.
22092209 if (!InPoundIfEnvironment && !Context.LangOpts .ParseForSyntaxTreeOnly ) {
22102210 D = lookupInScope (name);
2211- // FIXME: We want this to work: "var x = { x() }", but for now it's better
2212- // to disallow it than to crash.
2213- if (D) {
2214- for (auto activeVar : DisabledVars) {
2215- if (activeVar == D) {
2216- diagnose (loc.getBaseNameLoc (), DisabledVarReason);
2217- return new (Context) ErrorExpr (loc.getSourceRange ());
2211+
2212+ if (!Context.LangOpts .DisableParserLookup ) {
2213+ // FIXME: We want this to work: "var x = { x() }", but for now it's better
2214+ // to disallow it than to crash.
2215+ if (D) {
2216+ for (auto activeVar : DisabledVars) {
2217+ if (activeVar == D) {
2218+ diagnose (loc.getBaseNameLoc (), DisabledVarReason);
2219+ return new (Context) ErrorExpr (loc.getSourceRange ());
2220+ }
22182221 }
2219- }
2220- } else {
2221- for ( auto activeVar : DisabledVars ) {
2222- if (activeVar-> getName () == name. getFullName ()) {
2223- diagnose ( loc.getBaseNameLoc (), DisabledVarReason );
2224- return new (Context) ErrorExpr (loc. getSourceRange ());
2222+ } else {
2223+ for ( auto activeVar : DisabledVars) {
2224+ if ( activeVar-> getName () == name. getFullName () ) {
2225+ diagnose (loc. getBaseNameLoc (), DisabledVarReason);
2226+ return new (Context) ErrorExpr ( loc.getSourceRange () );
2227+ }
22252228 }
22262229 }
22272230 }
0 commit comments