Status: New
Owner: ----
New issue 687 by [email protected]: Object.defineProperty problems with
redefining accessor properties in some situations.
http://code.google.com/p/v8/issues/detail?id=687
v8 version 2.2.4.2 (static embedded in node.js 0.1.92)
---- Case 1
var lazy = { get x () {}, set x (v) { Object.defineProperty(this, "x",
{value: v}); } };
sys.puts(lazy.x);
lazy.x = 4;
sys.puts(lazy.x);
Works fine:
undefined
4
==== Case 2 (same as case 1, but created indirectly)
var lazy = Object.create(null, {x: {
get: function () {},
set: function (v) { Object.defineProperty(this, "x", {value: v}); }
}});
sys.puts(lazy.x);
lazy.x = 4;
sys.puts(lazy.x);
Crashes:
undefined
TypeError: Cannot redefine property: defineProperty
at Function.defineProperty (native)
at [object Object].<anonymous>
(/usr/home/herby/storage/usecase.js:8:30)
...
(usecase:8:30 is Object.[here]defineProperty in setter line)
==== Case 3 (case 1 wrapped in Object.create)
var lazy = {get value() {}, set value(v) { Object.defineProperty(this,
"value", {value: v}); }};
var l2 = Object.create(lazy);
sys.puts(l2.value);
try { l2.value = 4; } catch (e) { sys.puts(e); }
sys.puts(l2.value);
Crashes (try catch because otherwise exception is swallowed):
undefined
RangeError: Maximum call stack size exceeded
undefined
(it seems Object.definePrototype calls setter instead of redefining)
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev