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

Unified Diff: src/ast/scopes.cc

Issue 1950803002: Don't treat catch scopes as possibly-shadowing for sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Amend comment Created 4 years, 7 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 | « no previous file | test/mjsunit/regress/regress-crbug-608279.js » ('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 2372e1bb1d4b944a4acb668d1ff325c9199d0fd3..5b91bb6b7edee3be392a05077e73537a448a2a2c 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -1098,12 +1098,15 @@ 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() && !is_script_scope() &&
- name_can_be_shadowed) {
+ } else if (calls_sloppy_eval() && is_declaration_scope() &&
+ !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).
// In that case, change the lookup result to reflect this situation.
+ // Only scopes that can host var bindings (declaration scopes) need be
+ // considered here (this excludes block and catch scopes), and variable
+ // lookups at script scope are always dynamic.
if (*binding_kind == BOUND) {
*binding_kind = BOUND_EVAL_SHADOWED;
} else if (*binding_kind == UNBOUND) {
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-608279.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698