On Nov 8, 2013, at 3:35 PM, Ian Halliday wrote:

> Hello es-discuss,
>  
> I’m having difficulty figuring out where the ES6 draft spec specifies that a 
> “use before declaration” error should be thrown.  My last understanding of 
> the temporal dead zone was that ECMAScript would always issue a “use before 
> declaration” error at runtime, regardless whether it can be statically 
> determined or not.  However it seems like the evaluation semantics of var 
> declarations, for example, do not lead to any line that throws a 
> ReferenceError.


>  
> That is, consider this code:
>  
> 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
 


>     }
> }
> 
> f();
> 
> 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.

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to