unknownPrivateSymbol trap (was: WeakMap better than Private Symbols? (was: direct_proxies "problem"))

Nathan Wall nathan.wall at live.com
Tue Jan 15 22:30:30 PST 2013

> set(key, value) {
>     let data = this[$data];
>     if (!data)
>         throw new TypeError('this object must be a StringMap');
>     if (!(key in data))
>         this[$size]++;
>     data[key] = value;
> }

Doh! I wrote that in such a way that an inconsistency cannot be introduced, since `$data` is retrieved before `$size` is changed, and then the mutation on the data object happens without the use of a private symbol.

However, I think you get the idea. 

Probably a better example would have been one where I wanted to mutate two private symbol properties with primitive values, in which case they would both require calls to `unknownPrivateSymbol` when being set.


More information about the es-discuss mailing list