Commit df7ecd1c authored by verwaest's avatar verwaest Committed by Commit bot

Declare the arguments object before creating the function var, to make sure it masks it

BUG=chromium:649067

Review-Url: https://codereview.chromium.org/2362463003
Cr-Commit-Position: refs/heads/master@{#39642}
parent d52451ec
......@@ -1218,7 +1218,6 @@ void DeclarationScope::AnalyzePartially(DeclarationScope* migrate_to,
DCHECK_EQ(outer_scope_->zone(), migrate_to->zone());
DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject());
DCHECK_EQ(asm_function_, migrate_to->asm_function_);
DCHECK_EQ(arguments() != nullptr, migrate_to->arguments() != nullptr);
}
#ifdef DEBUG
......
......@@ -2842,10 +2842,6 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
// Parsing the body may change the language mode in our scope.
language_mode = scope->language_mode();
scope->DeclareArguments(ast_value_factory());
if (main_scope != scope) {
main_scope->DeclareArguments(ast_value_factory());
}
// Validate name and parameter names. We can do this only after parsing the
// function, since the function can declare itself strict.
......@@ -3434,6 +3430,13 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
}
}
if (!IsArrowFunction(kind)) {
// Declare arguments after parsing the function since lexical 'arguments'
// masks the arguments object. Declare arguments before declaring the
// function var since the arguments object masks 'function arguments'.
function_scope->DeclareArguments(ast_value_factory());
}
if (function_type == FunctionLiteral::kNamedExpression) {
Statement* statement;
if (function_scope->LookupLocal(function_name) == nullptr) {
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertEquals(1, (function arguments() { return eval("arguments"); })(1)[0]);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment