Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: src/parsing/preparser.cc

Issue 2407163003: PreParser: track variable declarations and parameters (Closed)
Patch Set: more tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 306fb264d1c17116d189d87aefedbcc65a6a8dbf..d53551430a2391936fa800debae6aa4c7f435b98 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -296,7 +296,10 @@ void PreParser::DeclareAndInitializeVariables(
var + initializer -> RemoveUnresolved followed by NewUnresolved
let / const + initializer -> RemoveUnresolved
*/
-
+ Scope* scope = declaration_descriptor->hoist_scope;
+ if (scope == nullptr) {
+ scope = this->scope();
+ }
if (declaration->initializer.IsEmpty() ||
(declaration_descriptor->mode == VariableMode::LET ||
declaration_descriptor->mode == VariableMode::CONST)) {
@@ -304,6 +307,9 @@ void PreParser::DeclareAndInitializeVariables(
declaration_descriptor->scope->RemoveUnresolved(identifier);
}
}
+ for (auto identifier : *(declaration->pattern.identifiers_)) {
+ scope->DeclareVariableName(identifier, declaration_descriptor->mode);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698