Skip to content

Commit c5a8099

Browse files
sygptomato
authored andcommitted
Allow global var-via-eval be declared
See tc39/ecma262#3226
1 parent 046dff4 commit c5a8099

File tree

4 files changed

+28
-55
lines changed

4 files changed

+28
-55
lines changed

test/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js

-21
This file was deleted.

test/annexB/language/eval-code/direct/script-decl-lex-no-collision-in-strict-mode.js renamed to test/annexB/language/eval-code/direct/script-decl-lex-no-collision.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33
/*---
44
esid: sec-globaldeclarationinstantiation
5-
description: No let binding collision with existing var declaration due to strict-mode eval().
5+
description: No let binding collision with existing var declaration due to eval().
66
info: |
7+
In strict mode:
8+
79
PerformEval ( x, strictCaller, direct )
810
911
[...]
1012
16. If direct is true, then
1113
a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment).
1214
[...]
1315
18. If strictEval is true, set varEnv to lexEnv.
14-
flags: [onlyStrict]
16+
17+
In sloppy mode:
18+
19+
GlobalDeclarationInstantiation ( script, env )
20+
21+
[...]
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.
1527
---*/
1628

1729
eval('if (true) { function test262Fn() {} }');

test/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js

-30
This file was deleted.

test/language/global-code/script-decl-lex-var-declared-via-eval-strict.js renamed to test/language/global-code/script-decl-lex-var-declared-via-eval.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33
/*---
44
esid: sec-globaldeclarationinstantiation
5-
description: No let binding collision with existing var declaration due to strict-mode eval().
5+
description: No let binding collision with existing var declaration due to eval().
66
info: |
7+
In strict mode:
8+
79
PerformEval ( x, strictCaller, direct )
810
911
[...]
1012
16. If direct is true, then
1113
a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment).
1214
[...]
1315
18. If strictEval is true, set varEnv to lexEnv.
14-
flags: [onlyStrict]
16+
17+
In sloppy mode:
18+
19+
GlobalDeclarationInstantiation ( script, env )
20+
21+
[...]
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.
1527
---*/
1628

1729
eval('var test262Var;');

0 commit comments

Comments
 (0)