Skip to content

Commit e43f65f

Browse files
committed
Normative: Remove [[VarNames]] from the global
The upshot of this change is that global var bindings introduced by sloppy direct eval becomes redeclarable by lexical bindings.
1 parent fe206cd commit e43f65f

File tree

1 file changed

+4
-51
lines changed

1 file changed

+4
-51
lines changed

spec.html

+4-51
Original file line numberDiff line numberDiff line change
@@ -10869,17 +10869,6 @@ <h1>Global Environment Records</h1>
1086910869
<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.
1087010870
</td>
1087110871
</tr>
10872-
<tr>
10873-
<td>
10874-
[[VarNames]]
10875-
</td>
10876-
<td>
10877-
a List of Strings
10878-
</td>
10879-
<td>
10880-
The string names bound by |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, |AsyncGeneratorDeclaration|, and |VariableDeclaration| declarations in global code for the associated realm.
10881-
</td>
10882-
</tr>
1088310872
</table>
1088410873
</emu-table>
1088510874
<emu-table id="table-additional-methods-of-global-environment-records" caption="Additional Methods of Global Environment Records" oldids="table-19">
@@ -10902,14 +10891,6 @@ <h1>Global Environment Records</h1>
1090210891
Return the value of this Environment Record's `this` binding.
1090310892
</td>
1090410893
</tr>
10905-
<tr>
10906-
<td>
10907-
HasVarDeclaration (N)
10908-
</td>
10909-
<td>
10910-
Determines if the argument identifier has a binding in this Environment Record that was created using a |VariableDeclaration|, |FunctionDeclaration|, |GeneratorDeclaration|, |AsyncFunctionDeclaration|, or |AsyncGeneratorDeclaration|.
10911-
</td>
10912-
</tr>
1091310894
<tr>
1091410895
<td>
1091510896
HasLexicalDeclaration (N)
@@ -11117,10 +11098,7 @@ <h1>
1111711098
1. Let _globalObject_ be _ObjRec_.[[BindingObject]].
1111811099
1. Let _existingProp_ be ? HasOwnProperty(_globalObject_, _N_).
1111911100
1. If _existingProp_ is *true*, then
11120-
1. Let _status_ be ? <emu-meta effects="user-code">_ObjRec_.DeleteBinding</emu-meta>(_N_).
11121-
1. If _status_ is *true* and _envRec_.[[VarNames]] contains _N_, then
11122-
1. Remove _N_ from _envRec_.[[VarNames]].
11123-
1. Return _status_.
11101+
1. Return ? <emu-meta effects="user-code">_ObjRec_.DeleteBinding</emu-meta>(_N_).
1112411102
1. Return *true*.
1112511103
</emu-alg>
1112611104
</emu-clause>
@@ -11175,26 +11153,6 @@ <h1>GetThisBinding ( ): a normal completion containing an Object</h1>
1117511153
</emu-alg>
1117611154
</emu-clause>
1117711155

11178-
<emu-clause id="sec-hasvardeclaration" type="concrete method">
11179-
<h1>
11180-
HasVarDeclaration (
11181-
_N_: a String,
11182-
): a Boolean
11183-
</h1>
11184-
<dl class="header">
11185-
<dt>for</dt>
11186-
<dd>a Global Environment Record _envRec_</dd>
11187-
11188-
<dt>description</dt>
11189-
<dd>It determines if the argument identifier has a binding in this record that was created using a |VariableStatement| or a |FunctionDeclaration|.</dd>
11190-
</dl>
11191-
<emu-alg>
11192-
1. Let _varDeclaredNames_ be _envRec_.[[VarNames]].
11193-
1. If _varDeclaredNames_ contains _N_, return *true*.
11194-
1. Return *false*.
11195-
</emu-alg>
11196-
</emu-clause>
11197-
1119811156
<emu-clause id="sec-haslexicaldeclaration" type="concrete method">
1119911157
<h1>
1120011158
HasLexicalDeclaration (
@@ -11298,7 +11256,7 @@ <h1>
1129811256
<dd>a Global Environment Record _envRec_</dd>
1129911257

1130011258
<dt>description</dt>
11301-
<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>
11259+
<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>
1130211260
</dl>
1130311261
<emu-alg>
1130411262
1. Let _ObjRec_ be _envRec_.[[ObjectRecord]].
@@ -11308,8 +11266,6 @@ <h1>
1130811266
1. If _hasProperty_ is *false* and _extensible_ is *true*, then
1130911267
1. Perform ? <emu-meta effects="user-code">_ObjRec_.CreateMutableBinding</emu-meta>(_N_, _D_).
1131011268
1. Perform ? <emu-meta effects="user-code">_ObjRec_.InitializeBinding</emu-meta>(_N_, *undefined*).
11311-
1. If _envRec_.[[VarNames]] does not contain _N_, then
11312-
1. Append _N_ to _envRec_.[[VarNames]].
1131311269
1. Return ~unused~.
1131411270
</emu-alg>
1131511271
</emu-clause>
@@ -11327,7 +11283,7 @@ <h1>
1132711283
<dd>a Global Environment Record _envRec_</dd>
1132811284

1132911285
<dt>description</dt>
11330-
<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>
11286+
<dd>It creates and initializes a mutable binding in the associated Object Environment Record. If a binding already exists, it is replaced.</dd>
1133111287
</dl>
1133211288
<emu-alg>
1133311289
1. Let _ObjRec_ be _envRec_.[[ObjectRecord]].
@@ -11339,8 +11295,6 @@ <h1>
1133911295
1. Let _desc_ be the PropertyDescriptor { [[Value]]: _V_ }.
1134011296
1. Perform ? DefinePropertyOrThrow(_globalObject_, _N_, _desc_).
1134111297
1. [id="step-createglobalfunctionbinding-set"] Perform ? Set(_globalObject_, _N_, _V_, *false*).
11342-
1. If _envRec_.[[VarNames]] does not contain _N_, then
11343-
1. Append _N_ to _envRec_.[[VarNames]].
1134411298
1. Return ~unused~.
1134511299
</emu-alg>
1134611300
<emu-note>
@@ -11569,7 +11523,6 @@ <h1>
1156911523
1. Set _env_.[[ObjectRecord]] to _objRec_.
1157011524
1. Set _env_.[[GlobalThisValue]] to _thisValue_.
1157111525
1. Set _env_.[[DeclarativeRecord]] to _dclRec_.
11572-
1. Set _env_.[[VarNames]] to a new empty List.
1157311526
1. Set _env_.[[OuterEnv]] to *null*.
1157411527
1. Return _env_.
1157511528
</emu-alg>
@@ -26156,9 +26109,9 @@ <h1>
2615626109
1. Let _lexNames_ be the LexicallyDeclaredNames of _script_.
2615726110
1. Let _varNames_ be the VarDeclaredNames of _script_.
2615826111
1. For each element _name_ of _lexNames_, do
26159-
1. If _env_.HasVarDeclaration(_name_) is *true*, throw a *SyntaxError* exception.
2616026112
1. If _env_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception.
2616126113
1. Let _hasRestrictedGlobal_ be ? _env_.HasRestrictedGlobalProperty(_name_).
26114+
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.
2616226115
1. If _hasRestrictedGlobal_ is *true*, throw a *SyntaxError* exception.
2616326116
1. For each element _name_ of _varNames_, do
2616426117
1. If _env_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception.

0 commit comments

Comments
 (0)