diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-07-28 20:11:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-29 03:11:02 +0800 |
commit | dfe47bcc42d0385577ecffa7fe312025e1369e7b (patch) | |
tree | 8d1e86310aa579611771c0357c3abe5d0d66327a | |
parent | 6d3dcaa59e5b7a6e3bef2de1daf4edd66a7bf274 (diff) | |
download | tracifyjs-dfe47bcc42d0385577ecffa7fe312025e1369e7b.tar.gz tracifyjs-dfe47bcc42d0385577ecffa7fe312025e1369e7b.zip |
fix corner case in `ie8` & `reduce_vars` (#4029)
fixes #4028
-rw-r--r-- | lib/compress.js | 3 | ||||
-rw-r--r-- | test/compress/ie8.js | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index c8f5b267..d439ed4c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -600,6 +600,7 @@ merge(Compressor.prototype, { return node.right; }; } else { + if (d.single_use) d.single_use = false; sym.fixed = d.fixed = function() { return make_node(AST_Binary, node, { operator: node.operator.slice(0, -1), @@ -894,9 +895,9 @@ merge(Compressor.prototype, { d.assignments++; var fixed = d.fixed; if (safe_to_read(tw, d) && safe_to_assign(tw, d)) { - if (d.single_use) d.single_use = false; push_ref(d, exp); mark(tw, d); + if (d.single_use) d.single_use = false; d.fixed = function() { return make_node(AST_Binary, node, { operator: node.operator.slice(0, -1), diff --git a/test/compress/ie8.js b/test/compress/ie8.js index 8ed23102..19437074 100644 --- a/test/compress/ie8.js +++ b/test/compress/ie8.js @@ -2661,3 +2661,33 @@ issue_4019: { } expect_stdout: "0" } + +issue_4028: { + options = { + reduce_vars: true, + toplevel: true, + unused: true, + } + mangle = { + ie8: true, + } + input: { + function a() { + try { + A; + } catch (e) {} + } + var b = a += a; + console.log(typeof b); + } + expect: { + function a() { + try { + A; + } catch (a) {} + } + var b = a += a; + console.log(typeof b); + } + expect_stdout: "string" +} |