Skip to content

Commit

Permalink
fix corner case in reduce_vars (#5919)
Browse files Browse the repository at this point in the history
fixes #5917
  • Loading branch information
alexlamsl authored Aug 13, 2024
1 parent 303417c commit f34fbb2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,6 @@ Compressor.prototype.compress = function(node) {
fn.enclosed.forEach(function(d) {
if (fn.variables.get(d.name) === d) return;
if (safe_to_read(tw, d)) return;
d.single_use = false;
var fixed = d.fixed;
if (typeof fixed == "function") fixed = fixed();
if (fixed instanceof AST_Lambda && fixed.safe_ids !== undefined) return;
d.fixed = false;
});
}
Expand Down
36 changes: 36 additions & 0 deletions test/compress/pure_getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -1715,3 +1715,39 @@ issue_5856: {
}
expect_stdout: "PASS"
}

issue_5917: {
options = {
pure_getters: "strict",
reduce_vars: true,
side_effects: true,
toplevel: true,
}
input: {
var a;
console || (a = function() {})(f);
function f() {
a.p;
}
try {
f();
console.log("FAIL");
} catch (e) {
console.log("PASS");
}
}
expect: {
var a;
console || (a = function() {})(f);
function f() {
a.p;
}
try {
f();
console.log("FAIL");
} catch (e) {
console.log("PASS");
}
}
expect_stdout: "PASS"
}

0 comments on commit f34fbb2

Please sign in to comment.