Closed
Bug 145791
Opened 22 years ago
Closed 22 years ago
ECMA conformance: Function.prototype.apply(), Function.prototype.call()
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
1.5R4
People
(Reporter: pschwartau, Assigned: norrisboyd)
Details
(Whiteboard: [Bug 145779 filed against SpiderMonkey])
Attachments
(2 files)
Function.prototype.apply has a FormalParameterList of length two: Function.prototype.apply (thisArg, argArray) Accordingly, Function.prototype.apply.length should return 2. This is explicitly stated in Section 15.3.4.3 of ECMA-262 Edition 3. See http://www.mozilla.org/js/language/ for a reference. However, Rhino currently returns 1 instead of 2. This was reported by igor3@apochta.com.
Reporter | ||
Comment 1•22 years ago
|
||
This bug is the Rhino version of bug 145779 against SpiderMonkey. The corresponding testcase for this is: mozilla/js/tests/ecma_3/Function/regress-145779.js
Whiteboard: [Bug 145779 filed against SpiderMonkey for same issue]
Comment 2•22 years ago
|
||
There are other problems with apply/call non-conformance. ECMA 15.3.4.3 requires for apply to behave in the same way when passing undefined as first or second argument as in case of passing null: <i>If thisArg is null or undefined, the called function is passed the global object as the this value. Otherwise, the called function is passed ToObject(thisArg) as the this value. If argArray is null or undefined, the called function is passed no arguments. Otherwise, if argArray is neither an array nor an arguments object (see 10.1.8), a TypeError exception is thrown. If argArray is either an array or an arguments object, the function is passed the (ToUint32(argArray.length)) arguments argArray[0], argArray[1], ..., argArray[ToUint32(argArray.length)�1].</i> Similarly ECMA 15.3.4.4 states for call: <i>If thisArg is null or undefined, the called function is passed the global object as the this value. Otherwise, the called function is passed ToObject(thisArg) as the this value.</i> Rhino does not behave as required for many cases of calling apply/call with null or undefined but I think there is no point in creating additional bug reports for this so the the patch extends ecma_3/Function/regress-145779.js to check against the cited text.
Comment 3•22 years ago
|
||
The patch makes apply.length to return 2 and addresses apply(undefined) etc. issues.
Reporter | ||
Comment 4•22 years ago
|
||
Igor: thank you for such thorough and precise tests! Following prevailing custom in the JS testsuite, I have CVS-deleted mozilla/js/tests/ecma_3/Function/regress-145779.js and added Igor's tests in the following two testcases: mozilla/js/tests/ecma_3/Function/15.3.4.3-1.js mozilla/js/tests/ecma_3/Function/15.3.4.4-1.js which test ECMA-262 Edition 3 Section 15.3.4.3 (Function.prototype.apply) Section 15.3.4.4 (Function.prototype.call) I can confirm that before Igor's patch, Rhino generated exceptions on both these testcases, but with Igor's patch, both tests pass -
Summary: Function.prototype.apply.length should return 2 → ECMA conformance: Function.prototype.apply(), Function.prototype.call()
Whiteboard: [Bug 145779 filed against SpiderMonkey for same issue] → [Bug 145779 filed against SpiderMonkey]
Comment 5•22 years ago
|
||
I commited the patch
Reporter | ||
Comment 6•22 years ago
|
||
Igor, thanks! Marking Fixed, then -
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 7•22 years ago
|
||
And marking Verified FIXED. Both testcases now pass in Rhino: mozilla/js/tests/ecma_3/Function/15.3.4.3-1.js mozilla/js/tests/ecma_3/Function/15.3.4.4-1.js And that holds for both the compiled and interpreted modes of Rhino.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•