v8/test/mjsunit/regress/regress-crbug-740591.js
Adam Klein f1f2285715 Rewrite scopes of initializers in for-in/of destructured declarations
Bug: chromium:740591
Change-Id: I869be41d8630b23704b9470c4d3db8a21bbde873
Reviewed-on: https://chromium-review.googlesource.com/583531
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46881}
2017-07-25 18:26:16 +00:00

38 lines
920 B
JavaScript

// Copyright 2017 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.
(function regressionCaseOne() {
var c;
for (let [a, b = c = function() { return a + b }] of [[0]]) {
function f() { return a };
}
c();
})();
(function testForInFunction() {
for (const {length: a, b = function() { return a, b }} in {foo: 42}) {
assertSame(b, (function() { return b() })());
}
})();
(function testForOfFunction() {
for (const [a, b = function() { return a, b }] of [[42]]) {
assertSame(b, (function() { return b() })());
}
})();
(function testForInVariableProxy() {
for (const {length: a, b = a} in {foo: 42}) {
assertEquals(3, a);
assertEquals(a, b);
}
})();
(function testForOfVariableProxy() {
for (const [a, b = a] of [[42]]) {
assertEquals(42, a);
assertEquals(a, b);
}
})();