Closed Bug 509733 Opened 10 years ago Closed 9 years ago

ES5: arguments.toString() === "[object Arguments]"

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla2.0b3

People

(Reporter: jimb, Assigned: Waldo)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

As described in section 10.6 of the July 27, 2009 draft, a function call's 'arguments' object should have:
- Array.prototype as its prototype,
- a class of "Arguments", 
- a constructor property equal to Object, and
- custom toString and toLocaleString methods that hand off to Object.prototype.
Quite the chimera.
The spec changed; as of the 1 September 2009 draft, the prototype of the arguments object should be Object.prototype.

The class name is still changing, though.
Summary: ES5: arguments object should have Array.prototype as its __proto__ → ES5: arguments.toString() === "[object Arguments]"
Attachment #457002 - Flags: review?(brendan)
Comment on attachment 457002 [details] [diff] [review]
Patch and an updated test

>- * The Arguments class is not initialized via JS_InitClass, and must not be,
>- * because its name is "Object".  Per ECMA, that causes instances of it to
>- * delegate to the object named by Object.prototype.  It also ensures that
>- * arguments.toString() returns "[object Object]".
>+ * The Arguments class is not initialized via JS_InitClass.  Instances of it
>+ * have the initial value of Object.prototype as their [[Prototype]].  However,
>+ * Object.prototype.toString.call(arguments) === "[object Arguments]" per ES5
>+ * (although not ES3), its class name is "Arguments" rather than "Object".

Don't add extra spaces after periods.

Do say why the Arguments class is not initialized via JS_InitClass even with the rename so it no longer collides with "Object".

Last sentence needs a "so" or after the last comma.

r=me with these fixed. I expect break-the-web for some corner case value of "web". :-P

/be
Attachment #457002 - Flags: review?(brendan) → review+
http://hg.mozilla.org/tracemonkey/rev/70b3280dea50

(In reply to comment #3)
> >- * The Arguments class is not initialized via JS_InitClass, and must not be,
> >- * because its name is "Object".  Per ECMA, that causes instances of it to
> >- * delegate to the object named by Object.prototype.  It also ensures that
> >- * arguments.toString() returns "[object Object]".
> 
> Don't add extra spaces after periods.

Seem to already have been there, no additions at all.  ;-)  But changed anyway.
Assignee: general → jwalden+bmo
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: x86 → All
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla1.9.3b2
http://hg.mozilla.org/mozilla-central/rev/70b3280dea50
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: mozilla2.0b2 → mozilla2.0b3
You need to log in before you can comment on or make changes to this bug.