6c2cc582e5
Keep track of loop nesting depth on FunctionState and use that to decide whether to mark var as assigned. That also fixes the weird cornercase where a loop body can have multiple expressions due to multiple declarations with independent initializers in a single var-statement. Change-Id: Ia24affde29e22e9464448fd390062f6dd983faf2 Reviewed-on: https://chromium-review.googlesource.com/c/1405037 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#58707}
15 lines
538 B
JavaScript
15 lines
538 B
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
|
|
function f() {
|
|
// Loop with a body that's not wrapped in a block.
|
|
for (i = 0; i < 2; i++)
|
|
var x = i, // var x that's assigned on each iteration
|
|
y = y||(()=>x), // single arrow function that returns x
|
|
z = (%OptimizeFunctionOnNextCall(y), y()); // optimize y on first iteration
|
|
return y()
|
|
};
|
|
assertEquals(1, f())
|