Status: New
Owner: ----

New issue 2930 by [email protected]: Error.prototype.toString uses wrong `this` for getter-access of `message` and `name`
http://code.google.com/p/v8/issues/detail?id=2930

When Error.prototype.toString gets the `message` (or `name`) property of an object, if the `message` property has a getter function, the `this` value used in the getter function will be the object that *actually has* the `message` property, rather than the object whose `message` value was asked for.

Test case:

    var myproto = { x : "proto" };
    Object.defineProperty(myproto, "message", {
          'get': function(){ return "x: " + this.x; }
    });

    var instance = Object.create(myproto);
    instance.x = "instance";

In this case:

  * `instance.message` gets "x: instance" (correct)
* `Error.prototype.toString.call(instance)` get "Error: x: proto" (not correct)

EMCAScript 15.11.4.4, Step 5 says that [[Get]] should be called on the original `this` value of the `toString` call, which should result in same `this` being used for the property getter. However, it appears that the getter is invoked with `this` set to the object in the prototype chain that actually has the accessor descriptor, rather than the original object used as the `this` in `Error.prototype.toString`.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to