Closed
Bug 918341
Opened 12 years ago
Closed 12 years ago
new Map(iterable) should check that iterator values are objects
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla27
People
(Reporter: wingo, Assigned: sankha)
References
Details
Attachments
(1 file, 1 obsolete file)
|
3.82 KB,
patch
|
Details | Diff | Splinter Review |
From http://people.mozilla.org/~jorendorff/es6-draft.html#sec-23.1.1, when building a map from an iterable, we should throw if the values are not objects.
| Reporter | ||
Updated•12 years ago
|
Blocks: harmony:collections
| Assignee | ||
Comment 1•12 years ago
|
||
Attachment #817639 -
Flags: review?(jorendorff)
Comment 2•12 years ago
|
||
Comment on attachment 817639 [details] [diff] [review]
patch v1
Review of attachment 817639 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks! r=me with the comments addressed.
::: js/src/builtin/MapObject.cpp
@@ +1194,5 @@
> if (!iter.next(&pairVal, &done))
> return false;
> if (done)
> break;
> + if (JSVAL_IS_PRIMITIVE(pairVal) || JSVAL_IS_NULL(pairVal)) {
Instead of this, please write:
if (!pairVal.isObject()) {
@@ +1203,3 @@
> pairObj = ToObject(cx, pairVal);
> if (!pairObj)
> return false;
Please change this ToObject call to pairVal.toObject(), which is cheaper and can't fail. (This is possible because we just confirmed that pairVal really is an object.)
::: js/src/jit-test/tests/collections/Map-constructor-5.js
@@ +10,5 @@
> +
> +assertThrowsInstanceOf(function () { Map([1, 2, 3]); }, TypeError);
> +assertThrowsInstanceOf(function () {
> + let s = new Set([1, 2, "abc"]);
> + Map(s.values());
just `new Map(s);` please. The values method is useless.
Attachment #817639 -
Flags: review?(jorendorff) → review+
| Assignee | ||
Comment 3•12 years ago
|
||
Assignee: general → sankha93
Attachment #817639 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
| Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 4•12 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Comment 5•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
You need to log in
before you can comment on or make changes to this bug.
Description
•