096125deaa
Fix an earlier regression which forbid non-VariableProxy LHS from being used in for-of loops. Like for-in loops, the spec allows any LHS to be used, with the sole exception that ObjectLiterals and ArrayLiterals must be valid AssignmentPatterns. Also fixes a bug in TurboFan which resulted in incorrectly replacing a variable load with a constant value in some instances, due to the AstLoopAssignmentAnalyzer failing to record the assignment to ForOfStatement's value. BUG=v8:4418, v8:2720 LOG=N R=wingo@igalia.com, littledan@chromium.org, adamk@chromium.org, bmeurer@chromium.org Review URL: https://codereview.chromium.org/1411873004 Cr-Commit-Position: refs/heads/master@{#31816}
25 lines
523 B
JavaScript
25 lines
523 B
JavaScript
// Copyright 2015 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 TestForOfName() {
|
|
var result = 0;
|
|
var index;
|
|
|
|
for (index of [1, 2, 3, 4, 5]) result += index;
|
|
|
|
assertEquals(result, 15);
|
|
assertEquals(index, 5);
|
|
})();
|
|
|
|
|
|
(function TestForOfProperty() {
|
|
var O = {};
|
|
var result = 0;
|
|
|
|
for (O.index of [1, 2, 3, 4, 5]) result += O.index;
|
|
|
|
assertEquals(result, 15);
|
|
assertEquals(O.index, 5);
|
|
})();
|