Coerce the argument passed to Object.keys using ToObject

RESOLVED FIXED in mozilla35

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: 446240525, Assigned: 446240525)

Tracking

({dev-doc-complete})

Trunk
mozilla35
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [DocArea=JS], )

Attachments

(1 attachment, 1 obsolete attachment)

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: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1060870
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
Posted 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: 5 years ago5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in before you can comment on or make changes to this bug.