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

Unified Diff: src/parsing/parser.cc

Issue 2656753003: [ast/parsing] Pessimistically assume all top-level variables will be assigned. (Closed)
Patch Set: Rebase. Created 3 years, 11 months 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
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 36268493e971ae185e2f88b5254cc5a88a7dde70..34a1ef224ab8a93291ce35952a6adb0316d4067c 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -1480,6 +1480,10 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
bool* ok) {
VariableProxy* proxy =
factory()->NewVariableProxy(variable_name, NORMAL_VARIABLE);
+
+ DeclarationScope* target_scope = GetDeclarationScope();
+ MarkTopLevelVariableAsAssigned(target_scope, proxy);
+
Declaration* declaration =
factory()->NewFunctionDeclaration(proxy, function, scope(), pos);
Declare(declaration, DeclarationDescriptor::NORMAL, mode, kCreatedInitialized,
@@ -1488,7 +1492,6 @@ Statement* Parser::DeclareFunction(const AstRawString* variable_name,
if (is_sloppy_block_function) {
SloppyBlockFunctionStatement* statement =
factory()->NewSloppyBlockFunctionStatement();
- DeclarationScope* target_scope = GetDeclarationScope();
target_scope->DeclareSloppyBlockFunction(variable_name, scope(), statement);
return statement;
}
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698