<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Function.prototype.bind: Bound functions must use the [[Prototype]] of their target function instead of Function.prototype"
href="https://bugs.webkit.org/show_bug.cgi?id=145605">145605</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Function.prototype.bind: Bound functions must use the [[Prototype]] of their target function instead of Function.prototype
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>528+ (Nightly build)
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>OS</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>JavaScriptCore
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>claude.pache@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>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:
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-boundfunctioncreate">https://people.mozilla.org/~jorendorff/es6-draft.html#sec-boundfunctioncreate</a>
For the justification, see <a href="https://bugs.ecmascript.org/show_bug.cgi?id=3819#c0">https://bugs.ecmascript.org/show_bug.cgi?id=3819#c0</a>
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
}
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>