Bug 578044 - fix setterOrUndefined (r=waldo)
authorLuke Wagner <lw@mozilla.com>
Tue, 20 Jul 2010 19:33:51 -0700
changeset 48519 605610554494be3984ba3546b1ee36571c296107
parent 48518 73922e37b73313237a6e1235ec2bf64d4c309601
child 48520 31cf8db8400b016af9e5c01581533ed75cfeef2c
push id14748
push userrsayre@mozilla.com
push dateSun, 01 Aug 2010 00:33:23 +0000
treeherdermozilla-central@f0df797bb2a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs578044
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 578044 - fix setterOrUndefined (r=waldo)
js/src/jsscope.h
js/src/trace-test/tests/basic/testBug578044.js
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -716,33 +716,32 @@ struct JSScopeProperty {
 
     // Per ES5, decode null getterObj as the undefined value, which encodes as null.
     js::Value getterValue() const {
         JS_ASSERT(hasGetterValue());
         return getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue();
     }
 
     js::Value getterOrUndefined() const {
-        JSObject *obj = hasGetterValue() ? getterObj : NULL;
-        return obj ? js::ObjectValue(*obj) : js::UndefinedValue();
+        return hasGetterValue() && getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue();
     }
 
     js::PropertyOp setter() const { return rawSetter; }
     bool hasDefaultSetter() const  { return !rawSetter; }
     js::PropertyOp setterOp() const { JS_ASSERT(!hasSetterValue()); return rawSetter; }
     JSObject *setterObject() const { JS_ASSERT(hasSetterValue()); return setterObj; }
 
     // Per ES5, decode null setterObj as the undefined value, which encodes as null.
     js::Value setterValue() const {
         JS_ASSERT(hasSetterValue());
         return setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue();
     }
 
     js::Value setterOrUndefined() const {
-        return setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue();
+        return hasSetterValue() && setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue();
     }
 
     inline JSDHashNumber hash() const;
     inline bool matches(const JSScopeProperty *p) const;
     inline bool matchesParamsAfterId(js::PropertyOp agetter, js::PropertyOp asetter,
                                      uint32 aslot, uintN aattrs, uintN aflags,
                                      intN ashortid) const;
 
new file mode 100644
--- /dev/null
+++ b/js/src/trace-test/tests/basic/testBug578044.js
@@ -0,0 +1,13 @@
+this.watch("x", Object.create)
+try {
+  (function() {
+    __defineGetter__("x",
+    function() {
+      return this
+    })
+  })()
+} catch(e) {}
+Object.defineProperty(x, "x", ({
+  set: Uint16Array
+}))
+