unexpected shared property value between object instance

RESOLVED INVALID

Status

()

Core
JavaScript Engine
--
major
RESOLVED INVALID
8 years ago
8 years ago

People

(Reporter: Franck, Unassigned)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

1.86 KB, text/plain
Details
(Reporter)

Description

8 years ago
The *vp value of a property getter seems to not be stored on the obj object.

In the following case:
  var oa = new MyClass;
  Print(oa.myProperty); // prints 1
  var ob = new MyClass;
  Print(ob.myProperty); // prints 1, expect 2

myProperty is define like this:
JSBool MyProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
  if ( *vp != JSVAL_VOID )
    return JS_TRUE;
  *vp = INT_TO_JSVAL(index);
  index++;
  return JS_TRUE;
}
(Reporter)

Comment 1

8 years ago
Created attachment 410759 [details]
testcase
(Reporter)

Comment 2

8 years ago
The value is stored on the object's prototype.
(In reply to comment #2)
> The value is stored on the object's prototype.

That's where you defined the property, and your MyProperty getter did nothing to override in the obj instance. Fix it to JS_SetProperty(cx, obj, id, vp) and you get what you want.

/be
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.