| 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-function-definitions-runtime-semantics-iteratorbindinginitialization |
| 5 |
description: > |
| 6 |
Removal of variable environment for the BindingRestElement formal parameter |
| 7 |
info: | |
| 8 |
[...] |
| 9 |
2. Let currentContext be the running execution context. |
| 10 |
3. Let originalEnv be the VariableEnvironment of currentContext. |
| 11 |
4. Assert: The VariableEnvironment and LexicalEnvironment of currentContext |
| 12 |
are the same. |
| 13 |
5. Assert: environment and originalEnv are the same. |
| 14 |
6. Let paramVarEnv be NewDeclarativeEnvironment(originalEnv). |
| 15 |
7. Set the VariableEnvironment of currentContext to paramVarEnv. |
| 16 |
8. Set the LexicalEnvironment of currentContext to paramVarEnv. |
| 17 |
9. Let result be the result of performing IteratorBindingInitialization for |
| 18 |
BindingRestElement using iteratorRecord and environment as the |
| 19 |
arguments. |
| 20 |
10. Set the VariableEnvironment of currentContext to originalEnv. |
| 21 |
11. Set the LexicalEnvironment of currentContext to originalEnv. |
| 22 |
[...] |
| 23 |
flags: [noStrict] |
| 24 |
---*/ |
| 25 |
|
| 26 |
var x = 'outside'; |
| 27 |
var probeParam, probeBody; |
| 28 |
|
| 29 |
(( |
| 30 |
...[_ = (eval('var x = "inside";'), probeParam = function() { return x; })] |
| 31 |
) => { |
| 32 |
probeBody = function() { return x; } |
| 33 |
})(); |
| 34 |
|
| 35 |
assert.sameValue(probeParam(), 'inside'); |
| 36 |
assert.sameValue(probeBody(), 'outside'); |