getOwnPropertyDescriptor side effects
Mark S. Miller
erights at google.com
Thu Jan 19 18:52:26 UTC 2017
On Thu, Jan 19, 2017 at 9:30 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> On 1/19/17 12:24 PM, Isiah Meadows wrote:
>> 1. What does Firefox do with the getter on non-errors?
> Oh, I didn't make that clear, did I? On a non-error in the getter, we
> have an Error object or Error.prototype (which appeared somewhere on our
> receiver's proto chain). Those objects all have, in Spidermonkey, an
> internal slot that stores information about the stack. The getter uses the
> information in that internal slot to create a string and return it.
> 2. How breaking is having the getter and setter throwing on non-errors?
> Well, when we tried to do it it didn't even pass our test automation, so...
> In particular it would throw on anyone doing ES5-style subclassing of
> Error and then doing anything with .stack.
That makes perfect sense.
We could have the Error.prototype.getter not throw but have System.getStack
throw. There was no strong reason for the getter and System.getStack to
have precisely the same behavior; it was just that there was no reason not
to. Now there is. Thanks.
> I'm struggling to see how it'd be that breaking. It's a getter, not a
>> method, so it requires a call to `__locateGetter__` or
>> `Object.defineProperty` to even access.
> No, it just requires that you have an Error on your prototype chain but
> not be an Error yourself, and suddenly you have exceptions everywhere.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss