Index: src/parsing/pattern-rewriter.cc |
diff --git a/src/parsing/pattern-rewriter.cc b/src/parsing/pattern-rewriter.cc |
index 6e20282785d0ba3495b2b4b723f69cb6e861bfd6..04b517ebba4ba0928994237360387df279d1cc92 100644 |
--- a/src/parsing/pattern-rewriter.cc |
+++ b/src/parsing/pattern-rewriter.cc |
@@ -33,7 +33,7 @@ void Parser::PatternRewriter::DeclareAndInitializeVariables( |
void Parser::PatternRewriter::RewriteDestructuringAssignment( |
- Parser* parser, RewritableAssignmentExpression* to_rewrite, Scope* scope) { |
+ Parser* parser, RewritableExpression* to_rewrite, Scope* scope) { |
PatternRewriter rewriter; |
DCHECK(!to_rewrite->is_rewritten()); |
@@ -58,8 +58,7 @@ Expression* Parser::PatternRewriter::RewriteDestructuringAssignment( |
Parser* parser, Assignment* assignment, Scope* scope) { |
DCHECK_NOT_NULL(assignment); |
DCHECK_EQ(Token::ASSIGN, assignment->op()); |
- auto to_rewrite = |
- parser->factory()->NewRewritableAssignmentExpression(assignment); |
+ auto to_rewrite = parser->factory()->NewRewritableExpression(assignment); |
RewriteDestructuringAssignment(parser, to_rewrite, scope); |
return to_rewrite->expression(); |
} |
@@ -91,8 +90,8 @@ Parser::PatternRewriter::SetInitializerContextIfNeeded(Expression* node) { |
// AssignmentElement nodes |
PatternContext old_context = context(); |
bool is_destructuring_assignment = |
- node->IsRewritableAssignmentExpression() && |
- !node->AsRewritableAssignmentExpression()->is_rewritten(); |
+ node->IsRewritableExpression() && |
+ !node->AsRewritableExpression()->is_rewritten(); |
bool is_assignment = |
node->IsAssignment() && node->AsAssignment()->op() == Token::ASSIGN; |
if (is_destructuring_assignment || is_assignment) { |
@@ -324,10 +323,11 @@ Variable* Parser::PatternRewriter::CreateTempVar(Expression* value) { |
} |
-void Parser::PatternRewriter::VisitRewritableAssignmentExpression( |
- RewritableAssignmentExpression* node) { |
- if (!IsAssignmentContext()) { |
- // Mark the assignment as rewritten to prevent redundant rewriting, and |
+void Parser::PatternRewriter::VisitRewritableExpression( |
+ RewritableExpression* node) { |
+ // If this is not a destructuring assignment... |
+ if (!IsAssignmentContext() || !node->expression()->IsAssignment()) { |
+ // Mark the node as rewritten to prevent redundant rewriting, and |
// perform BindingPattern rewriting |
DCHECK(!node->is_rewritten()); |
node->Rewrite(node->expression()); |