diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-05-07 19:34:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-08 02:34:27 +0800 |
commit | ee9ceb79ca61c8adb9bbf7e82459ab0bbe3aaced (patch) | |
tree | c029ea580ee0f1c5747c58c1bbb3e8dcf23f3f5f | |
parent | ac1f7d689b7dbd6311a6e8eaa633072db9d9703c (diff) | |
download | tracifyjs-ee9ceb79ca61c8adb9bbf7e82459ab0bbe3aaced.tar.gz tracifyjs-ee9ceb79ca61c8adb9bbf7e82459ab0bbe3aaced.zip |
fix corner case in `collapse_vars` (#4917)
fixes #4916
-rw-r--r-- | lib/compress.js | 2 | ||||
-rw-r--r-- | test/compress/default-values.js | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js index a9203ce9..fdf46fb9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1490,7 +1490,7 @@ merge(Compressor.prototype, { lhs = lhs.fixed_value(); } if (!lhs) return true; - if (lhs.is_constant()) return true; + if (lhs.tail_node().is_constant()) return true; return is_lhs_read_only(lhs, compressor); } if (lhs instanceof AST_SymbolRef) { diff --git a/test/compress/default-values.js b/test/compress/default-values.js index 1a21f513..56fa5c95 100644 --- a/test/compress/default-values.js +++ b/test/compress/default-values.js @@ -1703,3 +1703,29 @@ issue_4854: { expect_stdout: "undefined" node_version: ">=6" } + +issue_4916: { + options = { + collapse_vars: true, + pure_getters: "strict", + reduce_vars: true, + } + input: { + var log = console.log; + (function(b = "foo") { + b.value = "FAIL"; + b; + log(b.value); + })(); + } + expect: { + var log = console.log; + (function(b = "foo") { + b.value = "FAIL"; + b; + log(b.value); + })(); + } + expect_stdout: "undefined" + node_version: ">=6" +} |