diff options
-rw-r--r-- | lib/compress.js | 14 | ||||
-rw-r--r-- | test/compress/destructured.js | 33 |
2 files changed, 39 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index 0718e5c7..1dc01f93 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -5568,13 +5568,11 @@ merge(Compressor.prototype, { if (def.value) def.value = def.value.transform(tt); if (def.name instanceof AST_Destructured) { var name = trim_destructured(def.name, def.value, function(node) { - if (node instanceof AST_SymbolDeclaration) { - if (!drop_vars) return node; - if (node.definition().id in in_use_ids) return node; - if (is_catch(node)) return node; - if (is_var && !can_drop_symbol(node)) return node; - return null; - } + if (!drop_vars) return node; + if (node.definition().id in in_use_ids) return node; + if (is_catch(node)) return node; + if (is_var && !can_drop_symbol(node)) return node; + return null; }); if (name) { flush(); @@ -5747,7 +5745,7 @@ merge(Compressor.prototype, { descend(node, tt); if (node.left instanceof AST_Destructured) { var lhs = trim_destructured(node.left, node.right, function(node) { - if (node instanceof AST_SymbolRef) return node; + return node; }); if (!lhs) return node.right; node.left = lhs; diff --git a/test/compress/destructured.js b/test/compress/destructured.js index 7fe2f0c8..98e84f48 100644 --- a/test/compress/destructured.js +++ b/test/compress/destructured.js @@ -2164,3 +2164,36 @@ issue_4446: { expect_stdout: "PASS" node_version: ">=6" } + +issue_4456: { + options = { + pure_getters: true, + unused: true, + } + input: { + var o = { + set p(v) { + console.log(v); + }, + }; + [ function() { + try { + return o; + } catch ({}) {} + }().p ] = [ "PASS" ]; + } + expect: { + var o = { + set p(v) { + console.log(v); + }, + }; + [ function() { + try { + return o; + } catch ({}) {} + }().p ] = [ "PASS" ]; + } + expect_stdout: "PASS" + node_version: ">=6" +} |