fix corner case in assignments (#3430)

fixes #3429
This commit is contained in:
Alex Lam S.L
2019-05-30 05:01:53 +08:00
committed by GitHub
parent 482e1baea3
commit 9d3b1efd86
2 changed files with 47 additions and 1 deletions

View File

@@ -327,3 +327,49 @@ issue_3427: {
}
expect: {}
}
issue_3429_1: {
options = {
assignments: true,
side_effects: true,
unused: true,
}
input: {
var a = "PASS";
(function(b) {
b && (b = a = "FAIL");
})();
console.log(a);
}
expect: {
var a = "PASS";
(function(b) {
b = b && (a = "FAIL");
})();
console.log(a);
}
expect_stdout: "PASS"
}
issue_3429_2: {
options = {
assignments: true,
side_effects: true,
unused: true,
}
input: {
var a;
(function(b) {
b || (b = a = "FAIL");
})(42);
console.log(a);
}
expect: {
var a;
(function(b) {
b = b || (a = "FAIL");
})(42);
console.log(a);
}
expect_stdout: "undefined"
}