diff options
-rw-r--r-- | lib/compress.js | 18 | ||||
-rw-r--r-- | test/compress/default-values.js | 28 |
2 files changed, 39 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js index 97b6149b..58e0d785 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5460,7 +5460,7 @@ merge(Compressor.prototype, { var calls_to_drop_args = []; var fns_with_marked_args = []; var trimmer = new TreeTransformer(function(node) { - if (node instanceof AST_DefaultValue) return trim_default(tt, trimmer, node); + if (node instanceof AST_DefaultValue) return trim_default(trimmer, node); if (node instanceof AST_DestructuredArray) { var trim = true; for (var i = node.elements.length; --i >= 0;) { @@ -5482,10 +5482,13 @@ merge(Compressor.prototype, { node.key = node.key.transform(tt); retain = node.key.has_side_effects(compressor); } - if (retain && is_decl(node.value)) return node; - var value = node.value.transform(trimmer); - if (!value) return List.skip; - node.value = value; + if (retain && is_decl(node.value)) { + node.value = node.value.transform(tt); + } else { + var value = node.value.transform(trimmer); + if (!value) return List.skip; + node.value = value; + } return node; } if (node instanceof AST_SymbolDeclaration) return node.definition().id in in_use_ids ? node : null; @@ -6042,7 +6045,7 @@ merge(Compressor.prototype, { return (node instanceof AST_DefaultValue ? node.name : node) instanceof AST_SymbolDeclaration; } - function trim_default(tt, trimmer, node) { + function trim_default(trimmer, node) { node.value = node.value.transform(tt); var name = node.name.transform(trimmer); if (!name) { @@ -6076,7 +6079,7 @@ merge(Compressor.prototype, { if (compressor.option("default_values") && value && value.is_defined(compressor)) { node = node.name; } else { - return trim_default(tt, trimmer, node); + return trim_default(trimmer, node); } } if (node instanceof AST_DestructuredArray) { @@ -6125,6 +6128,7 @@ merge(Compressor.prototype, { retain = false; } if (retain && is_decl(prop.value)) { + prop.value = prop.value.transform(tt); properties.push(prop); } else { var newValue = prop.value.transform(trimmer); diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 0e05d37d..acd285f4 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1160,3 +1160,31 @@ issue_4461_2: { expect_stdout: "PASS" node_version: ">=6" } + +issue_4468: { + options = { + evaluate: true, + keep_fargs: false, + pure_getters: "strict", + reduce_vars: true, + side_effects: true, + unused: true, + } + input: { + (function(a) { + var { + [console.log("PASS")]: b = a && (a.p = 0), + } = 0; + a; + })(1234); + } + expect: { + (function() { + var { + [console.log("PASS")]: b = 0, + } = 0; + })(); + } + expect_stdout: "PASS" + node_version: ">=6" +} |