archives

« Bugzilla Issues Index

#2550 — toMethod doesn't work with callable proxies and bound functions


F,p.toMethod and the CloneMethod abstract operation currently throw for anything other than built-in functions and ECMAScript methods.

In particular, they throw for bound functions and callable proxies. I can imagine what I would do for found functions and possibly a special case for cloning a proxy with with same target and handler. However, it isn't clear in whether or not the CloneMethod should propagate to the target.

I think just is the tip of a bigger issues with regard to cloning proxies and other exotic objects. It may be that there needs to be MOP level support for cloning an object, but I don't want to consider that now or for just this limited use case, particularly if we want to tackle the more general cloning problem post ES6.

For now, I think we should just continue to throw. If you really need to make a a bound method or callable proxy work with toMethod you can just wrapper it with an ordinary function.


I agree on both points: if ever we want a general cloning abstraction, then we need a MOP-level hook, but for this particular case it feels ad hoc to add a hook and we’re better off throwing an exception.


support for cloning bound functions was added in rev25.

We aren't going to support cloning proxy function in ES6