Closed
Bug 1171053
Opened 10 years ago
Closed 10 years ago
Function.prototype.bind: Bound functions must use the [[Prototype]] of their target function instead of Function.prototype
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla42
| Tracking | Status | |
|---|---|---|
| firefox42 | --- | fixed |
People
(Reporter: claude.pache, Assigned: efaust)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
|
8.00 KB,
patch
|
efaust
:
review+
|
Details | Diff | Splinter Review |
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
}
```
| Reporter | ||
Updated•10 years ago
|
Updated•10 years ago
|
Assignee: nobody → evilpies
Updated•10 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Comment 1•10 years ago
|
||
This function doesn't have any uses and makes the code somewhat more complex.
Attachment #8627256 -
Flags: review?(efaustbmo)
| Assignee | ||
Comment 2•10 years ago
|
||
Comment on attachment 8627256 [details] [diff] [review]
Remove JS_BindCallable
Review of attachment 8627256 [details] [diff] [review]:
-----------------------------------------------------------------
Oh, cool. I didn't realize this was dead. Rock.
Attachment #8627256 -
Flags: review?(efaustbmo) → review+
Updated•10 years ago
|
Assignee: evilpies → efaustbmo
Comment 4•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Updated•10 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 5•10 years ago
|
||
This was fixed by bug 1055472 patch part 3.
Status: REOPENED → RESOLVED
Closed: 10 years ago → 10 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•