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

Mark S. Miller erights at google.com
Thu Oct 30 10:20:07 PDT 2008


On Thu, Oct 30, 2008 at 8:35 AM, Brendan Eich <brendan at mozilla.com> wrote:
> [...] Browser intersection semantics make indirect eval global, [...]


I had hoped so. This came up at Redmond, and unfortunately, without
either you or Lars there, I was unable to reconstruct why we thought
it would be upwards compatible to make indirect eval global. The
specification of indirect eval was also discussed in this morning's
ES3.1 phone call. Based on the ES3 spec and a quick testing of the
browsers, as well as the memory of those who had an opinion about this
in Redmond, we've been proceeding with the assumption that the ES3
spec should be read as:

An implementation may implement an indirect eval either by throwing an
EvalError or by treating it as equivalent to the eval operator.

Testing on FF3.0.3 and FF3.1Beta, with and without TraceMonkey
enabled, seemed to bear this out:

    function foo(a, b, c) { return b(c); }
    foo(3, eval, 'a'); // yields 3
    foo(3, window.eval, 'a'); // yields 3

However, a bit more testing reveals something truly bizarre:

    window.a = 'x';
    foo(3, window.eval, 'a') // yields 'x'
    foo(3, eval, 'a'); // yields 'x'

I can't think of any semantics that would account for both behaviors.
Is this a bug?

-- 
    Cheers,
    --MarkM


More information about the Es-discuss mailing list