diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-17 14:20:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 21:20:31 +0800 |
commit | 09d93cc6c80a934daae53dea6a13d96924a0f466 (patch) | |
tree | 9d571605c2b4c743658e11c779767f3d29768040 /lib/compress.js | |
parent | dd1374aa8adc0a0fc9fec8e173d424e8e1d17041 (diff) | |
download | tracifyjs-09d93cc6c80a934daae53dea6a13d96924a0f466.tar.gz tracifyjs-09d93cc6c80a934daae53dea6a13d96924a0f466.zip |
fix corner case in `evaluate` (#4120)
fixes #4119
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 76be4753..f59cc4d4 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -3362,6 +3362,7 @@ merge(Compressor.prototype, { cached.forEach(function(node) { delete node._eval; }); + if (cached.unsafe) return this; if (ignore_side_effects) return val; if (!val || val instanceof RegExp) return val; if (typeof val == "function" || typeof val == "object") return this; @@ -3430,6 +3431,10 @@ merge(Compressor.prototype, { var value = node._eval(compressor, ignore_side_effects, cached, depth); if (value === node) return this; modified(lhs); + if (Array.isArray(value)) value.toString = function() { + cached.unsafe = true; + return "[]"; + }; return value; }); def(AST_Sequence, function(compressor, ignore_side_effects, cached, depth) { |