Skip to content

Commit

Permalink
enhance hoist_vars (#5865)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl authored Jun 25, 2024
1 parent 6669ea1 commit ce8ef52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10353,7 +10353,6 @@ Compressor.prototype.compress = function(node) {
def.assignments++;
}
def.eliminated++;
def.single_use = false;
return a;
}, []);
if (assignments.length == 0) return null;
Expand Down
14 changes: 7 additions & 7 deletions test/compress/hoist_vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ issue_4489: {
evaluate: true,
hoist_vars: true,
reduce_vars: true,
sequences: true,
toplevel: true,
unused: true,
}
Expand Down Expand Up @@ -363,6 +364,7 @@ issue_4893_1: {
evaluate: true,
hoist_vars: true,
reduce_vars: true,
side_effects: true,
toplevel: true,
unused: true,
}
Expand All @@ -383,9 +385,8 @@ issue_4893_1: {
}
expect: {
try{
(function f() {
(function() {
null.p += 42;
f;
})();
} catch (e) {
console.log("PASS");
Expand Down Expand Up @@ -422,9 +423,7 @@ issue_4893_2: {
expect: {
try{
(function() {
var a;
a = null;
a.p += 42;
null.p += 42;
})();
} catch (e) {
console.log("PASS");
Expand Down Expand Up @@ -610,6 +609,7 @@ issue_5411_2: {
evaluate: true,
hoist_vars: true,
reduce_vars: true,
sequences: true,
toplevel: true,
unused: true,
}
Expand All @@ -622,9 +622,9 @@ issue_5411_2: {
}
expect: {
var b, c;
b++;
b++,
b = "PASS",
c;
c,
console.log(b);
}
expect_stdout: "PASS"
Expand Down

0 comments on commit ce8ef52

Please sign in to comment.