Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index bbc8155e9bd3f5f54070d480170f6ed4faef91cc..a981a5dc9a4280fe1f7f7ed7243ea88b0d9d17fa 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -411,6 +411,14 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) { |
| scope->outer_scope()->scope_type() == SCRIPT_SCOPE || |
| scope->outer_scope()->already_resolved_); |
| + // If there's a chance that there's a reference to global 'this', predeclare |
| + // it as a dynamic global on the script scope. |
| + if (scope->scope_type() != SCRIPT_SCOPE && |
| + scope->outer_scope()->GetReceiverScope()->is_script_scope()) { |
|
Toon Verwaest
2016/08/31 08:56:55
Shouldn't this just be scope->GetReceiverScope()?
|
| + info->script_scope()->DeclareDynamicGlobal( |
| + info->ast_value_factory()->this_string(), Variable::THIS); |
| + } |
| + |
| scope->AllocateVariables(info, mode); |
| #ifdef DEBUG |