WeakMap and primitive keys
# Allen Wirfs-Brock (13 years ago)
copy/paste bug!!
copy/paste bug!! Allen On Nov 1, 2012, at 9:05 AM, Nathan Wall wrote: > Looking at the recent draft, I noticed that the WeakMap methods accept primitive keys, converting them to objects, and acting like an object was passed in. This differs from the current behavior of Chrome and Firefox, which both throw if key is not an object. It seems, as the current draft reads, passing in a primitive will fail silently, since weakmap.set(3, 'some value'); weakmap.get(3); will be undefined. Is this a bug in the draft or was it decided not to throw in these situations (or am I misunderstanding the draft)? > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121101/85666ccd/attachment.html>
# Brendan Eich (13 years ago)
On file?
Nathan, thanks for catching this!
On file? Nathan, thanks for catching this! /be Allen Wirfs-Brock wrote: > copy/paste bug!! > > Allen > > On Nov 1, 2012, at 9:05 AM, Nathan Wall wrote: > >> Looking at the recent draft, I noticed that the WeakMap methods >> accept primitive keys, converting them to objects, and acting like an >> object was passed in. This differs from the current behavior of >> Chrome and Firefox, which both throw if key is not an object. It >> seems, as the current draft reads, passing in a primitive will fail >> silently, since weakmap.set(3, 'some value'); weakmap.get(3); will be >> undefined. Is this a bug in the draft or was it decided not to throw >> in these situations (or am I misunderstanding the draft)? >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> >> https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss
# Allen Wirfs-Brock (13 years ago)
On Nov 1, 2012, at 10:40 PM, Brendan Eich wrote:
On file?
already fixed in my draft.
On Nov 1, 2012, at 10:40 PM, Brendan Eich wrote: > On file? already fixed in my draft. > > Nathan, thanks for catching this! > > /be > > Allen Wirfs-Brock wrote: >> copy/paste bug!! >> >> Allen >> >> On Nov 1, 2012, at 9:05 AM, Nathan Wall wrote: >> >>> Looking at the recent draft, I noticed that the WeakMap methods accept primitive keys, converting them to objects, and acting like an object was passed in. This differs from the current behavior of Chrome and Firefox, which both throw if key is not an object. It seems, as the current draft reads, passing in a primitive will fail silently, since weakmap.set(3, 'some value'); weakmap.get(3); will be undefined. Is this a bug in the draft or was it decided not to throw in these situations (or am I misunderstanding the draft)? >>> >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> >>> https://mail.mozilla.org/listinfo/es-discuss >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >
Looking at the recent draft, I noticed that the WeakMap methods accept primitive keys, converting them to objects, and acting like an object was passed in. This differs from the current behavior of Chrome and Firefox, which both throw if key is not an object. It seems, as the current draft reads, passing in a primitive will fail silently, since weakmap.set(3, 'some value'); weakmap.get(3); will be undefined. Is this a bug in the draft or was it decided not to throw in these situations (or am I misunderstanding the draft)?