| Index: src/parsing/parser.cc
|
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
|
| index 0d16469f3190e582d399752cf5387926922d268a..6db71f8ebcdb669558f5944b452069a8ed166d4d 100644
|
| --- a/src/parsing/parser.cc
|
| +++ b/src/parsing/parser.cc
|
| @@ -988,6 +988,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
|
| + // 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())) {
|
| @@ -1152,6 +1158,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()) ||
|
|
|