This does not look correct to me. Symbol should behave like Number, String and
Boolean with the exception of Symbol.prototype[Symbol.toPrimitive]


https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js
File test/mjsunit/harmony/symbols.js (right):

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode75
test/mjsunit/harmony/symbols.js:75: assertSame(Function.prototype,
Symbol.prototype)
On 2014/01/08 18:13:43, sof wrote:
On 2014/01/08 17:52:25, rossberg wrote:
> That seems wrong. Symbol.prototype is an ordinary object.


https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-properties-of-the-symbol-constructor
says it's Function.prototype.

It says that "The value of the [[Prototype]] internal slot" is
Function.prototype. This is reflected as

assertSame(Object.getPrototypeOf(Symbol), Function.prototype)

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode78
test/mjsunit/harmony/symbols.js:78: assertSame(symbolPrototype,
Object(Symbol()).__proto__)
On 2014/01/08 18:13:43, sof wrote:
On 2014/01/08 17:52:25, rossberg wrote:
> Is this different from Symbol.prototype? Why?

Yes, Object(Symbol()).__proto__ is the prototype of the wrapper
object, not
Symbol.prototype.

The [[Prototype]] of a symbol wrapper should be Symbol.prototype. This
is the same as for number, string and boolean wrappers.

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode81
test/mjsunit/harmony/symbols.js:81: assertSame(Function.prototype,
(Symbol()).__proto__)
On 2014/01/08 18:13:43, sof wrote:
On 2014/01/08 17:52:25, rossberg wrote:
> And Symbol().__proto__ should be Symbol.prototype

Definitely not.

When you do a [[Get]] on a non object a temporary wrapper is created so

var sym = Symbol();
sym.foo === Object(sym).foo;

for all foos

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode91
test/mjsunit/harmony/symbols.js:91: assertFalse(Object ===
Symbol.prototype.constructor)
On 2014/01/08 18:13:43, sof wrote:
On 2014/01/08 17:52:25, rossberg wrote:
> This should be true now.

No, I believe this is correct.

Looks correct to me too:

assertSame(Symbol.prototype.constructor, Symbol);

just like for all other wrappers.

However, using assertSame would be better.

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode93
test/mjsunit/harmony/symbols.js:93: assertSame(Function,
Symbol.prototype.constructor)
On 2014/01/08 18:13:43, sof wrote:
On 2014/01/08 17:52:25, rossberg wrote:
> This should be Object, not Function

Same; are we reading the same draft version of the spec?

This should be

assertSame(Symbol.prototype.constructor, Symbol);

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol.prototype.constructor

https://codereview.chromium.org/118553003/diff/1/test/mjsunit/harmony/symbols.js#newcode94
test/mjsunit/harmony/symbols.js:94: assertSame(Function,
Symbol().__proto__.constructor)
On 2014/01/08 17:52:25, rossberg wrote:
Dito

Should be

assertSame(Symbol, Symbol().__proto__.constructor)

https://codereview.chromium.org/118553003/

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to