Map/Set/WeakMap/WeakSet should throw a TypeError when called without a new target

RESOLVED DUPLICATE of bug 1083752

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 1083752
3 years ago
3 years ago

People

(Reporter: Leo Balter, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
If Map/Set/WeakMap/WeakSet are called without a new target they should throw a TypeError.

Currently it's possible to call directly:

- Map()
- Set()
- WeakMap()
- ~WeakSet()~ // currently not implemented on my SpiderMonkey build (JavaScript-C42.0a1)

They need to have a new target when called in order to not throw a TypeError:

- new Map()
- new Set()
- ...

Refs: 
- 23.1.1.1 item 1
- 23.2.1.1 item 1
- 23.3.1.1 item 1
- 23.4.1.1 item 1
WeakSet() already throws.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1083752
(Reporter)

Comment 2

3 years ago
WeakSet() throws only because it's not even a function yet.

It should throw (when it's implemented) because a new target is not defined.

Current error: `TypeError: WeakSet is not a function`

The other bug didn't have any reference to Map, WeakMap and WeakSet. I added a comment there to not let the issue persist on the other collections Objects.
Thanks for reporting. I changed the bug summary of the other bug before duping though. You might be confused by the weird error message for WeakSet(). new WeakSet already works.
(Reporter)

Comment 4

3 years ago
> new WeakSet already works.

oops, that was my bad. It works for sure.

I didn't notice the change on the bug summary before. Thanks!
No worries. Thanks again for helping out.
You need to log in before you can comment on or make changes to this bug.