return when desugaring to closures

Mark S. Miller erights at google.com
Sun Oct 12 21:34:24 PDT 2008


On Sun, Oct 12, 2008 at 7:55 PM, David-Sarah Hopwood
<david.hopwood at industrial-designers.co.uk> wrote:
> In ES3.1, this will mean that they normally require braces whenever a
> body can introduce variables. There are two classes of exceptions,
> shown by these examples:
>
>  a) while (...) foo: var x = ...;
>  b) while (...) for (var x = ...; ...; ...) {}
>
> I think these are bugs. a) can certainly be disallowed. There might
> possibly be existing code that is relying on b), confusing though it
> is, but it can be disallowed in strict mode at least.

ES3.1 will disallow #a because a LabelledStatement can only contain a
SubStatement. A variable declaration is a Statement but not a
SubStatement.

Your point about #b is interesting. I do not know if it has previously
been raised.

-- 
    Cheers,
    --MarkM


More information about the Es-discuss mailing list