fix corner case in inline (#4754)

fixes #4753
This commit is contained in:
Alex Lam S.L
2021-03-08 04:38:53 +00:00
committed by GitHub
parent e4848a7f5a
commit 077512d151
4 changed files with 99 additions and 24 deletions

View File

@@ -5771,3 +5771,64 @@ new_target: {
expect_stdout: "function undefined"
node_version: ">=6"
}
issue_4753_1: {
options = {
inline: true,
toplevel: true,
}
input: {
for (var i in [ 1, 2 ])
(function() {
function f() {}
f && console.log(f.p ^= 42);
})();
}
expect: {
for (var i in [ 1, 2 ])
f = function() {},
void (f && console.log(f.p ^= 42));
var f;
}
expect_stdout: [
"42",
"42",
]
}
issue_4753_2: {
options = {
inline: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
do {
(function() {
var a = f();
function f() {
return "PASS";
}
f;
function g() {
console.log(a);
}
g();
})();
} while (0);
}
expect: {
do {
f = function() {
return "PASS";
},
a = void 0,
a = f(),
console.log(a);
} while (0);
var f, a;
}
expect_stdout: "PASS"
}