diff --git a/lib/compress.js b/lib/compress.js index 81298cb673..d920bc119a 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -10436,7 +10436,7 @@ merge(Compressor.prototype, { } else { value = fixed.optimize(compressor); } - if (value === fixed) value = value.transform(new TreeTransformer(function(node, descend) { + value = value.transform(new TreeTransformer(function(node, descend) { if (node instanceof AST_Scope) return node; node = node.clone(); descend(node, this); diff --git a/test/compress/bigint.js b/test/compress/bigint.js index 9c21d083bf..b417268c3d 100644 --- a/test/compress/bigint.js +++ b/test/compress/bigint.js @@ -60,3 +60,33 @@ issue_4590: { expect_stdout: "PASS" node_version: ">=10" } + +issue_4801: { + options = { + booleans: true, + collapse_vars: true, + reduce_vars: true, + unused: true, + } + input: { + try { + (function(a) { + A = 42; + a || A; + })(!(0 == 42 >> 0o644n)); + } catch (e) { + console.log("PASS"); + } + } + expect: { + try { + (function(a) { + 0 != (A = 42) >> 0o644n || A; + })(); + } catch (e) { + console.log("PASS"); + } + } + expect_stdout: "PASS" + node_version: ">=10" +} diff --git a/test/compress/let.js b/test/compress/let.js index 3f42dd1087..90d99524fc 100644 --- a/test/compress/let.js +++ b/test/compress/let.js @@ -419,36 +419,36 @@ reduce_vars_3: { } input: { "use strict"; - (function(scope) { + (function(a) { let i = 1; function f() { i = 0; } - for (let i = 0, x = 0; i < scope.length; i++, x++) { + for (let i = 0, x = 0; i < a.length; i++, x++) { if (x != i) { console.log("FAIL"); break; } f(); - console.log(scope[i]); + console.log(a[i]); } console.log(i); })([ 4, 2 ]); } expect: { "use strict"; - (function(scope) { + (function(a) { let i = 1; function f() { i = 0; } - for (let i = 0, x = 0; i < scope.length; i++, x++) { + for (let i = 0, x = 0; i < a.length; i++, x++) { if (x != i) { console.log("FAIL"); break; } f(); - console.log(scope[i]); + console.log(a[i]); } console.log(i); })([ 4, 2 ]);