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)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: claude.pache, Assigned: efaust)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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 } ```
Depends on: es6
Blocks: es6
No longer depends on: es6
Assignee: nobody → evilpies
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
This function doesn't have any uses and makes the code somewhat more complex.
Attachment #8627256 - Flags: review?(efaustbmo)
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+
Assignee: evilpies → efaustbmo
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
This was fixed by bug 1055472 patch part 3.
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: