diff --git a/lib/compress.js b/lib/compress.js index e5d64c9a..81d84906 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -283,10 +283,16 @@ merge(Compressor.prototype, { if (node instanceof AST_VarDef) { var d = node.name.definition(); if (d.fixed == null) { - d.fixed = node.value && function() { - return node.value; - }; + if (node.value) { + d.fixed = function() { + return node.value; + }; + descend(); + } else { + d.fixed = null; + } mark_as_safe(d); + return true; } else if (node.value) { d.fixed = false; } @@ -1167,6 +1173,9 @@ merge(Compressor.prototype, { def(AST_UnaryPrefix, function() { return this.operator == "void"; }); + def(AST_Seq, function(compressor) { + return this.cdr.may_eq_null(compressor); + }); def(AST_PropAccess, function(compressor) { return !compressor.option("unsafe"); }); diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 5ad5c6da..fdfec99e 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -1916,3 +1916,25 @@ side_effects_assign: { } expect_stdout: "undefined" } + +pure_getters: { + options = { + pure_getters: true, + reduce_vars: true, + side_effects: true, + toplevel: true, + } + input: { + try { + var a = (a.b, 2); + } catch (e) {} + console.log(a); + } + expect: { + try { + var a = (a.b, 2); + } catch (e) {} + console.log(a); + } + expect_stdout: "undefined" +}