Assigning to globals in strict mode

Maciej Stachowiak mjs at
Tue Oct 19 17:53:49 PDT 2010

On Oct 19, 2010, at 5:36 PM, Brendan Eich wrote:

> On Oct 19, 2010, at 4:22 PM, Oliver Hunt wrote:
>> On Oct 19, 2010, at 4:19 PM, Maciej Stachowiak wrote:
>>> If Harmony is going to require the other behavior, how about an erratum to make ES5 strict mode the same? There doesn't seem to be much reason to have a future behavior difference here.
>> In harmony you have a purely lexical scope, eg. the global object is not at the head of the scope chain.  That means all unqualified names can be resolved statically so all these errors become early errors.
>> In ES5 there is both with() and the global object that make early errors incompatible.
> Exactly. (BTW, do people use "head" for the far end of the scope chain? I try to be consistent in using "tail", myself... ;-)
> Plus, ES5 is "done". Sure, there are errata and will be more. But too many errata, especially "big" ones (even if "small" in spec language terms; I mean by "big" that they have significant implications for implementors and possibly for other parts of the spec, without enough time to study the big picture), seem likely to cause trouble.

Just to make sure I'm clear on this, will the following program have the same effect in ES5 strict mode and Harmony, or no?

"use strict";
var declared = 0;
undeclared = declared++;

My understanding is that in ES5 strict mode, declared ends up 1, but in Harmony it ends up 0. In both cases, undeclared is left undefined. Is that correct? Or maybe by "early error" you mean it's a parse error and therefore in Harmony, declared will not be defined at all.


More information about the es5-discuss mailing list