Debian Codegraph @

js/src/tests/test262/language/expressions/optional-chaining/eval-optional-call.js

raw
1 // Copyright 2020 Toru Nagashima. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-optional-chaining-chain-evaluation
5 description: optional call invoked on eval function should be indirect eval.
6 info: |
7 Runtime Semantics: ChainEvaluation
8 OptionalChain: ?. Arguments
9 1. Let thisChain be this OptionalChain.
10 2. Let tailCall be IsInTailPosition(thisChain).
11 3. Return ? EvaluateCall(baseValue, baseReference, Arguments, tailCall).
12
13 Runtime Semantics: EvaluateCall ( func, ref, arguments, tailPosition )
14
15 ...
16 7. Let result be Call(func, thisValue, argList).
17 ...
18
19 eval ( x )
20
21 ...
22 4. Return ? PerformEval(x, callerRealm, false, false).
23
24 Runtime Semantics: PerformEval ( x, callerRealm, strictCaller, direct )
25 features: [optional-chaining]
26 ---*/
27
28 const a = 'global';
29
30 function fn() {
31 const a = 'local';
32 return eval?.('a');
33 }
34
35 assert.sameValue(fn(), 'global', 'fn() returns "global" value from indirect eval');
36
37 const b = (a => eval?.('a'))('local');
38
39 assert.sameValue(b, 'global', 'b is "global", from indirect eval not observing parameter');
40
41 reportCompare(0, 0);