diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-12-18 12:07:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-18 12:07:53 +0800 |
commit | 0b0eac1d5dc6e1cc1e9bf3682871cafdda59066d (patch) | |
tree | f58e51ee9651e22eab2c68a0f17c98139da84582 /lib | |
parent | b29fc8b27c7bf4f48ff354ea2b9d55f7f4b69f79 (diff) | |
download | tracifyjs-0b0eac1d5dc6e1cc1e9bf3682871cafdda59066d.tar.gz tracifyjs-0b0eac1d5dc6e1cc1e9bf3682871cafdda59066d.zip |
drop property assignment to constants (#2612)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index 52c30964..735b4d2d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1708,6 +1708,11 @@ merge(Compressor.prototype, { return this.consequent._dot_throw(compressor) || this.alternative._dot_throw(compressor); }) + def(AST_Dot, function(compressor) { + if (!is_strict(compressor)) return false; + if (this.expression instanceof AST_Function && this.property == "prototype") return false; + return true; + }); def(AST_Sequence, function(compressor) { return this.tail_node()._dot_throw(compressor); }); @@ -3184,8 +3189,14 @@ merge(Compressor.prototype, { } }); def(AST_Assign, function(compressor){ - this.write_only = !this.left.has_side_effects(compressor); - return this; + var left = this.left; + if (left.has_side_effects(compressor)) return this; + this.write_only = true; + while (left instanceof AST_PropAccess) { + left = left.expression; + } + if (left instanceof AST_Symbol) return this; + return this.right.drop_side_effect_free(compressor); }); def(AST_Conditional, function(compressor){ var consequent = this.consequent.drop_side_effect_free(compressor); |