fix replacement logic in collapse_vars (#2475)

This commit is contained in:
Alex Lam S.L
2017-11-13 07:37:42 +08:00
committed by GitHub
parent 2ac5086831
commit 49fbe9c5ac
2 changed files with 174 additions and 102 deletions

View File

@@ -3518,3 +3518,63 @@ issue_2436_12: {
}
}
}
issue_2436_13: {
options = {
collapse_vars: true,
reduce_vars: true,
unused: true,
}
input: {
var a = "PASS";
(function() {
function f(b) {
(function g(b) {
var b = b && (b.null = "FAIL");
})(a);
}
f();
})();
console.log(a);
}
expect: {
var a = "PASS";
(function() {
(function(b) {
(function(b) {
a && (a.null = "FAIL");
})();
})();
})();
console.log(a);
}
expect_stdout: "PASS"
}
issue_2436_14: {
options = {
collapse_vars: true,
reduce_vars: true,
unused: true,
}
input: {
var a = "PASS";
var b = {};
(function() {
var c = a;
c && function(c, d) {
console.log(c, d);
}(b, c);
})();
}
expect: {
var a = "PASS";
var b = {};
(function() {
a && function(c, d) {
console.log(c, d);
}(b, a);
})();
}
expect_stdout: true
}