fix corner cases in reduce_vars (#5097)

fixes #5096
This commit is contained in:
Alex Lam S.L
2021-07-23 10:17:20 +01:00
committed by GitHub
parent ec7fadcb5b
commit 6a3fe9d1df
3 changed files with 191 additions and 28 deletions

View File

@@ -556,7 +556,7 @@ reduce_iife_3: {
node_version: ">=4"
}
reduce_lambda: {
reduce_lambda_1: {
options = {
evaluate: true,
reduce_vars: true,
@@ -588,6 +588,43 @@ reduce_lambda: {
node_version: ">=4"
}
reduce_lambda_2: {
options = {
evaluate: true,
passes: 2,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
(function(f, a, b) {
f = () => {
console.log(a, b);
};
a = "foo", b = 42;
f();
b = "bar";
f();
})();
}
expect: {
(function(f, a, b) {
f = () => {
console.log("foo", b);
};
b = 42;
f();
b = "bar";
f();
})();
}
expect_stdout: [
"foo 42",
"foo bar",
]
node_version: ">=4"
}
single_use_recursive: {
options = {
reduce_vars: true,