v8/test/mjsunit/regress/regress-crbug-807096.js
Adam Klein f1a551800f [parser] More carefully handle destructuring in arrow params
This patch attempts to reduce the special handling of destructuring
assignments in arrow function parameters by "adopting" them from
wherever they were initially parsed into the arrow function's
FunctionState/Scope. This avoids incorrectly re-setting the
Scope of such assignments multiple times for arrow functions
that are nested inside other arrow params themselves.

It also generally seems better, in that we now only rewrite
destructuring assignments for a single function at a time.

Bug: chromium:807096
Change-Id: I6bef5613f99e3e8c130fc0aa2ee5d6fcf2efd34b
Reviewed-on: https://chromium-review.googlesource.com/900168
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Caitlin Potter <caitp@igalia.com>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51155}
2018-02-07 18:14:28 +00:00

28 lines
681 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.
//
// Flags: --allow-natives-syntax --no-lazy
// For regression testing, it's important that these functions are:
// 1) toplevel
// 2) arrow functions with single-expression bodies
// 3) eagerly compiled
let f = ({a = (({b = {a = c} = {
a: 0x1234
}}) => 1)({})}, c) => 1;
assertThrows(() => f({}), ReferenceError);
let g = ({a = (async ({b = {a = c} = {
a: 0x1234
}}) => 1)({})}, c) => a;
testAsync(assert => {
assert.plan(1);
g({}).catch(e => {
assert.equals("ReferenceError", e.name);
});
});