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

Unified Diff: src/ast/scopes.cc

Issue 2380993003: Readd default function variables upon scope reset for preparse abort (Closed)
Patch Set: Created 4 years, 3 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/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 9e77b5145265eee9906f0c4a155cae246c6cf369..1607553c3b5782a55a57d829b58070477cdfb548 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -606,6 +606,7 @@ void DeclarationScope::DeclareDefaultFunctionVariables(
DCHECK(is_function_scope());
DCHECK(!is_arrow_scope());
+ DeclareThis(ast_value_factory);
new_target_ = Declare(zone(), this, ast_value_factory->new_target_string(),
CONST, NORMAL_VARIABLE, kCreatedInitialized);
@@ -1188,7 +1189,10 @@ Handle<StringSet> DeclarationScope::CollectNonLocals(
return non_locals;
}
-void DeclarationScope::ResetAfterPreparsing(bool aborted) {
+void DeclarationScope::ResetAfterPreparsing(AstValueFactory* ast_value_factory,
+ bool aborted) {
+ DCHECK(is_function_scope());
+
// Reset all non-trivial members.
decls_.Clear();
locals_.Clear();
@@ -1201,6 +1205,9 @@ void DeclarationScope::ResetAfterPreparsing(bool aborted) {
// TODO(verwaest): We should properly preparse the parameters (no declarations
// should be created), and reparse on abort.
if (aborted) {
+ if (!IsArrowFunction(function_kind_)) {
+ DeclareDefaultFunctionVariables(ast_value_factory);
+ }
// Recreate declarations for parameters.
for (int i = 0; i < params_.length(); i++) {
Variable* var = params_[i];
@@ -1246,7 +1253,7 @@ void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) {
}
}
- ResetAfterPreparsing(false);
+ ResetAfterPreparsing(ast_node_factory->ast_value_factory(), false);
unresolved_ = unresolved;
}
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698