Calling Map/Set/WeakMap() (without `new`) should throw

RESOLVED FIXED in Firefox 42

Status

()

RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: medikoo+mozilla.org, Assigned: evilpie)

Tracking

({addon-compat, dev-doc-complete, site-compat})

36 Branch
mozilla42
x86
macOS
addon-compat, dev-doc-complete, site-compat
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox42 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20141016030201

Steps to reproduce:

Just run:

Set();


Actual results:

New set instance was returned


Expected results:

If understand ES6 spec correctly, it should throw with TypeError
Depends on: 1108930
Depends on: 1108965
(Assignee)

Updated

4 years ago
Duplicate of this bug: 1176396
(Assignee)

Updated

4 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Calling Set() (without `new`) should throw → Calling Map/Set/WeakMap() (without `new`) should throw
(Assignee)

Updated

4 years ago
Duplicate of this bug: 1180294

Comment 3

4 years ago
The same error occurs on Map and WeakMap.
(Assignee)

Updated

4 years ago
Assignee: nobody → evilpies
(Assignee)

Comment 4

4 years ago
I think it's time to do this. We landed the warning for this in 38 with bug 1108930.
Attachment #8636833 - Flags: review?(jwalden+bmo)
Comment on attachment 8636833 [details] [diff] [review]
Throw when calling Map/Set/WeakMap/

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

::: js/src/builtin/MapObject.cpp
@@ +1237,5 @@
>  MapObject::construct(JSContext* cx, unsigned argc, Value* vp)
>  {
>      Rooted<MapObject*> obj(cx, MapObject::create(cx));
>      if (!obj)
>          return false;

Mind moving this down below the ThrowIfNotConstructing call?

@@ +1902,5 @@
>  SetObject::construct(JSContext* cx, unsigned argc, Value* vp)
>  {
>      Rooted<SetObject*> obj(cx, SetObject::create(cx));
>      if (!obj)
>          return false;

Likewise.

::: js/src/jsweakmap.cpp
@@ +513,5 @@
>  {
>      CallArgs args = CallArgsFromVp(argc, vp);
>      RootedObject obj(cx, NewBuiltinClassInstance(cx, &WeakMapObject::class_));
>      if (!obj)
>          return false;

Move the obj bits down below ThrowIfNotConstructing as well.
Attachment #8636833 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/9fe635d3bb9b
Status: NEW → RESOLVED
Last Resolved: 4 years ago
status-firefox42: --- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
(Assignee)

Updated

4 years ago
Keywords: addon-compat, dev-doc-needed, site-compat
You need to log in before you can comment on or make changes to this bug.