06f8463004
This reverts commit 99fd5b9b9d
.
Reason for revert: fails presubmit test:
https://ci.chromium.org/p/v8/builders/ci/V8%20Presubmit/5238
and a nosnap test
https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/34143
Original change's description:
> Let all early errors be SyntaxErrors.
>
> Implement the spec change from the following TC39 PR:
> https://github.com/tc39/ecma262/pull/1527
>
> Bug: v8:9326
> Change-Id: I9639903b12e7621e323990e2335f00e0313a59c3
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643171
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Commit-Queue: Adam Klein <adamk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62451}
TBR=adamk@chromium.org,verwaest@chromium.org,rkirsling@gmail.com
Change-Id: If63b97725e9737ad5a98800e1194caf8e9c1c43d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9326
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682393
Reviewed-by: Francis McCabe <fgm@chromium.org>
Commit-Queue: Francis McCabe <fgm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62452}
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
// 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.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
// Parameters can't have parentheses (both patterns and identifiers)
|
|
assertThrows("( ({x: 1}) ) => {};", SyntaxError);
|
|
assertThrows("( (x) ) => {}", SyntaxError);
|
|
assertThrows("( ({x: 1}) = y ) => {}", ReferenceError);
|
|
assertThrows("( (x) = y ) => {}", SyntaxError);
|
|
|
|
// Declarations can't have parentheses (both patterns and identifiers)
|
|
assertThrows("let [({x: 1})] = [];", SyntaxError);
|
|
assertThrows("let [(x)] = [];", SyntaxError);
|
|
assertThrows("let [({x: 1}) = y] = [];", SyntaxError);
|
|
assertThrows("let [(x) = y] = [];", SyntaxError);
|
|
assertThrows("var [({x: 1})] = [];", SyntaxError);
|
|
assertThrows("var [(x)] = [];", SyntaxError);
|
|
assertThrows("var [({x: 1}) = y] = [];", SyntaxError);
|
|
assertThrows("var [(x) = y] = [];", SyntaxError);
|
|
|
|
// Patterns can't have parentheses in assignments either
|
|
assertThrows("[({x: 1}) = y] = [];", ReferenceError);
|
|
assertThrows("({a,b}) = {a:2,b:3}", ReferenceError);
|
|
|
|
// Parentheses are fine around identifiers in assignments though, even inside a
|
|
// pattern
|
|
var x;
|
|
[(x)] = [2];
|
|
assertEquals(x, 2);
|
|
[(x) = 3] = [];
|
|
assertEquals(x, 3);
|