Chromium Code Reviews| Index: src/parsing/parser.cc |
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
| index 59d31f5a73514fd5c8a7f98d8e4be9146f8f433f..29c141257a02c486da32bea216209fbda7618c4c 100644 |
| --- a/src/parsing/parser.cc |
| +++ b/src/parsing/parser.cc |
| @@ -998,6 +998,12 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { |
| FunctionLiteral* result = NULL; |
| { |
| Scope* outer = original_scope_; |
| + // If there's a chance that there's a reference to global 'this', predeclare |
|
adamk
2016/08/11 18:27:17
What does the "If there's a chance" add to this co
Toon Verwaest
2016/08/12 04:49:40
How would you reformulate? I'm just trying to indi
adamk
2016/08/15 17:39:43
Makes sense, I missed the fact that the GetReceive
|
| + // it as a dynamic global on the script scope. |
| + if (outer->GetReceiverScope()->is_script_scope()) { |
| + info->script_scope()->DeclareDynamicGlobal( |
| + ast_value_factory()->this_string(), Variable::THIS); |
| + } |
| DCHECK(outer); |
| if (info->is_eval()) { |
| if (!outer->is_script_scope() || is_strict(info->language_mode())) { |
| @@ -1162,6 +1168,12 @@ FunctionLiteral* Parser::DoParseLazy(ParseInfo* info, |
| // Parse the function literal. |
| Scope* scope = original_scope_; |
| DCHECK(scope); |
| + // If there's a chance that there's a reference to global 'this', predeclare |
| + // it as a dynamic global on the script scope. |
| + if (info->is_arrow() && scope->GetReceiverScope()->is_script_scope()) { |
| + info->script_scope()->DeclareDynamicGlobal( |
| + ast_value_factory()->this_string(), Variable::THIS); |
| + } |
| FunctionState function_state(&function_state_, &scope_state_, scope, |
| info->function_kind()); |
| DCHECK(is_sloppy(scope->language_mode()) || |