[class] Rewrite destructuring assignment in class field initializers
Bug: v8:5751, chromium:899537 Change-Id: I4c072727dffc9381a81eb8711c4114220345914d Reviewed-on: https://chromium-review.googlesource.com/c/1304538 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#57141}
This commit is contained in:
parent
78c053a5c1
commit
c65dbd5153
@ -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'](){}",
|
||||
|
5
test/mjsunit/regress/regress-899537.js
Normal file
5
test/mjsunit/regress/regress-899537.js
Normal file
@ -0,0 +1,5 @@
|
||||
// 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 } ]
|
Loading…
Reference in New Issue
Block a user