Closed Bug 509510 Opened 11 years ago Closed 10 years ago

Object.getPrototypeOf doesn't match ES5 final draft spec

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

VERIFIED FIXED
mozilla1.9.2

People

(Reporter: brendan, Assigned: jimb)

References

Details

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

Attachments

(2 files, 1 obsolete file)

It turns out the communication with Ecma TC39 and the ES5 editor mentioned in comment 444787 comment 7 did not result in a change to ES5 draft to tolerate non-null, non-undefined primitive values as arguments. This is too bad, but more consistent with the rest of the new meta-programming APIs in Object, which all have an early step of the form:

# If Type(O) is not Object, throw a TypeError exception

For some reason the ES3 additions Object.prototype.{hasOwnProperty, isPrototypeOf, propertyIsEnumerable} (which are flawed in other ways, if you think this is a flaw too) all use ToObject on their parameter.

We should match the ES5 spec. Apple is, and developers will notice if we don't. Jim, can you get this assigned? Easy patch. Thanks,

/be
Assignee: general → jim
Attachment #393604 - Flags: review?(mrbkap)
Comment on attachment 393604 [details] [diff] [review]
Make Object.getPrototypeOf reject primitives, not coerce them.

>Bug 509510: Make Object.getPrototypeOf reject primitives, not coerce them.
>
>diff --git a/js/src/js.msg b/js/src/js.msg
>--- a/js/src/js.msg
>+++ b/js/src/js.msg
>@@ -310,3 +310,4 @@ MSG_DEF(JSMSG_MISSING_FUN_ARG,        22
> MSG_DEF(JSMSG_JSON_BAD_PARSE,         228, 0, JSEXN_SYNTAXERR, "JSON.parse")
> MSG_DEF(JSMSG_JSON_BAD_STRINGIFY,     229, 0, JSEXN_ERR, "JSON.stringify")
> MSG_DEF(JSMSG_XDR_CLOSURE_WRAPPER,    230, 1, JSEXN_INTERNALERR, "can't XDR closure wrapper for function {0}")
>+MSG_DEF(JSMSG_NOT_OBJECT,             231, 1, JSEXN_TYPEERR, "{0} is not an object")

Can you use the error reporting structure from the second to last patch in bug 444787? That also avoids JSDVG_SEARCH_STACK by passing -argc when we don't have to use it. I think you can also ignore the stuff about argc == 0, since that's handled above in that patch.
Attachment #393604 - Attachment is obsolete: true
Attachment #394179 - Flags: review?(mrbkap)
Attachment #393604 - Flags: review?(mrbkap)
Attachment #394179 - Flags: review?(mrbkap) → review+
Comment on attachment 394179 [details] [diff] [review]
Make Object.getPrototypeOf reject primitives, not coerce them.

Now that we're fully in C++-land, I *think* you should be able to combine the initialization of bytes with the declaration, but I'm not sure.
(In reply to comment #5)
> (From update of attachment 394179 [details] [diff] [review])
> Now that we're fully in C++-land, I *think* you should be able to combine the
> initialization of bytes with the declaration, but I'm not sure.

It's always been permissible to combine those, even in pre-standard C.
Attachment #394877 - Flags: review?(mrbkap)
Attachment #394877 - Flags: review?(mrbkap) → review+
http://hg.mozilla.org/tracemonkey/rev/c154196995b8
(both patches)
Whiteboard: fixed-in-tracemonkey
http://hg.mozilla.org/mozilla-central/rev/cc0fa7fd8fd8
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
js/tests/ecma_3_1/Object/regress-444787.js
v 1.9.3, 1.9.2
Status: RESOLVED → VERIFIED
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.