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

Unified Diff: src/scopes.cc

Issue 1078483002: [es6]: Lexical arguments for arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make arguments() DCHECK instead Created 5 years, 8 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/scopes.h ('k') | test/mjsunit/harmony/arrow-functions-lexical-arguments.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 3d46d158ac877ad88ad4724d5184e4c6c275166b..93268ad31905015d78f014430124f70e6e7d1807 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -328,8 +328,8 @@ void Scope::Initialize() {
receiver_ = outer_scope()->receiver();
}
- if (is_function_scope()) {
- // Declare 'arguments' variable which exists in all functions.
+ if (is_function_scope() && !is_arrow_scope()) {
+ // 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.
variables_.Declare(this,
@@ -1295,11 +1295,13 @@ void Scope::AllocateHeapSlot(Variable* var) {
void Scope::AllocateParameterLocals(Isolate* isolate) {
DCHECK(is_function_scope());
Variable* arguments = LookupLocal(ast_value_factory_->arguments_string());
- DCHECK(arguments != NULL); // functions have 'arguments' declared implicitly
+ // Functions have 'arguments' declared implicitly in all non arrow functions.
+ DCHECK(arguments != nullptr || is_arrow_scope());
bool uses_sloppy_arguments = false;
- if (MustAllocate(arguments) && !HasArgumentsParameter(isolate)) {
+ if (arguments != nullptr && MustAllocate(arguments) &&
+ !HasArgumentsParameter(isolate)) {
// 'arguments' is used. Unless there is also a parameter called
// 'arguments', we must be conservative and allocate all parameters to
// the context assuming they will be captured by the arguments object.
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/arrow-functions-lexical-arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698