Assigning to globals in strict mode
oliver at apple.com
Mon Oct 18 10:12:47 PDT 2010
On Oct 18, 2010, at 10:08 AM, Jason Orendorff wrote:
> Oliver's original message seems exactly right to me. I'll spell out
> what I *think* is happening.
> On Sun, Oct 17, 2010 at 4:56 PM, Oliver Hunt <oliver at apple.com> wrote:
>> "use strict"; undeclared = (this.undeclared = 5);
>> Should throw as |undeclared| will not exist when LeftHandSideExpression is evaluated.
> * The left hand side evaluates to an unresolveable strict Reference (§10.2.2.1);
> * the right hand side evaluates to 5;
> * assignment to the Reference throws, because it is still
> unresolveable (see IsUnresolvableReference, §8.7), even though
> undeclared now exists.
Err when does the exception get thrown?
I just realised the spec does not state explicitly when the error should be thrown
"When an assignment occurs within strict mode code, its LeftHandSide must not evaluate to an unresolvable reference. If it does a ReferenceError exception is thrown upon assignment."
Does 'assignment' in that sentence mean when we reach the assignment expression, or does it mean at the point of PutValue()?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es5-discuss