[INFER] Handle property assignments inside 'with' statements, bug 617757.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 13 Dec 2010 11:29:30 -0800
changeset 74658 c305092a1b33689ef387f3d443e0849628022808
parent 74657 e074599afab9b54ec9b8aff98dd03a2e114e70b6
child 74659 261101d210dc025392f919e020c97905b61432e4
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs617757
milestone2.0b8pre
[INFER] Handle property assignments inside 'with' statements, bug 617757.
js/src/jit-test/tests/basic/testWith.js
js/src/jsinfer.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/testWith.js
@@ -0,0 +1,8 @@
+
+// basic 'with' functionality
+
+var o = {foo: true};
+with(o) {
+    foo = 10;
+}
+assertEq(o.foo, 10);
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -1636,16 +1636,19 @@ TypeCompartment::addPendingRecompile(JSC
 
     recompilations++;
     pendingRecompiles->append(script);
 }
 
 void
 TypeCompartment::dynamicAssign(JSContext *cx, JSObject *obj, jsid id, const Value &rval)
 {
+    if (obj->isWith())
+        obj = js_UnwrapWithObject(cx, obj);
+
     jstype rvtype = GetValueType(cx, rval);
     TypeObject *object = obj->getTypeObject();
 
     if (object->unknownProperties)
         return;
 
     TypeSet *assignTypes;