11.13.2 Compound Assignment does a single reference resolution for its LHS, but implementations vary in their behaviour and don't really follow the specification. This also applies to the increment and decrement operators (11.3.1, 11.3.2, 11.4.4, 11.4.5).
Implementations tested: Opera 12.15, IE11, SpiderMonkey (trunk), V8 (bleeding edge), JavaScriptCore (trunk)
Test case 1:
---
var o1, o2;
with (o1 = {set x(v) { print("wrong") }}) {
with (o2 = {get x() { delete this.x; return 2 }}) {
x += 1;
}
}
o2.x
---
Expected: "wrong" is not printed and `o2.x` is set to 3
Correct behaviour: SM, Opera
Wrong behaviour: JSC, V8, IE
Test case 2:
---
var x = 1;
(function() {
x += eval("var x = 2; x");
return x;
})();
---
Expected: function returns 2 and global x is set to 3
Correct behaviour: SM, Opera, JSC,
Wrong behaviour: V8, IE
Test case 3:
---
(function(global) {
"use strict";
Object.defineProperty(global, "x", {configurable:true, get: function(){ delete this.x; return 2 }});
x += 1;
})(this);
---
Expected: Create a global variable x with value 3, no strict-mode ReferenceError is thrown
Correct behaviour: -
Wrong behaviour: SM, Opera, JSC, V8, IE
Tests added in https://github.com/tc39/test262/pull/91