blob: 827e3c6eb1635b19a4160646f976744d93a000b4 [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// 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/*---
4esid: sec-functiondeclarationinstantiation
5description: >
6 Creation of new variable environment for the function body (as disinct from
7 that for the function's parameters)
8info: |
9 [...]
10 26. If hasParameterExpressions is false, then
11 [...]
12 27. Else,
13 a. NOTE A separate Environment Record is needed to ensure that closures
14 created by expressions in the formal parameter list do not have
15 visibility of declarations in the function body.
16 b. Let varEnv be NewDeclarativeEnvironment(env).
17 c. Let varEnvRec be varEnv's EnvironmentRecord.
18 d. Set the VariableEnvironment of calleeContext to varEnv.
19 e. Let instantiatedVarNames be a new empty List.
20 [...]
21---*/
22
23var x = 'outside';
24var probeParams, probeBody;
25
26class C {
27 m(_ = probeParams = function() { return x; }) {
28 var x = 'inside';
29 probeBody = function() { return x; };
30 }
31}
32C.prototype.m();
33
34assert.sameValue(probeParams(), 'outside');
35assert.sameValue(probeBody(), 'inside');