Skip to content

Commit ed75310

Browse files
sygljharb
authored andcommitted
Normative: Remove [[VarNames]] from the global (#3226)
The upshot of this change is that global var bindings introduced by sloppy direct eval becomes redeclarable by lexical bindings.
1 parent ff129b1 commit ed75310

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

spec.html

+4-41
Original file line numberDiff line numberDiff line change
@@ -10862,17 +10862,6 @@ <h1>Global Environment Records</h1>
1086210862
<emu-not-ref>Contains</emu-not-ref> bindings for all declarations in global code for the associated realm code except for |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| bindings.
1086310863
</td>
1086410864
</tr>
10865-
<tr>
10866-
<td>
10867-
[[VarNames]]
10868-
</td>
10869-
<td>
10870-
a List of Strings
10871-
</td>
10872-
<td>
10873-
The string names bound by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| declarations in global code for the associated realm.
10874-
</td>
10875-
</tr>
1087610865
</table>
1087710866
</emu-table>
1087810867
<emu-table id="table-additional-methods-of-global-environment-records" caption="Additional Methods of Global Environment Records" oldids="table-19">
@@ -11053,10 +11042,7 @@ <h1>
1105311042
1. Let _globalObject_ be _ObjRec_.[[BindingObject]].
1105411043
1. Let _existingProp_ be ? HasOwnProperty(_globalObject_, _N_).
1105511044
1. If _existingProp_ is *true*, then
11056-
1. Let _status_ be ? <emu-meta effects="user-code">_ObjRec_.DeleteBinding</emu-meta>(_N_).
11057-
1. If _status_ is *true* and _envRec_.[[VarNames]] contains _N_, then
11058-
1. Remove _N_ from _envRec_.[[VarNames]].
11059-
1. Return _status_.
11045+
1. Return ? <emu-meta effects="user-code">_ObjRec_.DeleteBinding</emu-meta>(_N_).
1106011046
1. Return *true*.
1106111047
</emu-alg>
1106211048
</emu-clause>
@@ -11111,24 +11097,6 @@ <h1>GetThisBinding ( ): a normal completion containing an Object</h1>
1111111097
</emu-alg>
1111211098
</emu-clause>
1111311099

11114-
<emu-clause id="sec-hasvardeclaration" type="abstract operation">
11115-
<h1>
11116-
HasVarDeclaration (
11117-
_envRec_: a Global Environment Record,
11118-
_N_: a String,
11119-
): a Boolean
11120-
</h1>
11121-
<dl class="header">
11122-
<dt>description</dt>
11123-
<dd>It determines if the argument identifier has a binding in _envRec_ that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |AsyncGeneratorDeclaration|.</dd>
11124-
</dl>
11125-
<emu-alg>
11126-
1. Let _varDeclaredNames_ be _envRec_.[[VarNames]].
11127-
1. If _varDeclaredNames_ contains _N_, return *true*.
11128-
1. Return *false*.
11129-
</emu-alg>
11130-
</emu-clause>
11131-
1113211100
<emu-clause id="sec-haslexicaldeclaration" type="abstract operation">
1113311101
<h1>
1113411102
HasLexicalDeclaration (
@@ -11222,7 +11190,7 @@ <h1>
1122211190
</h1>
1122311191
<dl class="header">
1122411192
<dt>description</dt>
11225-
<dd>It creates and initializes a mutable binding in the associated Object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is reused and assumed to be initialized.</dd>
11193+
<dd>It creates and initializes a mutable binding in the associated Object Environment Record. If a binding already exists, it is reused and assumed to be initialized.</dd>
1122611194
</dl>
1122711195
<emu-alg>
1122811196
1. Let _ObjRec_ be _envRec_.[[ObjectRecord]].
@@ -11232,8 +11200,6 @@ <h1>
1123211200
1. If _hasProperty_ is *false* and _extensible_ is *true*, then
1123311201
1. Perform ? <emu-meta effects="user-code">_ObjRec_.CreateMutableBinding</emu-meta>(_N_, _D_).
1123411202
1. Perform ? <emu-meta effects="user-code">_ObjRec_.InitializeBinding</emu-meta>(_N_, *undefined*).
11235-
1. If _envRec_.[[VarNames]] does not contain _N_, then
11236-
1. Append _N_ to _envRec_.[[VarNames]].
1123711203
1. Return ~unused~.
1123811204
</emu-alg>
1123911205
</emu-clause>
@@ -11249,7 +11215,7 @@ <h1>
1124911215
</h1>
1125011216
<dl class="header">
1125111217
<dt>description</dt>
11252-
<dd>It creates and initializes a mutable binding in the associated Object Environment Record and records the bound name in the associated [[VarNames]] List. If a binding already exists, it is replaced.</dd>
11218+
<dd>It creates and initializes a mutable binding in the associated Object Environment Record. If a binding already exists, it is replaced.</dd>
1125311219
</dl>
1125411220
<emu-alg>
1125511221
1. Let _ObjRec_ be _envRec_.[[ObjectRecord]].
@@ -11261,8 +11227,6 @@ <h1>
1126111227
1. Let _desc_ be the PropertyDescriptor { [[Value]]: _V_ }.
1126211228
1. Perform ? DefinePropertyOrThrow(_globalObject_, _N_, _desc_).
1126311229
1. [id="step-createglobalfunctionbinding-set"] Perform ? Set(_globalObject_, _N_, _V_, *false*).
11264-
1. If _envRec_.[[VarNames]] does not contain _N_, then
11265-
1. Append _N_ to _envRec_.[[VarNames]].
1126611230
1. Return ~unused~.
1126711231
</emu-alg>
1126811232
<emu-note>
@@ -11480,7 +11444,6 @@ <h1>
1148011444
1. Set _env_.[[ObjectRecord]] to _objRec_.
1148111445
1. Set _env_.[[GlobalThisValue]] to _thisValue_.
1148211446
1. Set _env_.[[DeclarativeRecord]] to _dclRec_.
11483-
1. Set _env_.[[VarNames]] to a new empty List.
1148411447
1. Set _env_.[[OuterEnv]] to *null*.
1148511448
1. Return _env_.
1148611449
</emu-alg>
@@ -26119,9 +26082,9 @@ <h1>
2611926082
1. Let _lexNames_ be the LexicallyDeclaredNames of _script_.
2612026083
1. Let _varNames_ be the VarDeclaredNames of _script_.
2612126084
1. For each element _name_ of _lexNames_, do
26122-
1. If HasVarDeclaration(_env_, _name_) is *true*, throw a *SyntaxError* exception.
2612326085
1. If HasLexicalDeclaration(_env_, _name_) is *true*, throw a *SyntaxError* exception.
2612426086
1. Let _hasRestrictedGlobal_ be ? HasRestrictedGlobalProperty(_env_, _name_).
26087+
1. 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.
2612526088
1. If _hasRestrictedGlobal_ is *true*, throw a *SyntaxError* exception.
2612626089
1. For each element _name_ of _varNames_, do
2612726090
1. If HasLexicalDeclaration(_env_, _name_) is *true*, throw a *SyntaxError* exception.

0 commit comments

Comments
 (0)