let/const in switch cases
rossberg at google.com
Tue Aug 14 05:05:42 PDT 2012
On 10 August 2012 05:48, Brendan Eich <brendan at mozilla.org> wrote:
> Luke Hoban wrote:
>> Current Chrome builds appear to follow this approach, reporting that
>> the 'let' in the initial code sample above appears in an 'unprotected
>> statement context'.
> Are we all trying to follow the draft spec, or not? Thanks for proposing to
> change it first. Implementations deviating without talking first =
To be fair, IIRC we implemented that before there was much of a spec
covering details like that. So we picked what we thought makes most
sense (and is most conservative).
Having said that, I fully agree with Luke. The switch statement is
what it is, unfortunately, and beyond repair, but to maintain scoping
sanity, we should rule out examples that mistake its body for a proper
There is precedent for that in C++, where you cannot place non-trivial
declarations into a switch block either.
More information about the es-discuss