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

Unified Diff: src/pattern-rewriter.cc

Issue 1139773005: [destructuring] More tests for object literal pattern (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments addressed, landing Created 5 years, 7 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
Index: src/pattern-rewriter.cc
diff --git a/src/pattern-rewriter.cc b/src/pattern-rewriter.cc
index 949be73e295a24b941dde658f42a4168d89d5250..9f24a395a25c4a24d1a17a9e7f75eb0b97bef1ee 100644
--- a/src/pattern-rewriter.cc
+++ b/src/pattern-rewriter.cc
@@ -209,14 +209,21 @@ void Parser::PatternRewriter::VisitVariableProxy(VariableProxy* pattern) {
void Parser::PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern) {
- auto temp = descriptor_->declaration_scope->NewTemporary(
+ auto temp = TemporaryDeclarationScope()->NewTemporary(
ast_value_factory()->empty_string());
auto assignment =
factory()->NewAssignment(Token::ASSIGN, factory()->NewVariableProxy(temp),
current_value_, RelocInfo::kNoPosition);
+
block_->AddStatement(
factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition),
zone());
+
+ if (pattern->properties()->length() == 0) {
+ block_->AddStatement(descriptor_->parser->BuildAssertIsCoercible(temp),
+ zone());
+ }
+
for (ObjectLiteralProperty* property : *pattern->properties()) {
// TODO(dslomov): computed property names.
RecurseIntoSubpattern(

Powered by Google App Engine
This is Rietveld 408576698