Closed Bug 586168 Opened 14 years ago Closed 7 years ago

can't implement Function.caller with function proxies

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 892903

People

(Reporter: dherman, Unassigned)

References

()

Details

I can't see any way to write a function proxy that implements Function.caller (docs at attached URL). I tried the following:

    function call() { saved = fproxy.caller }
    function trap(receiver, name) {
        if (name === "caller")
            return trap.caller;
    }
    fproxy = Proxy.createFunction({ get: trap }, call, call)
    function main() { fproxy() }
    main()

If you read the saved global, you get the call function. If you change trap to return trap.caller.caller and rerun the program, the saved global is null.

Dave
Function.caller is poison in ES5 (which can easily be emulated); isn't not implementing it desirable, even a feature perhaps?
We already censor .caller across wrappers, for what its worth.
Narcissus may want to implement guest .caller but it won't be based on the host .caller I hope.

Re: comment 1, .caller is poison only in ES5 strict, not ES5 non-strict, but of course ES5 strict is what Harmony is based on, so the deck is stacked.

The main interest in supporting .caller in Narcissus is to pass most of the tests that SpiderMonkey and Rhino pass.

/be
(In reply to comment #3)
> Re: comment 1, .caller is poison only in ES5 strict, not ES5 non-strict, but of
> course ES5 strict is what Harmony is based on, so the deck is stacked.

Oops, yes, I was imprecise.  What I meant is that, in strict mode and where new functions can be created, fun.caller is poison: fun.bind().caller is poison, for example.
Is this bug WONTFIX? Those tests should be excluded from Narcissus test runs, as a badge of honor :-|.

/be
Assignee: general → nobody
Proxy.createFunction() was removed in bug 892903.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.