Open Bug 605515 Opened 14 years ago Updated 2 years ago

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

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect

Tracking

()

Tracking Status
blocking2.0 --- -
status2.0 --- wanted

People

(Reporter: jorendorff, Unassigned)

References

(Blocks 2 open bugs, )

Details

"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.
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: es5strict
No longer blocks: es5
blocking2.0: --- → ?
blocking2.0: ? → betaN+
blocking2.0: betaN+ → -
status2.0: --- → wanted
Assignee: general → nobody
The semantics with checking RHS didn't change in ES6 spec, so this still should throw ReferenceError, because LHS is an unresolved reference.
Blocks: test262
Severity: normal → S3
Duplicate of this bug: 1799290
You need to log in before you can comment on or make changes to this bug.