From 4c4dc2137cc256bb1e7a3827b4c96c95be42782e Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Wed, 7 Aug 2013 12:04:58 +0300 Subject: [PATCH] Don't drop unused setter argument. Fix #257 --- lib/compress.js | 2 +- test/compress/drop-unused.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index fcc3f31e..3bf9f672 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -948,7 +948,7 @@ merge(Compressor.prototype, { // pass 3: we should drop declarations not in_use var tt = new TreeTransformer( function before(node, descend, in_list) { - if (node instanceof AST_Lambda) { + if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) { for (var a = node.argnames, i = a.length; --i >= 0;) { var sym = a[i]; if (sym.unreferenced()) { diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index bf5cd296..406ce9e6 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -95,3 +95,27 @@ unused_circular_references_3: { } } } + +unused_keep_setter_arg: { + options = { unused: true }; + input: { + var x = { + _foo: null, + set foo(val) { + }, + get foo() { + return this._foo; + } + } + } + expect: { + var x = { + _foo: null, + set foo(val) { + }, + get foo() { + return this._foo; + } + } + } +} -- 2.34.1