const and eval in non-strict code

Luke Hoban lukeh at
Sun Jul 8 16:51:51 PDT 2012

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.


More information about the es-discuss mailing list