In what ways does the following "eval" regularity break?

Maciej Stachowiak mjs at
Thu Oct 30 11:14:42 PDT 2008

On Oct 30, 2008, at 11:12 AM, Mark S. Miller wrote:

> On Thu, Oct 30, 2008 at 11:00 AM, Maciej Stachowiak <mjs at>  
> wrote:
>> In recent WebKit versions, this test prints PASS twice:
>> <pre><script>
>> var a = "PASS";
>> function foo(a, b, c) { return b(c); }
>> document.writeln(foo(3, eval, 'a'));
>> document.writeln(foo(3, window.eval, 'a'));
>> </script></pre>
>> (prints nothing if you remove the to-level var a declaration).
>> Opera matches this behavior.
>> In a recent Firefox nightly it also prints PASS twice, but FAIL  
>> twice if you
>> remove the top-level declaration. That seems in line with your  
>> results
>> above. I agree that is puzzling.
> What's FAIL?

Oops, I edited the test case after running it, I had 3 replaced with  
"FAIL". (I wanted to see if your original 3 did anything different  
than the string "FAIL", which of course it does not.) The correct  

var a = "PASS";
function foo(a, b, c) { return b(c); }
document.writeln(foo("FAIL", eval, 'a'));
document.writeln(foo("FAIL", window.eval, 'a'));

  - Maciej

More information about the Es-discuss mailing list