[parser] Parenthesized identifiers are invalid as part of a declaration
Bug: v8:8659 Change-Id: I7208589dcb5c40dd915a50517f83f3da646202be Reviewed-on: https://chromium-review.googlesource.com/c/1402547 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#58657}
This commit is contained in:
parent
c26b4977d6
commit
5b4d4c2401
@ -4320,6 +4320,11 @@ ParserBase<Impl>::ParsePossibleDestructuringSubPattern(
|
||||
// themselves are not allowed, e.g., "[(x)] = []". Only accumulate
|
||||
// assignment pattern errors if the parsed expression is more complex.
|
||||
if (impl()->IsIdentifier(result)) {
|
||||
if (result->is_parenthesized()) {
|
||||
expression_scope()->RecordDeclarationError(
|
||||
Scanner::Location(begin, end_position()),
|
||||
MessageTemplate::kInvalidDestructuringTarget);
|
||||
}
|
||||
IdentifierT identifier = impl()->AsIdentifier(result);
|
||||
ClassifyParameter(identifier, begin, end_position());
|
||||
if (impl()->IsLet(identifier)) {
|
||||
|
5
test/mjsunit/regress/regress-8659.js
Normal file
5
test/mjsunit/regress/regress-8659.js
Normal file
@ -0,0 +1,5 @@
|
||||
// Copyright 2019 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.
|
||||
|
||||
assertThrows("const [(x)] = []", SyntaxError);
|
Loading…
Reference in New Issue
Block a user