Skip to content

Commit

Permalink
fix corner case in unused (#5629)
Browse files Browse the repository at this point in the history
fixes #5628
  • Loading branch information
alexlamsl authored Aug 24, 2022
1 parent 4db8106 commit 9cdc1ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -6905,7 +6905,7 @@ Compressor.prototype.compress = function(node) {
initializations.add(def.id, node);
if (tw.parent() instanceof AST_ExportDefault) {
export_defaults[def.id] = true;
return;
return scan_ref_scoped(node, descend, true);
}
if (drop && !(def.id in lambda_ids)) lambda_ids[def.id] = 1;
return true;
Expand Down
20 changes: 20 additions & 0 deletions test/compress/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,23 @@ issue_5444: {
export var a = console;
}
}

issue_5628: {
options = {
unused: true,
}
input: {
var a;
export default function f() {
for (a in 42);
}
console.log(a);
}
expect: {
var a;
export default function f() {
for (a in 42);
}
console.log(a);
}
}

0 comments on commit 9cdc1ef

Please sign in to comment.