const and eval in non-strict code

Allen Wirfs-Brock allen at
Sun Jul 8 18:17:04 PDT 2012

On Jul 8, 2012, at 4:51 PM, Luke Hoban wrote:

> What is the intended behavior of this code:
>    (function() {
>        eval("const x = 4");
>        const x = 3;
>    })();
> The ES6 draft spec seems to be missing a few of the details that would contribute to answering this.  Specifically, section on eval refers to 10.4.2, which no longer exists, and 10.5, which is now a series of separate algorithms.  My guess is that the intention is that eval code is intended to be treated as "top level declaration instantiation" (10.5.1), but that section doesn't handle LexicalDeclarations.  Block Declaration Instantiation (10.5.4) does handle LexicalDeclarations, but it's not clear that there is a block instantiation here.

Yes, the eval spec. is still incomplete and there are still  top level declarations issues to resolve that should be done first.  There may end up being a seperate eval declaration instantiation section.

Regarding, this specific issue.  I assume that it would be a early error (during the eval)  because the scope contour (the function's top level) where eval needs to instantiate x already has a declaration for x and multiple declaration are not allowed.


> Luke
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list