Throwing when symbol *wrappers* are converted to primitives

Isiah Meadows impinball at gmail.com
Sat Dec 27 03:42:20 PST 2014


> From: Claude Pache <claude.pache at gmail.com>
> To: Axel Rauschmayer <axel at rauschma.de>
> Cc: Erik Arvidsson <erik.arvidsson at gmail.com>, es-discuss list <
es-discuss at mozilla.org>
> Date: Sat, 27 Dec 2014 09:04:43 +0100
> Subject: Re: Throwing when symbol *wrappers* are converted to primitives
>
> > Le 27 déc. 2014 à 08:41, Claude Pache <claude.pache at gmail.com> a écrit :
> >
> > I guess that V8 follows an old version of the spec draft. That
particular behaviour was modified in Rev 28. See:
> >
> > https://bugs.ecmascript.org/show_bug.cgi?id=3252
> >
> > —Claude
>
> In fact, that bug was for the particular case of wrapped symbol used as
property key. For the more general case of converting a Symbol wrapper
object back into a primitive value, I believe that behaviour also changed
during the life in the spec draft, but I am too lazy to find when. (Note
that the current draft defines Symbol.prototype[@@toPrimitive], and AFAIK,
V8 doesn't implement @@toPrimitive yet.)
>
> —Claude
>
> >
> > Le 27 déc. 2014 à 08:17, Axel Rauschmayer <axel at rauschma.de> a écrit :
> >
> >> This is current V8 behavior:
> >>
> >> ```
> >> > let obj = {};
> >> > obj[Object(Symbol())] = true;
> >> TypeError: Cannot convert object to primitive value
> >>
> >> > '' + Object(Symbol())
> >> TypeError: Cannot convert a Symbol wrapper object to a primitive value
> >> ```
> >>
> >> Both exceptions make a lot of sense, but I don’t see that in the spec.
The way I’d expect it to happen is via `Symbol.prototype[@@toPrimitive]` –
it would always throw. But that’s not the case.
> >>
> >>
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol.prototype-@@toprimitive
> >>
> >> --
> >> Dr. Axel Rauschmayer
> >> axel at rauschma.de
> >> rauschma.de
> >>
> >>
> >>
> >> _______________________________________________
> >> es-discuss mailing list
> >> es-discuss at mozilla.org
> >> https://mail.mozilla.org/listinfo/es-discuss

AFAICT from the GitHub mirror, V8 does not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141227/bc9bcfa4/attachment.html>


More information about the es-discuss mailing list