Ignore `null` iterable in Map, Set, WeakMap and WeakSet constructors

RESOLVED FIXED in mozilla37

Status

()

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: anba, Assigned: arai)

Tracking

({dev-doc-complete})

Trunk
mozilla37
dev-doc-complete
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [DocArea=JS])

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
`null` iterable argument has to be ignored.

Simple tests:
---
new Map(null);
new Set(null);
new WeakMap(null); // but see bug 1092537
new WeakSet(null);
---

Expected: No TypeError thrown
Actual: TypeError thrown for Map, Set and WeakSet
(Reporter)

Comment 1

4 years ago
Ignoring `null` in addition to `undefined` was added in ES6 draft rev14.
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Depends on: 1101704
Comment on attachment 8530324 [details] [diff] [review]
Ignore `null` iterable in Map, Set, WeakMap and WeakSet constructors.

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

Thanks :)

::: js/src/builtin/MapObject.cpp
@@ -1235,5 @@
>      if (!obj)
>          return false;
>  
>      CallArgs args = CallArgsFromVp(argc, vp);
> -    if (args.hasDefined(0)) {

please change all of these to !args.get(0).isNullOrUndefined()
Attachment #8530324 - Flags: review?(evilpies) → review+
thank you for reviewing :D

Changed those lines and pushed to m-i:
  https://hg.mozilla.org/integration/mozilla-inbound/rev/187125e5da10
https://hg.mozilla.org/mozilla-central/rev/187125e5da10
Assignee: nobody → arai_a
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
Thanks, :arai! :)
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.