getOwnPropertyDescriptor side effects

Boris Zbarsky bzbarsky at mit.edu
Thu Jan 19 17:30:46 UTC 2017


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.

> 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.

-Boris


More information about the es-discuss mailing list