Consider the following code:

    function f() { "use strict"; g() }
    function g() {
      var caller = Object.getOwnPropertyDescriptor(g, "caller").value
    }

With the current spec, this code would legally give g the strict
function f as its caller. In
https://bugs.ecmascript.org/show_bug.cgi?id=310, Allen proposes the
obvious fix, which is to special case [[GetOwnProperty]] instead of
[[Get]] for function objects in 15.3.5.4. In fact, that is what both
V8 and FF already implement.

However, we recently discovered an issue with that semantics. Namely,
it causes Object.is{Sealed,Frozen} and Object.{seal,freeze} to
spuriously throw when applied to the wrong function at the wrong time.
Consider:

d8> function g() { Object.seal(g) }
d8> function f() { "use strict"; g() }
d8> f()
(d8):1: TypeError: Illegal access to a strict mode caller function.

(Interestingly, Firefox does not throw on that example, so I'm not
sure what semantics it actually implements.)

What can we do here? There does not seem to be a clean fix, only more
hacks on top of hacks. It is a bit of a bummer for our implementation
of Object.observe, which wants an isFrozen check on its callback.

Thoughts?

/Andreas
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to