Commit 5b4d4c24 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Parenthesized identifiers are invalid as part of a declaration

Bug: v8:8659
Change-Id: I7208589dcb5c40dd915a50517f83f3da646202be
Reviewed-on: https://chromium-review.googlesource.com/c/1402547Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58657}
parent c26b4977
......@@ -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)) {
......
// 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);
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