Skip to content

Commit

Permalink
Normative: Re-resolve unresolvable references on the global in PutValue.
Browse files Browse the repository at this point in the history
Currently, JSC, V8, SM, and XS all *do not throw* on the following code,
contra spec:

```javascript
"use strict";
undeclared = (this.undeclared = 42);
```

This has been a bug in implementations for a decade
(https://bugzilla.mozilla.org/show_bug.cgi?id=605515), and is arguably
implementation reality not only for the web but for most
implementations.

This changes the spec to match the implemented re-resolution behavior.

Also see
- tc39#467
- tc39/test262#1964
  • Loading branch information
syg committed Oct 14, 2020
1 parent f2eb022 commit dcafa83
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -3821,10 +3821,14 @@ <h1>PutValue ( _V_, _W_ )</h1>
1. If Type(_V_) is not Reference, throw a *ReferenceError* exception.
1. Let _base_ be GetBase(_V_).
1. If IsUnresolvableReference(_V_) is *true*, then
1. Let _name_ be GetReferencedName(_V_).
1. If IsStrictReference(_V_) is *true*, then
1. Throw a *ReferenceError* exception.
1. Let _realm_ be the current Realm Record.
1. Set _V_ to ? ResolveBinding(_realm_.[[GlobalEnv]], _name_).
1. Assert: IsStrictReference(_V_) is *true*.
1. If IsUnresolvableReference(_V_) is *true*, throw a *ReferenceError* exception.
1. Let _globalObj_ be GetGlobalObject().
1. Return ? Set(_globalObj_, GetReferencedName(_V_), _W_, *false*).
1. Return ? Set(_globalObj_, _name_, _W_, *false*).
1. Else if IsPropertyReference(_V_) is *true*, then
1. If HasPrimitiveBase(_V_) is *true*, then
1. Assert: In this case, _base_ will never be *undefined* or *null*.
Expand Down

0 comments on commit dcafa83

Please sign in to comment.