> On Fri, Aug 22, 2008 at 12:40 PM, Waldemar Horwat <[EMAIL PROTECTED]> wrote:
>> Brendan Eich wrote:
>>> On Aug 22, 2008, at 7:26 AM, Ingvar von Schoultz wrote:
>>>> 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.

On Fri, Aug 22, 2008 at 2:04 PM, Mark S. Miller <[EMAIL PROTECTED]> wrote:
> I agree that this should be a static error.


Even this simple cleanup has surprising consequences. If

function() {
   ...
   {
     var x = 'global';
     let x = 42;
   }
}

is a static error, then so should

function() {
   ...
   {
     var x = 'global';
     const x = 42;
   }
}

and

function() {
   ...
   {
     var x = 'global';
     function x() 42;
   }
}

The last of these differs from the current behavior 4/4 existing
browsers. However, I still think it's the right thing, and it is
upwards compatible from ES3 (which prohibits nested named function
declarations).


-- 
    Cheers,
    --MarkM
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to