Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: src/parsing/parser.cc

Issue 2362463003: Declare the arguments object before creating the function var, to make sure it masks it (Closed)
Patch Set: Add comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.cc ('k') | test/mjsunit/regress/regress-649067.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index b1f7c667ef9ac4b5c115bdab0cbef30de7ae5e90..29b26055c3d8e7519e097c6fe912437c63712242 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -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) {
« no previous file with comments | « src/ast/scopes.cc ('k') | test/mjsunit/regress/regress-649067.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698