1 // Copyright (C) 2023 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 esid: sec-globaldeclarationinstantiation
5 description: No let binding collision with existing var declaration due to eval().
9 PerformEval ( x, strictCaller, direct )
12 16. If direct is true, then
13 a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment).
15 18. If strictEval is true, set varEnv to lexEnv.
19 GlobalDeclarationInstantiation ( script, env )
22 3. For each element name of lexNames, do
23 a. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
24 b. Let hasRestrictedGlobal be ? env.HasRestrictedGlobalProperty(name).
25 c. NOTE: Global var and function bindings (except those that are introduced by non-strict direct eval) are non-configurable and are therefore restricted global properties.
26 d. If hasRestrictedGlobal is true, throw a SyntaxError exception.
29 eval('var test262Var;');
30 eval('function test262Fn() {}');
32 $262.evalScript('let test262Var = 1;');
33 assert.sameValue(test262Var, 1);
35 $262.evalScript('const test262Fn = 2;');
36 assert.sameValue(test262Fn, 2);