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

Unified Diff: src/scopes.cc

Issue 1423613002: Fix eval calls in initializers of arrow function parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment, rebase Created 5 years, 2 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/scopes.h ('k') | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index e85d35ac9bd70720ab23f31e1a9dfcd0a992219a..6a6b8ad45c7e74a092a716b715eafe33918dcb5c 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -386,22 +386,32 @@ Scope* Scope::FinalizeBlockScope() {
outer_scope()->unresolved_.Add(unresolved_[i], zone());
}
- // Propagate usage flags to outer scope.
- // TODO(adamk): Why doesn't this call PropagateScopeInfo()?
- if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
- if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
- if (scope_calls_eval_) outer_scope_->RecordEvalCall();
+ PropagateUsageFlagsToScope(outer_scope_);
return NULL;
}
-void Scope::ReplaceOuterScope(Scope* outer_scope) {
+void Scope::ReplaceOuterScope(Scope* outer) {
+ DCHECK_NOT_NULL(outer);
DCHECK_NOT_NULL(outer_scope_);
+ DCHECK(!already_resolved());
+ DCHECK(!outer->already_resolved());
+ DCHECK(!outer_scope_->already_resolved());
outer_scope_->RemoveInnerScope(this);
- outer_scope_ = outer_scope;
- outer_scope_->AddInnerScope(this);
- // TODO(adamk): Do we need to propagate usage flags here?
+ outer->AddInnerScope(this);
+ outer_scope_ = outer;
+}
+
+
+void Scope::PropagateUsageFlagsToScope(Scope* other) {
+ DCHECK_NOT_NULL(other);
+ DCHECK(!already_resolved());
+ DCHECK(!other->already_resolved());
+ if (uses_arguments()) other->RecordArgumentsUsage();
+ if (uses_super_property()) other->RecordSuperPropertyUsage();
+ if (calls_eval()) other->RecordEvalCall();
+ if (scope_contains_with_) other->RecordWithStatement();
}
@@ -1120,7 +1130,8 @@ Variable* Scope::LookupRecursive(VariableProxy* proxy,
if (var != NULL && proxy->is_assigned()) var->set_maybe_assigned();
*binding_kind = DYNAMIC_LOOKUP;
return NULL;
- } else if (calls_sloppy_eval() && name_can_be_shadowed) {
+ } else if (calls_sloppy_eval() && !is_script_scope() &&
+ name_can_be_shadowed) {
// A variable binding may have been found in an outer scope, but the current
// scope makes a sloppy 'eval' call, so the found variable may not be
// the correct one (the 'eval' may introduce a binding with the same name).
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/regress/regress-4395.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698