Closed Bug 562448 Opened 15 years ago Closed 15 years ago

ES5 Function.prototype.apply does not require argArray be either Array or arguments

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b3

People

(Reporter: brendan, Assigned: Waldo)

References

Details

(Keywords: dev-doc-complete, Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

It treats the second parameter, if not null and not undefined, as an object from which to get "length" and index-named properties, i.e. a generic array-like. /be
Attached patch Patch and tests (obsolete) — Splinter Review
I have a query going on es5-discuss about whether it's really intended/desirable to apply ToNumber twice (once via ToUint32) to argsArray.length, but with spec text as it is now, this patch is correct.
Assignee: general → jwalden+bmo
Status: NEW → ASSIGNED
Attachment #457930 - Flags: review?(brendan)
Attachment #457930 - Attachment is obsolete: true
Attachment #459839 - Flags: review?(brendan)
Attachment #457930 - Flags: review?(brendan)
Comment on attachment 459839 [details] [diff] [review] Patch and tests, now with less weird error-checking and double-evaluating Nice, much improved and close to the spec. >+ if (lenval.isInt32()) { >+ length = jsuint(jsint(lenval.toInt32())); /* jsuint cast does ToUint32 */ Don't need the jsint case here. r=me with that picked -- thanks. /be
Attachment #459839 - Flags: review?(brendan) → review+
http://hg.mozilla.org/tracemonkey/rev/898b20672383 Picked that nit, added comments delineating algorithm steps for greater clarity and readability, and renamed a variable for the same reason -- pushed with those changes.
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla2.0b3
Status: ASSIGNED → RESOLVED
Closed: 15 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: