Last Comment Bug 562448 - ES5 Function.prototype.apply does not require argArray be either Array or arguments
: ES5 Function.prototype.apply does not require argArray be either Array or arg...
Status: RESOLVED FIXED
fixed-in-tracemonkey
: dev-doc-complete
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla2.0b3
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
:
Mentors:
Depends on:
Blocks: es5
  Show dependency treegraph
 
Reported: 2010-04-28 13:24 PDT by Brendan Eich [:brendan]
Modified: 2011-01-07 15:34 PST (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch and tests (11.52 KB, patch)
2010-07-16 12:13 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
no flags Details | Diff | Review
Patch and tests, now with less weird error-checking and double-evaluating (10.28 KB, patch)
2010-07-23 08:54 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
brendan: review+
Details | Diff | Review

Description Brendan Eich [:brendan] 2010-04-28 13:24:57 PDT
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
Comment 1 Jeff Walden [:Waldo] (remove +bmo to email) 2010-07-16 12:13:55 PDT
Created attachment 457930 [details] [diff] [review]
Patch and tests

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.
Comment 2 Jeff Walden [:Waldo] (remove +bmo to email) 2010-07-23 08:54:02 PDT
Created attachment 459839 [details] [diff] [review]
Patch and tests, now with less weird error-checking and double-evaluating
Comment 3 Brendan Eich [:brendan] 2010-07-23 16:41:39 PDT
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
Comment 4 Jeff Walden [:Waldo] (remove +bmo to email) 2010-07-26 16:48:25 PDT
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.
Comment 5 Jeff Walden [:Waldo] (remove +bmo to email) 2010-08-04 16:39:27 PDT
http://hg.mozilla.org/mozilla-central/rev/898b20672383
Comment 6 Eric Shepherd [:sheppy] 2010-08-31 13:28:49 PDT
Added a note to:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply

And to the New in JavaScript 1.8.5 page.

Note You need to log in before you can comment on or make changes to this bug.