Closed Bug 1038545 Opened 10 years ago Closed 10 years ago

Coerce the argument passed to Object.keys using ToObject

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla35

People

(Reporter: 446240525, Assigned: 446240525)

References

()

Details

(Keywords: dev-doc-complete, Whiteboard: [DocArea=JS])

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2091.2 Safari/537.36

Steps to reproduce:

According to ES6 spec 19.1.2.14 http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys

1. Let obj be ToObject(O).

So Object.keys(1) or Object.keys(Symbol("foo")) shouldn't throw any more.
Yup, confirmed.
Blocks: es6
Status: UNCONFIRMED → NEW
Ever confirmed: true
Component: JavaScript Engine → JavaScript: Standard Library
OS: Mac OS X → All
Hardware: x86 → All
Version: 33 Branch → Trunk
Weird. Is this change intentional? I don't recall seeing a discussion or meeting notes on this.
(In reply to David Bruant from comment #3)
> Weird. Is this change intentional? I don't recall seeing a discussion or
> meeting notes on this.

Yes, See this tweet by allen: https://twitter.com/ziyunfei/status/488893818620489730
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
Let's deal with each of these changes in its own bug. The description of the new bug you filed doesn't at all explain what's going on. On top of that, these are quite a few changes.

I'll change your new bug into a meta bug tracking all these related changes, though.
Blocks: 1060870
No longer blocks: es6
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Summary: Object.keys(1) shouldn't throw → Object.keys() shouldn't throw when given primitive values as input
Summary: Object.keys() shouldn't throw when given primitive values as input → Coerce the argument passed to Object.keys using ToObject
Attached patch bug-1038545.patch (obsolete) — Splinter Review
try run: https://tbpl.mozilla.org/?tree=Try&rev=cd7ef348706f
Assignee: nobody → 446240525
Attachment #8499958 - Flags: review?(till)
Comment on attachment 8499958 [details] [diff] [review]
bug-1038545.patch

Review of attachment 8499958 [details] [diff] [review]:
-----------------------------------------------------------------

Oh, how nice that the specification simplified this so much. :)

Please mention this simplification in the commit message:

"Coerce the argument passed to Object.keys using ToObject and simplify implementation."

For future reference, if you make changes that go beyond what the bug says, please briefly explain why you're making them and why they're ok in a bug comment. In this case, something like "I also simplified the implementation in accordance with the current specification draft. All existing tests still pass."

It probably would've taken me just as long to verify the correctness of these changes, but it would at least have spared me some confusion.
Attachment #8499958 - Flags: review?(till) → review+
Attachment #8499958 - Attachment is obsolete: true
Attachment #8500096 - Flags: review+
All green try run at comment 7
https://hg.mozilla.org/mozilla-central/rev/347f87932c77
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in before you can comment on or make changes to this bug.