Strict mode code should throw ReferenceError when assigning to a global if it doesn't exist at BINDNAME time

NEW
Unassigned

Status

()

Core
JavaScript Engine
7 years ago
2 years ago

People

(Reporter: jorendorff, Unassigned)

Tracking

(Blocks: 1 bug)

Other Branch
Points:
---

Firefox Tracking Flags

(blocking2.0 -, status2.0 wanted)

Details

(URL)

(Reporter)

Description

7 years ago
"use strict";
var ok = false;
try {
    undeclared = (this.undeclared = 5);
} catch (exc) {
    ok = exc instanceof ReferenceError;
}
assertEq(ok, true);


Per ES5, this assignment to undeclared should throw a ReferenceError in strict mode. In detail,

    undeclared = (this.undeclared = 5);

* The LHS evaluates to an unresolveable strict Reference (ES5 §10.2.2.1);
* the RHS evaluates to 5;
* assignment to the Reference throws, because it is still
unresolveable (see IsUnresolvableReference, §8.7), even though
undeclared now exists.
(Reporter)

Updated

7 years ago
Summary: Assigning to globals in strict mode → Strict mode code should throw ReferenceError when assigning to a global if it doesn't exist at BINDNAME time
If Allen's fix makes it into an erratum, then there'll be a check before RHS evaluation. But we need a check somewhere.

/be
Blocks: 482298
No longer blocks: 445494
blocking2.0: --- → ?

Updated

7 years ago
blocking2.0: ? → betaN+
This one's been sitting for a while. ES5 experts, are you guys going to fix this for Fx4?

Updated

7 years ago
blocking2.0: betaN+ → -
status2.0: --- → wanted

Comment 3

3 years ago
Status?
(Assignee)

Updated

3 years ago
Assignee: general → nobody

Comment 4

2 years ago
The semantics with checking RHS didn't change in ES6 spec, so this still should throw ReferenceError, because LHS is an unresolved reference.
You need to log in before you can comment on or make changes to this bug.