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

Unified Diff: src/pattern-rewriter.cc

Issue 1414283002: [es6] Fix scoping for default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 2 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/parser.cc ('k') | src/scopes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pattern-rewriter.cc
diff --git a/src/pattern-rewriter.cc b/src/pattern-rewriter.cc
index 090f85dc9c533ad68fcdb0bff435c7440152194d..f2c1240b9c5e0f98b0dd24e3aba1cb702f81ff2f 100644
--- a/src/pattern-rewriter.cc
+++ b/src/pattern-rewriter.cc
@@ -4,6 +4,7 @@
#include "src/ast.h"
#include "src/messages.h"
+#include "src/parameter-initializer-rewriter.h"
#include "src/parser.h"
namespace v8 {
@@ -359,8 +360,16 @@ void Parser::PatternRewriter::VisitAssignment(Assignment* node) {
Token::EQ_STRICT, factory()->NewVariableProxy(temp),
factory()->NewUndefinedLiteral(RelocInfo::kNoPosition),
RelocInfo::kNoPosition);
+ Expression* initializer = node->value();
+ if (descriptor_->declaration_kind == DeclarationDescriptor::PARAMETER &&
+ descriptor_->scope->is_arrow_scope()) {
+ // TODO(adamk): Only call this if necessary.
+ RewriteParameterInitializerScope(
+ descriptor_->parser->stack_limit(), initializer,
+ descriptor_->scope->outer_scope(), descriptor_->scope);
+ }
Expression* value = factory()->NewConditional(
- is_undefined, node->value(), factory()->NewVariableProxy(temp),
+ is_undefined, initializer, factory()->NewVariableProxy(temp),
RelocInfo::kNoPosition);
RecurseIntoSubpattern(node->target(), value);
}
« no previous file with comments | « src/parser.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698