All current engines I could try return Number.prototype for:
12["__proto__"]
But the new spec says this should be a TypeError.
It’s more consistent with the other members of Object.prototype to do an implicit ToObject here, and apparently matches existing implementations. Is it intentional that the spec is treating this as a TypeError?
Allen commented in mail:
Well, it was intentional, but perhaps wrong. As you say, the set accessor probably needs to do a ToObject. The set accessor probably only needs to do a CheckObjectCoercible followed by an immediate return if the type of this is not Object (the wrapper and hence it's modified [[Prototype]] isn't observable, so it doesn't actually need to be created).
File a bug, and I'll put the revised algorithms into the ticket.
fixed in rev17 editor's draft.
Here are the revised definitions:
B.2.2.1.1 get Object.prototype.__proto__
The value of the [[Get]] attribute is a built-in function that requires no arguments. It performs the following steps:
1. Let O be the result of calling ToObject passing the this value as the argument.
2. ReturnIfAbrupt(O).
3. Return the result of calling the [[GetInheritance]] internal method of O.
B.2.2.1.2 set Object.prototype.__proto__
The value of the [[Set]] attribute is a built-in function that takes an argument proto. It performs the following steps:
1. Let O be CheckObjectCoercible(this value).
2. ReturnIfAbrupt(O).
3. If Type(proto) is neither Object or Null, then throw a TypeError exception.
4. If Type(O) is not Object, then return proto.
5. Let status be the result of calling the [[SetInheritance]] internal method of O with argument proto.
6. ReturnIfAbrupt(status).
7. If status is false, then throw a TypeError exception.
8. Return proto.
I also updated Object.setPrototypeOf
15.2.3.19 Object.setPrototypeOf ( O, proto )
When the setPrototypeOf function is called with arguments O and proto, the following steps are taken:
1. Let O be CheckObjectCoercible(O).
2. ReturnIfAbrupt(O).
3. If Type(proto) is neither Object or Null, then throw a TypeError exception.
4. If Type(O) is not Object, then return O.
5. Let status be the result of calling the [[SetInheritance]] internal method of O with argument proto.
6. ReturnIfAbrupt(status).
7. If status is false, then throw a TypeError exception.
8. Return O.
Are we sure that Object.setPrototypeOf should do ToObject? None of the other Object.* methods do this.
fixed in rev17, August 23, 2013 draft