Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-5379

js increment operators (ob.prop += ob2.prop) do not work, after assigment like this ob = ob2

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.3, 2.1.0
    • Component/s: JavaScript
    • None
    • Environment:
      I think in all environment, but my is "Linux azat 2.6.38custom1.0 #1 SMP Mon May 23 17:17:08 MSD 2011 x86_64 GNU/Linux"
    • ALL

      /**
       * js increment operators (ob.prop += ob2.prop) do not work, after assigment like this ob = ob2
       * 
       * Affected versions:	r2.1.0-1580-g0c1a6bd (v8)
       * 				v8 engine: Version 3.9.23
       * 
       * 				2.0.3-1 (spider monkey)
       */
      
      db.eval(function() {
      	var ob2 = null;
      	var ob1 = {foo: 1};
      	ob2 = ob1;
      	// if uncomment, than works
      // 	ob2 = {};
      // 	for (i in ob1) {
      // 		ob2[i] = ob1[i];
      // 	}
      
      	ob2.foo += ob1.foo;
      	assert(2 == ob2.foo, "increment #2, must be: 2");
      	assert(ob2.foo == (1 + ob1.foo), "increment #1, must be: " + ob2.foo);
      	return ob2.foo;
      });
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            azat Azat Khuzhin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: