Skip to content

Commit

Permalink
fix corner case in join_vars
Browse files Browse the repository at this point in the history
fixes #5950
  • Loading branch information
alexlamsl committed Oct 27, 2024
1 parent af71274 commit 9840f7a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -10462,9 +10462,11 @@ Compressor.prototype.compress = function(node) {
def.orig[def.orig.indexOf(node)] = name;
for (var s = scope; s !== def.scope && (s = s.parent_scope);) {
remove(s.enclosed, def);
s._var_names = undefined;
}
def.scope = scope;
def.scope.variables.del(def.name);
scope.variables.set(def.name, def);
def.scope = scope;
}),
value: defn.value,
});
Expand Down
32 changes: 32 additions & 0 deletions test/compress/let.js
Original file line number Diff line number Diff line change
Expand Up @@ -2566,3 +2566,35 @@ issue_5787: {
expect_stdout: "PASS"
node_version: ">=6"
}

issue_5950: {
options = {
conditionals: true,
join_vars: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
"use strict";
{
let a;
if (console.log("PASS")) {
var b = function() {
a;
}, c = b;
}
}
}
expect: {
"use strict";
{
let a;
console.log("PASS") && function() {
a;
};
}
}
expect_stdout: "PASS"
node_version: ">=4"
}

0 comments on commit 9840f7a

Please sign in to comment.