setPrototypeOf should throw TypeError if typeof newProto === 'undefined'
johnjbarton opened this issue · 1 comments
johnjbarton commented
The first line of [[setPrototypeOf]] fails if the argument is undefined:
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v
But reflect.js does not:
function testSetPrototypeOf() {
var obj = {};
var shouldThrow;
try {
Object.setPrototypeOf(obj, undefined);
} catch (ex) {
shouldThrow = ex;
}
assert(shouldThrow);
}
I believe the issue here is that reflect.js implements Object.setPrototypeOf(obj, newProto)
using obj.__proto__
setter, but somehow these operations are not consistent on Chrome at least.
tvcutsem commented
Reflect.setPrototypeOf now explicitly tests whether the new prototype is an object or null.