Allen Wirfs-Brock (2013-11-09T00:15:46.000Z)
domenic at domenicdenicola.com (2013-11-13T16:54:33.961Z)
On Nov 8, 2013, at 3:35 PM, Ian Halliday wrote: > That is, consider this code: > > ```js > function f() { > { > var x = 5; > let x; > ``` declaring the same name using a let and a var is an early error: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-block-static-semantics-early-errors or for the function level http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function-definitions-static-semantics-early-errors > I think the var declaration creates a binding for x in the function’s lexical environment, but then binds to the x in the block’s environment for the initialization. As such, the initialization should throw a “use before declaration” error. But this is what I cannot find in the spec. Maybe I am wrong about the semantics here? because an early error exists, the surround script or module is never evaluated.