Tom Van Cutsem (2013-09-12T11:14:16.000Z)
domenic at domenicdenicola.com (2013-09-25T01:44:17.954Z)
[+markm, allenwb] 2013/9/11 David Bruant <bruant.d at gmail.com> > It's annoying to cleanup post-trap though (to restore the target initial > prototype). Is the invariant on getPrototypeOf that important on extensible > objects? > I think it is the only trap that enforces something without a related > eternal invariant. > For membranes, when using a shadow target, there's no need to clean-up/restore anything. But more generally, you're right that it's odd [[GetInheritance]] is doing an invariant check on an otherwise extensible/configurable object. I think it's simply a remnant of the time before we fully embraced setPrototypeOf. Now that Object.setPrototypeOf is part of ES6, there doesn't seem to be a point in guaranteeing the stability of Object.getPrototypeOf for extensible objects. The important invariant is that getPrototypeOf remain stable for non-extensible objects. Hence, it seems we could replace steps 8-10 of [Proxy.[[GetInheritance]]](https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-9.3.1) with: ``` 8. Let extensibleTarget be the result of IsExtensible(target). 9. ReturnIfAbrupt(extensibleTarget). 10. If extensibleTarget is true, then return handlerProto. // steps below identical to the old steps 8-10: 11. Let targetProto be the result of calling the [[GetInheritance]] internal method of target. 12. ReturnIfAbrupt(targetProto). 13. If SameValue(handlerProto, targetProto) is false, then throw a TypeError exception. ``` Mark, Allen, does that seem right?