Conflicting declarations -- Was: Re: local

Waldemar Horwat waldemar at
Fri Aug 22 12:40:51 PDT 2008

Brendan Eich wrote:
> On Aug 22, 2008, at 7:26 AM, Ingvar von Schoultz wrote:
>> Brendan Eich wrote:
>>> More helpful would be comments on the utility of let blocks  
>>> (a.k.a. let statements) and let expressions.
>> While reading up on this, I noticed that you can declare the
>> same name with both let and var in the same scope:
>>     var x = 'global';
>>     let x = 42;
> If these are both within an explicit block, the let will shadow the  
> hoisted var.

This one is bizarre and infrequent enough that I wouldn't mind if we made this into an error -- specifically, you can't write "var x" inside a block that contains a "let x" if that var would hoist to or beyond that let's block.


More information about the Es-discuss mailing list