Closed
Bug 392593
Opened 18 years ago
Closed 18 years ago
Wrong type for arguments object
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mguillemot, Assigned: norrisboyd)
Details
Attachments
(3 files)
|
2.11 KB,
patch
|
Details | Diff | Splinter Review | |
|
585 bytes,
patch
|
Details | Diff | Splinter Review | |
|
2.42 KB,
text/plain
|
bc
:
review+
|
Details |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20060601 Firefox/2.0.0.6 (Ubuntu-edgy)
Build Identifier:
The "arguments" object available within function execution should be a "normal" object not an own type.
This leads currently to errors for instance for typeof or toString() (see unit test in attached patch)
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
[seems I can't attach a patch here. I try to open the issue first and attach then]
Comment 3•18 years ago
|
||
Could you point out why is the current behaviour a problem?
Extracted from the unit test in the provided patch;
// 1: Rhino fails here as it returns Arguments
function f() {
var t = typeof arguments;
if (t != 'object') throw 'Failed: got ' + t;
}
f();
// 2: Rhino fails here too. Again "Arguments" where it should be "Object"
function f() {
var t = arguments.toString();
if (t != '[object Object]') throw 'Failed: got ' + t;
}
f();
Comment 5•18 years ago
|
||
Ah, okay, ECMA-262 section 10.1.8 actually prescribes:
"The value of the internal [[Prototype]] property of the arguments object is the original Object
prototype object, the one that is the initial value of Object.prototype"
So this is indeed a bug against the ECMA spec.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 6•18 years ago
|
||
Your patch changes it from IdScriptableObject to NativeObject, but doesn't address the problem that "callee", "length", and "caller" were provided on the arguments object via the IdScriptableObject mechanism.
Isn't this already handled because NativeObject extends IdScriptableObject? (I haven't checked)
| Assignee | ||
Updated•18 years ago
|
Assignee: nobody → norrisboyd
| Assignee | ||
Comment 8•18 years ago
|
||
In my testing Rhino only fails "// 2" on comment #4.
The expression
(function () { return arguments.__proto__ === Object.prototype; })()
is true on both Rhino and SpiderMonkey, so I'm hoping the attached patch is sufficient to fix this. Comments?
Comment 9•18 years ago
|
||
Norris, I'll show my ignorance of some of the Rhino implementation here, but is it safe to further subclass a class that is already subclassing IdScriptableObject? Will the IDs from the superclass (NativeObject) coexist peacefully with IDs in the subclass (Arguments)?
| Assignee | ||
Comment 10•18 years ago
|
||
The problem is the usage models are different. "Object" has a constructor and defines a prototype, but "arguments" is an object that has Object.prototype as its prototype. So we don't want all the NativeObject features in this case.
| Reporter | ||
Comment 11•18 years ago
|
||
Norris, your patch seems ok to me.
I don't remember how I got the failing result for "// 1" on comment #4, it's long ago. No matter.
| Assignee | ||
Comment 12•18 years ago
|
||
Committed my patch:
Checking in src/org/mozilla/javascript/Arguments.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Arguments.java,v <-- Argu
ments.java
new revision: 1.32; previous revision: 1.31
done
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 13•18 years ago
|
||
Cool!
And the unit test?
| Assignee | ||
Comment 14•18 years ago
|
||
Proposed test for typeof arguments.
Comment 15•18 years ago
|
||
Comment on attachment 300005 [details]
ecma/ExecutionContexts/10.1.8-3.js
flipping type so it can be viewed.
Attachment #300005 -
Attachment mime type: application/x-javascript → text/plain
Comment 16•18 years ago
|
||
Comment on attachment 300005 [details]
ecma/ExecutionContexts/10.1.8-3.js
>
>var SECTION = "10.1.8-2";
>var VERSION = "ECMA_1";
>startTest();
>var TITLE = "Arguments Object";
>
>var expected = "object";
>var actual = (function () { return typeof arguments; })();
>reportCompare(expected, actual, "typeof arguments == object");
>
>writeHeaderToLog( SECTION + " "+ TITLE);
nit: move the writeHeaderToLog to just below the var TITLE. r+ with that.
Attachment #300005 -
Flags: review+
| Assignee | ||
Comment 17•18 years ago
|
||
Change made, test committed to cvs. Thanks for the quick review!
Updated•18 years ago
|
Flags: in-testsuite+
Flags: in-litmus-
You need to log in
before you can comment on or make changes to this bug.
Description
•