Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 36f5b8bbf3179fe495ff42309f777ee1a70095ff..48ddd0a53a51a23386c82681b8a6c27a0169eb6b 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -1178,7 +1178,10 @@ bool Scope::AllowsLazyParsingWithoutUnresolvedVariables( |
// the parse, since context allocation of those variables is already |
// guaranteed to be correct. |
for (const Scope* s = this; s != outer; s = s->outer_scope_) { |
- if (s->is_eval_scope()) return false; |
+ // Eval forces context allocation on all outer scopes, so we don't need to |
+ // look at those scopes. Sloppy eval makes top-level non-lexical variables |
+ // dynamic, whereas strict-mode requires context allocation. |
+ if (s->is_eval_scope()) return is_sloppy(s->language_mode()); |
// Catch scopes force context allocation of all variables. |
if (s->is_catch_scope()) continue; |
// With scopes do not introduce variables that need allocation. |
@@ -1888,7 +1891,10 @@ bool Scope::MustAllocateInContext(Variable* var) { |
if (has_forced_context_allocation()) return true; |
if (var->mode() == TEMPORARY) return false; |
if (is_catch_scope()) return true; |
- if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true; |
+ if ((is_script_scope() || is_eval_scope()) && |
+ IsLexicalVariableMode(var->mode())) { |
+ return true; |
+ } |
return var->has_forced_context_allocation() || inner_scope_calls_eval_; |
} |