v8/test/mjsunit/regress/regress-crbug-768158.js
Adam Klein 0717ff3457 [parser] Ensure for-in/of loop variables are marked maybe_assigned
The code used to rely on all such loops having a block scope around
them, but that is no longer the case for loops whose loop variables
are VAR-declared.

This patch introduces a new DeclarationDescriptor::Kind for such
variables, and sets it during parsing, allowing the variable
declaration code to note them as assigned appropriately.

Bug: chromium:768158
Change-Id: I0cd60e8c8c735681be9dbb9344a93156af09c952
Reviewed-on: https://chromium-review.googlesource.com/701624
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48320}
2017-10-05 19:16:29 +00:00

24 lines
572 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.
//
// Flags: --always-opt
(function testOriginalRepro() {
var result;
var dict = { toString() { result = v;} };
for (var v of ['fontsize', 'sup']) {
String.prototype[v].call(dict);
assertEquals(v, result);
}
})();
(function testSimpler() {
var result;
function setResult() { result = v; }
for (var v of ['hello', 'world']) {
setResult();
assertEquals(v, result);
}
})();