v8/test/mjsunit/regress/regress-852765.js
Toon Verwaest e167ad823e [parser] Reduce reliance on ExpressionClassifier to detect pattern errors
Rather check expressions used as patterns directly. Check parentheses by
tagging parenthesized expressions as parenthesized.

This allows us to drop UnexpectedPatternToken and makes it clear why a specific
token is unexpected (because it's invalid in a binding pattern).

This also more uniformly restores messages like "Invalid destructuring
assignment target".

Change-Id: Idd98e9116c85de4c2304cf1fef1baa097b67149d
Reviewed-on: https://chromium-review.googlesource.com/c/1349572
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57792}
2018-11-23 16:59:47 +00:00

18 lines
919 B
JavaScript

// 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.
// The actual regression test
assertThrows("(import(foo)) =>", undefined, "Invalid destructuring assignment target");
// Other related tests
assertThrows("import(foo) =>", undefined, "Malformed arrow function parameter list");
assertThrows("(a, import(foo)) =>", undefined, "Invalid destructuring assignment target");
assertThrows("(1, import(foo)) =>", undefined, "Invalid destructuring assignment target");
assertThrows("(super(foo)) =>", undefined, "'super' keyword unexpected here");
assertThrows("(bar(foo)) =>", undefined, "Invalid destructuring assignment target");
// No syntax errors
assertThrows("[import(foo).then] = [1];", undefined, "foo is not defined");
assertThrows("[[import(foo).then]] = [[1]];", undefined, "foo is not defined");