Block scoping and redeclarations

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Aug 24 09:43:49 PDT 2011


On Aug 24, 2011, at 2:01 AM, Andreas Rossberg wrote:

> On 23 August 2011 19:14, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>> 
> 
> Oh, but that description does not cover Dave's exact example, which actually was
> 
> { { let x; { var x } } }
> 
> Here, the var is hoisted across the let's scope, but doesn't end up in
> the same scope. And we clearly want to rule that out, too. But then,
> you also want to properly distinguish this case from, say

This is essentially the same as the hosting a var out of a catch clause where the var and catch parameter have the same name.

I tried to get that defined as an error for ES5 and it didn't fly because of backwards compat. concerns. I suspect we would come to the same conclusion this time.

But, there is nothing stoping an implementation from issuing a warning for such occurrences.  It might even be a good idea. We might be able to even get agreement to include in the spec. a non-normative recommendation to that regard similarly to what ES5 has regarding function declarations within blocks.


Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110824/d14cfe36/attachment.html>


More information about the es-discuss mailing list