Closed Bug 1180294 Opened 9 years ago Closed 9 years ago

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

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1083752

People

(Reporter: leonardo.balter, Unassigned)

Details

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
Closed: 9 years ago
Resolution: --- → DUPLICATE
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.
> 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.