diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-02-28 19:59:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-28 19:59:19 +0800 |
commit | 73e98dcda48be52f2c045038554b2cfe184a9a5a (patch) | |
tree | c16dfe8aba269a2ef4dc4adce6e59f786a5d2fad /lib | |
parent | 36bca6934de494a79a1c1af952653eaaf9c15ed8 (diff) | |
download | tracifyjs-73e98dcda48be52f2c045038554b2cfe184a9a5a.tar.gz tracifyjs-73e98dcda48be52f2c045038554b2cfe184a9a5a.zip |
drop `side_effects`-free `return` values (#2965)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index ed094874..9adef60e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3644,7 +3644,15 @@ merge(Compressor.prototype, { if (this.expression instanceof AST_Function && (!this.expression.name || !this.expression.name.definition().references.length)) { var node = this.clone(); - node.expression.process_expression(false, compressor); + var exp = node.expression; + exp.process_expression(false, compressor); + exp.walk(new TreeWalker(function(node) { + if (node instanceof AST_Return && node.value) { + node.value = node.value.drop_side_effect_free(compressor); + return true; + } + if (node instanceof AST_Scope && node !== exp) return true; + })); return node; } return this; |