Andreas Rossberg (2013-08-20T11:13:07.000Z)
domenic at domenicdenicola.com (2013-08-23T16:06:10.827Z)
> This difference was introduced between 8. Dec. 2008 and 15. Dec. 2008, in > the earlier drafts both, function declarations and function expressions, > used the LexicalEnvironment of the running execution context for their > [[Scope]]. And this is also what ES3 specified ("Pass in the scope chain of > the running execution context as the Scope."). So maybe this is just another > bug in the ES5 specification? I tend to agree that this particular detail should be considered a spec bug. As far as I can tell, examples like the above are the only way one can actually tell the difference in proper ES5, and it seems rather wrong there. In all other contexts allowing function declarations, Lexical- and VariableEnvironment are the same anyway. Perhaps this change was made in vague anticipation of local function declarations? Either way, for ES6, this necessarily will change back again, since otherwise lexical scoping for function declarations would be completely broken. The current draft already does the equivalent (modulo some major refactoring).