Closed Bug 1083752 Opened 10 years ago Closed 10 years ago

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

Categories

(Core :: JavaScript Engine, defect)

36 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

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

References

Details

(Keywords: addon-compat, dev-doc-complete, site-compat)

Attachments

(1 file)

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
Blocks: 1062075
Depends on: 1108930
Depends on: 1108965
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Calling Set() (without `new`) should throw → Calling Map/Set/WeakMap() (without `new`) should throw
The same error occurs on Map and WeakMap.
Assignee: nobody → evilpies
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+
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: