Don't drop unused setter argument.
authorMihai Bazon <mihai@bazon.net>
Wed, 7 Aug 2013 09:04:58 +0000 (12:04 +0300)
committerMihai Bazon <mihai@bazon.net>
Wed, 7 Aug 2013 09:04:58 +0000 (12:04 +0300)
Fix #257

lib/compress.js
test/compress/drop-unused.js

index fcc3f31..3bf9f67 100644 (file)
@@ -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()) {
index bf5cd29..406ce9e 100644 (file)
@@ -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;
+            }
+        }
+    }
+}