Skip to content

Commit

Permalink
fix corner case in dead_code
Browse files Browse the repository at this point in the history
fixes #5941
  • Loading branch information
alexlamsl committed Sep 28, 2024
1 parent d460c70 commit cc76429
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -13141,8 +13141,8 @@ Compressor.prototype.compress = function(node) {
var scope = def.scope.resolve();
var local = scope === compressor.find_parent(AST_Lambda);
var level = 0, node;
parent = compressor.self();
if (!(scope.uses_arguments && is_funarg(def)) || compressor.has_directive("use strict")) do {
if ((compressor.has_directive("use strict") || !(scope.uses_arguments && is_funarg(def)))
&& (parent = compressor.self()) === self) do {
node = parent;
parent = compressor.parent(level++);
if (parent instanceof AST_Assign) {
Expand Down
17 changes: 17 additions & 0 deletions test/compress/dead-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -1776,3 +1776,20 @@ issue_5882_3: {
}
expect_stdout: "true"
}

issue_5941: {
options = {
assignments: true,
conditionals: true,
dead_code: true,
}
input: {
var a = 1;
a = a &&= (a = console) && console.log(typeof a);
}
expect: {
var a = 1;
a = (a = a && console) && console.log(typeof a);
}
expect_stdout: "object"
}

0 comments on commit cc76429

Please sign in to comment.