Assigning to globals in strict mode

Oliver Hunt 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.
> 
> Right.
> 
> * 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()?

--Oliver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es5-discuss/attachments/20101018/e1612383/attachment.html>


More information about the es5-discuss mailing list