Inconsistent language regarding strict mode restrictions on eval
jwalden+es at MIT.EDU
Mon Oct 11 23:31:39 PDT 2010
> 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.
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.
More information about the es5-discuss