Skip to content

Commit f34fbb2

Browse files
authoredAug 13, 2024··
fix corner case in reduce_vars (#5919)
fixes #5917
1 parent 303417c commit f34fbb2

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed
 

‎lib/compress.js

-4
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,6 @@ Compressor.prototype.compress = function(node) {
601601
fn.enclosed.forEach(function(d) {
602602
if (fn.variables.get(d.name) === d) return;
603603
if (safe_to_read(tw, d)) return;
604-
d.single_use = false;
605-
var fixed = d.fixed;
606-
if (typeof fixed == "function") fixed = fixed();
607-
if (fixed instanceof AST_Lambda && fixed.safe_ids !== undefined) return;
608604
d.fixed = false;
609605
});
610606
}

‎test/compress/pure_getters.js

+36
Original file line numberDiff line numberDiff line change
@@ -1715,3 +1715,39 @@ issue_5856: {
17151715
}
17161716
expect_stdout: "PASS"
17171717
}
1718+
1719+
issue_5917: {
1720+
options = {
1721+
pure_getters: "strict",
1722+
reduce_vars: true,
1723+
side_effects: true,
1724+
toplevel: true,
1725+
}
1726+
input: {
1727+
var a;
1728+
console || (a = function() {})(f);
1729+
function f() {
1730+
a.p;
1731+
}
1732+
try {
1733+
f();
1734+
console.log("FAIL");
1735+
} catch (e) {
1736+
console.log("PASS");
1737+
}
1738+
}
1739+
expect: {
1740+
var a;
1741+
console || (a = function() {})(f);
1742+
function f() {
1743+
a.p;
1744+
}
1745+
try {
1746+
f();
1747+
console.log("FAIL");
1748+
} catch (e) {
1749+
console.log("PASS");
1750+
}
1751+
}
1752+
expect_stdout: "PASS"
1753+
}

0 commit comments

Comments
 (0)
Please sign in to comment.