| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation |
| 5 |
description: > |
| 6 |
No variable environment is created for the statement "head" |
| 7 |
info: | |
| 8 |
IterationStatement : for ( ForDeclaration of AssignmentExpression ) Statement |
| 9 |
|
| 10 |
1. Let keyResult be the result of performing ? |
| 11 |
ForIn/OfHeadEvaluation(BoundNames of ForDeclaration, |
| 12 |
AssignmentExpression, iterate). |
| 13 |
[...] |
| 14 |
|
| 15 |
13.7.5.12 Runtime Semantics: ForIn/OfHeadEvaluation |
| 16 |
|
| 17 |
[...] |
| 18 |
2. If TDZnames is not an empty List, then |
| 19 |
a. Assert: TDZnames has no duplicate entries. |
| 20 |
b. Let TDZ be NewDeclarativeEnvironment(oldEnv). |
| 21 |
c. Let TDZEnvRec be TDZ's EnvironmentRecord. |
| 22 |
d. For each string name in TDZnames, do |
| 23 |
i. Perform ! TDZEnvRec.CreateMutableBinding(name, false). |
| 24 |
e. Set the running execution context's LexicalEnvironment to TDZ. |
| 25 |
3. Let exprRef be the result of evaluating expr. |
| 26 |
[...] |
| 27 |
flags: [noStrict] |
| 28 |
---*/ |
| 29 |
|
| 30 |
var probeBefore = function() { return x; }; |
| 31 |
var x = 1; |
| 32 |
var probeDecl, probeExpr, probeBody; |
| 33 |
|
| 34 |
for ( |
| 35 |
let [_ = probeDecl = function() { return x; }] |
| 36 |
in |
| 37 |
{ '': (eval('var x = 2;'), probeExpr = function() { return x; }) } |
| 38 |
) |
| 39 |
probeBody = function() { return x; }; |
| 40 |
|
| 41 |
assert.sameValue(probeBefore(), 2, 'reference preceding statement'); |
| 42 |
assert.sameValue(probeDecl(), 2, 'reference from ForDeclaration'); |
| 43 |
assert.sameValue(probeExpr(), 2, 'reference from AssignmentExpression'); |
| 44 |
assert.sameValue(probeBody(), 2, 'reference from statement body'); |
| 45 |
assert.sameValue(x, 2, 'reference following statement'); |
| 46 |
|
| 47 |
reportCompare(0, 0); |