Closed Bug 1122944 Opened 11 years ago Closed 11 years ago

Function.prototype.bind should create non-constructor function when applied to a non-constructor object

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: caitpotter88, Assigned: evilpies)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0 Build ID: 20150117030203 Steps to reproduce: A simple reproduction is http://jsfiddle.net/4q75LL77/ Actual results: When `this` is a bound non-constructor function, IsConstructor() returns true, and `this` is invoked with `new`, thus a TypeError is thrown. If the non-constructor is unbound, it behaves correctly. Expected results: IsConstructor() should return false for bound non-constructor functions. In the posted example, the result of each call should be an array with the element values 1, 2 and 3.
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Blocks: es6
Attached patch bound-constructor (obsolete) — Splinter Review
What a funny little test case, thank you! Till does your new implementation pass this test?
Assignee: nobody → evilpies
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8550774 - Flags: review?(till)
Attached patch bound-constructor (obsolete) — Splinter Review
Attachment #8550774 - Attachment is obsolete: true
Attachment #8550774 - Flags: review?(till)
Attachment #8550775 - Flags: review?(till)
Attached patch bound-functionSplinter Review
Oh, dear ...
Attachment #8550775 - Attachment is obsolete: true
Attachment #8550775 - Flags: review?(till)
Attachment #8550776 - Flags: review?(till)
Summary: Array.from and Array.of should not throw TypeError if `this` is a bound non-constructor function → Function.prototype.bind should create non-constructor function when applied to a non-constructor object
That was fast, I was going to try and get my friend to work on that as a good first bug =)
Oh dammit :( I would rather your friend did it, instead of me. We have a few other good first bugs under the es6 meta bug, and there is of course http://www.joshmatthews.net/bugsahoy/?jseng=1.
Comment on attachment 8550776 [details] [diff] [review] bound-function Review of attachment 8550776 [details] [diff] [review]: ----------------------------------------------------------------- Heh, funny little test indeed. Yes, my implementation would pass this - though I wasn't even aware of this issue :)
Attachment #8550776 - Flags: review?(till) → review+
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: