fix corner cases in unused (#3519)

This commit is contained in:
Alex Lam S.L
2019-10-23 06:46:05 +08:00
committed by GitHub
parent 267bc70d33
commit 4240fba9b8
2 changed files with 62 additions and 2 deletions

View File

@@ -2103,7 +2103,7 @@ issue_3497: {
expect_stdout: "undefined"
}
issue_3515: {
issue_3515_1: {
options = {
collapse_vars: true,
reduce_vars: true,
@@ -2127,3 +2127,62 @@ issue_3515: {
}
expect_stdout: "1"
}
issue_3515_2: {
options = {
side_effects: true,
toplevel: true,
unused: true,
}
input: {
var a = "FAIL";
function f() {
typeof b === "number";
delete a;
}
var b = f(a = "PASS");
console.log(a);
}
expect: {
var a = "FAIL";
function f() {
delete a;
}
f(a = "PASS");
console.log(a);
}
expect_stdout: "PASS"
}
issue_3515_3: {
options = {
collapse_vars: true,
unused: true,
}
input: {
var c = "FAIL";
(function() {
function f() {
c = "PASS";
}
var a = f();
var a = function g(b) {
b && (b.p = this);
}(a);
})();
console.log(c);
}
expect: {
var c = "FAIL";
(function() {
function f() {
c = "PASS";
}
(function(b) {
b && (b.p = this);
})(f());
})();
console.log(c);
}
expect_stdout: "PASS"
}