var foo = {name: "foo"}; foo.name; var foo; foo.name; eval("var foo;"); foo.name; When you run the forementioned code, the first two foo.name statements execute fine just as expected; even after foo has been initialized in the first line, the second "var foo" statement doesn't unset the variable. However, the third foo.name statement causes an exception: Uncaught exception - TypeError: cannot convert undefined to object When you inspect the variable foo after the eval() statement, you find out that it has been unset (set to undefined), which in my view is incorrect behaviour. All variable declarations and assignments inside eval() should behave as if they were executed in the outside of eval(). Or does ECMA-262 specify otherwise? Seems unlikely. This bug is present in 1.6.0 and master branch, and thus likely in all versions.
commit 3d3f473c399186d229bc0313d3f4efaef0cc5bdb Author: Tor Andersson <tor.andersson@artifex.com> Date: Mon Nov 11 11:02:54 2019 +0100 Bug 701887: Create arguments if eval is present. We can't know at compile time that the 'arguments' object will not be used from the eval statement, so err on the side of caution and always create the arguments object if eval can be called.
commit d248b0ce1800a1ebf2c853f205c1947642185c6a Author: Tor Andersson <tor.andersson@artifex.com> Date: Mon Nov 11 11:34:43 2019 +0100 Bug 701886: Always create new scope for eval(). Distinguish eval code from script code.
The fix in d248b0ce1800a1ebf2c853f205c1947642185c6a is wrong. Fixed in a better way in: commit a34fdf2af87cc13b1d85cd19812c4d0b722f3e3a Author: Tor Andersson <tor.andersson@artifex.com> Date: Thu Mar 4 12:20:46 2021 +0100 Bug 701886: Don't redefine/reset existing vars in script code. If a var is already declared in the same scope, don't redeclare it. Should fix issues with "var" used in eval() code.