fix pure_getters on AST_Binary (#2681)

fixes #2678
This commit is contained in:
Alex Lam S.L
2017-12-28 17:01:01 +08:00
committed by GitHub
parent e40a0ee9c6
commit b95e3338d9
2 changed files with 34 additions and 9 deletions

View File

@@ -1693,15 +1693,8 @@ merge(Compressor.prototype, {
return this.operator == "void";
});
def(AST_Binary, function(compressor) {
switch (this.operator) {
case "&&":
return this.left._dot_throw(compressor);
case "||":
return this.left._dot_throw(compressor)
&& this.right._dot_throw(compressor);
default:
return false;
}
return (this.operator == "&&" || this.operator == "||")
&& (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
})
def(AST_Assign, function(compressor) {
return this.operator == "="

View File

@@ -611,3 +611,35 @@ issue_2313_6: {
x();
}
}
issue_2678: {
options = {
pure_getters: "strict",
side_effects: true,
}
input: {
var a = 1, c = "FAIL";
(function f() {
(a-- && f()).p;
return {
get p() {
c = "PASS";
}
};
})();
console.log(c);
}
expect: {
var a = 1, c = "FAIL";
(function f() {
(a-- && f()).p;
return {
get p() {
c = "PASS";
}
};
})();
console.log(c);
}
expect_stdout: "PASS"
}