fix corner case in inline (#4472)

fixes #4471
This commit is contained in:
Alex Lam S.L
2020-12-28 02:05:59 +00:00
committed by GitHub
parent 6a8aed2049
commit 28bcdbd7df
2 changed files with 39 additions and 1 deletions

View File

@@ -8039,7 +8039,11 @@ merge(Compressor.prototype, {
refs.forEach(function(ref) {
var def = ref.definition();
def.references.push(ref);
if (replacing) def.replaced++;
if (replacing) {
def.replaced++;
} else {
def.single_use = false;
}
});
return node;
}

View File

@@ -5249,3 +5249,37 @@ issue_4451: {
}
expect_stdout: "function"
}
issue_4471: {
options = {
inline: true,
reduce_funcs: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
f(f());
function f() {
return g();
}
function g() {
{
console.log("PASS");
}
}
}
expect: {
f(g());
function f() {
return g();
}
function g() {
console.log("PASS");
}
}
expect_stdout: [
"PASS",
"PASS",
]
}