block scope + direct non-strict eval

Andy Wingo wingo at
Tue Jan 31 09:07:58 PST 2012

Hi Sam :)

On Tue, 2012-01-31 at 11:27 -0500, Sam Tobin-Hochstadt wrote:
> >  (function (){eval("let x = 10"); return x;})()
> ReferenceError

Oh good.  I was thinking that the intention was that let could introduce
new block-scoped bindings in the containing scope.  If that is not the
case, then good.

Summary: eval introduces a new block scope.

> >  (function (){let x = 20; eval("var x = 10"); return x;})()
> 10

Surely a SyntaxError, as the var x conflicts with the let x at the
function-level scope?


More information about the es-discuss mailing list