Inconsistent language regarding strict mode restrictions on eval

Brendan Eich brendan at mozilla.org
Mon Oct 11 23:46:09 PDT 2010


On Oct 11, 2010, at 11:31 PM, Jeff Walden wrote:

>> 10.4.2.1  Strict Mode Restrictions
>> 
>> The eval code cannot instantiate variable or function bindings in the
>> variable environment of the calling context that invoked the eval if
>> either the code of the calling context or the eval code is strict code.
>> Instead such bindings are instantiated in a new VariableEnvironment
>> that is only accessible to the eval code.
> 
> At risk of pedantry, this is not consistent with the remainder of ES5.

No pedantry, good catches.

Nit I just noticed: "that is only accessible" should be "that is accessible only" in the spec.

/be


> 
> First: the strictness of the calling context does not affect calculation of eval code's variable environment if the call to eval was indirect (10.4.2 step 3).  Second: for an indirect eval of non-strict code, the variable environment used is the global environment.
> 
> Therefore, if an indirect eval occurs at global level in strict code, it *can* "instantiate variable or function bindings in the variable environment of the calling context that invoked the eval" even though "the code of the calling context...is strict code".  Further, "such bindings are instantiated in a new VariableEnvironment" that is accessible to other global code and to other Programs executed against the global environment, and it is *not* "only accessible to the eval code".
> 
> I suspect this paragraph was meant to be informative rather than normative, and I assume most readers will treat it as such, referring to the paragraph only for basic understanding, not exact detail.  Even still, it shouldn't contradict the rest of the spec.
> 
> Jeff
> _______________________________________________
> es5-discuss mailing list
> es5-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es5-discuss



More information about the es5-discuss mailing list