Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 73c243b6250c21e4adccb99288be13b8b803707e..571da099e1bd2f6aa0a876154f9c8bb00e817c77 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -436,15 +436,26 @@ void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) { |
receiver_ = var; |
} |
-void DeclarationScope::DeclareDefaultFunctionVariables( |
- AstValueFactory* ast_value_factory) { |
+void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) { |
DCHECK(is_function_scope()); |
DCHECK(!is_arrow_scope()); |
+ |
+ Variable* arg_variable = LookupLocal(ast_value_factory->arguments_string()); |
+ if (arg_variable != NULL && IsLexicalVariableMode(arg_variable->mode())) { |
adamk
2016/08/30 20:45:56
Please add a comment here explaining what you're d
lpy
2016/09/01 01:17:30
Done.
|
+ return; |
+ } |
+ |
// Declare 'arguments' variable which exists in all non arrow functions. |
// Note that it might never be accessed, in which case it won't be |
// allocated during variable allocation. |
arguments_ = Declare(zone(), this, ast_value_factory->arguments_string(), VAR, |
adamk
2016/08/30 20:45:56
I think you only need to do this if arg_variable =
lpy
2016/09/01 01:17:30
Done.
|
Variable::ARGUMENTS, kCreatedInitialized); |
+} |
+ |
+void DeclarationScope::DeclareDefaultFunctionVariables( |
+ AstValueFactory* ast_value_factory) { |
+ DCHECK(is_function_scope()); |
+ DCHECK(!is_arrow_scope()); |
new_target_ = Declare(zone(), this, ast_value_factory->new_target_string(), |
CONST, Variable::NORMAL, kCreatedInitialized); |
@@ -1501,9 +1512,6 @@ void DeclarationScope::AllocateParameterLocals() { |
// allocate the arguments object by nulling out arguments_. |
arguments_ = nullptr; |
} |
- |
- } else { |
- DCHECK(is_arrow_scope()); |
} |
// The same parameter may occur multiple times in the parameters_ list. |