block scope + direct non-strict eval
Andy Wingo
wingo at igalia.com
Tue Jan 31 12:22:41 PST 2012
On Tue, 2012-01-31 at 10:13 -0800, Brendan Eich wrote:
> >>> (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?
>
> Oops, you're right. This is non-strict direct eval, so the var hoists
> and collides with the 'let'. Thanks!
Relatedly:
(function (){ { let x = 20; eval ("var x = 10"); } return x;})()
SyntaxError because the "var x" gets hoisted past the "let x" ?
Andy
More information about the es-discuss
mailing list