Commit c65dbd51 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[class] Rewrite destructuring assignment in class field initializers

Bug: v8:5751, chromium:899537
Change-Id: I4c072727dffc9381a81eb8711c4114220345914d
Reviewed-on: https://chromium-review.googlesource.com/c/1304538Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57141}
parent 78c053a5
......@@ -2339,6 +2339,12 @@ ParserBase<Impl>::ParseClassFieldInitializer(ClassInfo* class_info, int beg_pos,
initializer = ParseAssignmentExpression(true);
ValidateExpression();
// TODO(gsathya): In the future, this could be changed to be
// called once for all the class field initializers, instead of
// rewriting after each class field initializer, improving
// performance.
impl()->RewriteDestructuringAssignments();
} else {
initializer = factory()->NewUndefinedLiteral(kNoSourcePosition);
}
......
......@@ -5036,6 +5036,8 @@ TEST(StaticClassFieldsNoErrors) {
"static 'a' = 0;",
"static 'a';",
"static c = [c] = c",
// ASI
"static a = 0\n",
"static a = 0\n b",
......@@ -5126,6 +5128,8 @@ TEST(ClassFieldsNoErrors) {
"'a' = 0;",
"'a';",
"c = [c] = c",
// ASI
"a = 0\n",
"a = 0\n b",
......@@ -5279,6 +5283,8 @@ TEST(StaticClassFieldsErrors) {
"static a b",
"static a = 0 b",
"static c = [1] = [c]",
// ASI requires that the next token is not part of any legal production
"static a = 0\n *b(){}",
"static a = 0\n ['b'](){}",
......@@ -5327,6 +5333,8 @@ TEST(ClassFieldsErrors) {
"a b",
"a = 0 b",
"c = [1] = [c]",
// ASI requires that the next token is not part of any legal production
"a = 0\n *b(){}",
"a = 0\n ['b'](){}",
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[ class { c = [ c ] = c } ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment