[Webkit-unassigned] [Bug 145605] New: Function.prototype.bind: Bound functions must use the [[Prototype]] of their target function instead of Function.prototype

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 3 08:58:38 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=145605

            Bug ID: 145605
           Summary: Function.prototype.bind: Bound functions must use the
                    [[Prototype]] of their target function instead of
                    Function.prototype
    Classification: Unclassified
           Product: WebKit
           Version: 528+ (Nightly build)
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: claude.pache at gmail.com

A function object constructed using Function#bind must retain the [[Prototype]] of its target function.
Currently, it gets the default one, namely Function.prototype.

This is a breaking change introduced in ES6.

For the reference, see steps 2 and 8 of BoundFunctionCreate() in the spec:
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-boundfunctioncreate

For the justification, see https://bugs.ecmascript.org/show_bug.cgi?id=3819#c0

Here is a test case:

```
function getProtoBound(proto) {
    var f = Object.setPrototypeOf(function() { }, proto)
    var boundF = Function.prototype.bind.call(f, null)
    return Object.getPrototypeOf(boundF)
}

for (var proto of [ Function.prototype, function(){}, [], null ]) {
    console.log(Object.is(getProtoBound(proto), proto)) // should always log true
}
```

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150603/78c10f2d/attachment.html>


More information about the webkit-unassigned mailing list