getOwnPropertyDescriptor side effects

Isiah Meadows isiahmeadows at gmail.com
Thu Jan 19 12:09:54 UTC 2017


It still seems useful. My only nit is shouldn't they be static methods of
`Error`, not `System`? (They only deal with an error-specific internal
property, so it seems odd to put it in the generic system stuff.)

On Thu, Jan 19, 2017, 02:34 Jordan Harband <ljharb at gmail.com> wrote:

> The beginnings of the Error Stacks proposal is now up at
> https://github.com/ljharb/proposal-error-stacks
>
> I'm presenting it this month at TC39, hoping for it to be stage 1.
>
> As its stands, the proposal would indeed make v8's behavior noncompliant,
> were it to become stage 4.
>
> On Thu, Jan 12, 2017 at 1:04 PM, Isiah Meadows <isiahmeadows at gmail.com>
> wrote:
>
> Okay, so it's a V8 bug. Filed it here:
> https://bugs.chromium.org/p/v8/issues/detail?id=5834
>
> On Thu, Jan 12, 2017, 03:03 T.J. Crowder <tj.crowder at farsightsoftware.com>
> wrote:
>
> So to sum up, then, and circle back to Francisco Tolmasky's original
> question:
>
> * For ordinary objects, `Object.getOwnPropertyDescriptor` shouldn't
> have side-effects because none of the ordinary operations it uses has
> side effects.
> * For exotic objects, it may well have side effects as a result of an
> exotic version of [[GetOwnProperty]]; for instance, Adam Klein's
> `Proxy` example.
> * `Error` objects are specified as ordinary objects.
> * V8's `Error` object has a `stack` property that claims to be a value
> property (not an accessor).
> * V8's `Error` object is a exotic object, it has exotic behavior for
> [[GetOwnProperty]], because it triggers filling in the string for the
> captured stack trace if you call it for `stack` (it has to, in order
> to provide the `value` property of the descriptor, since `stack`
> claims to be a value property).
> * This aspect of V8's `Error` could be in-spec by making `stack` an
> accessor instead (or by building the string earlier, but it's deferred
> for performance reasons).
>
> Is that a reasonable summary?
>
> Additionally, I believe the only exotic object defined by the
> specification that has a [[GetOwnProperty]] with potential side
> effects is `Proxy`.
>
> Provided that's all correct, Francisco's answer is: Per spec, you
> can't rely on `Object.getOwnPropertyDescriptor` not having side
> effects unless you can guarantee you're not dealing with a `Proxy`.
> Per spec, you could for non-`Proxy` objects defined by the
> specification, but that's not currently the case with V8 (at least).
> And there's always the possibility of host objects having exotic
> [[GetOwnProperty]] behavior.
>
> -- T.J.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170119/18cafc43/attachment.html>


More information about the es-discuss mailing list