aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-23 19:37:52 +0000
committerGitHub <noreply@github.com>2021-01-24 03:37:52 +0800
commitacc443b2cf0614351aeb953e393260f13f783c96 (patch)
tree788ea95625b1a5c6972dad56a029b4b13d5b857c /lib/compress.js
parentf87e7be12c7857ec0fc772a9ea4db6d24b5e3551 (diff)
downloadtracifyjs-acc443b2cf0614351aeb953e393260f13f783c96.tar.gz
tracifyjs-acc443b2cf0614351aeb953e393260f13f783c96.zip
fix corner case in `reduce_vars` (#4585)
fixes #4584
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 547ef574..c6ebb34c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -786,7 +786,10 @@ merge(Compressor.prototype, {
}
var d = sym.definition();
d.assignments++;
- if (fixed && !is_modified(compressor, tw, node, node.right, 0) && safe_to_assign(tw, d)) {
+ if (fixed
+ && !is_modified(compressor, tw, node, node.right, 0)
+ && !sym.in_arg
+ && safe_to_assign(tw, d)) {
push_ref(d, sym);
mark(tw, d);
if (d.single_use && left instanceof AST_Destructured) d.single_use = false;
@@ -809,7 +812,7 @@ merge(Compressor.prototype, {
}
var safe = safe_to_read(tw, d);
node.right.walk(tw);
- if (safe && safe_to_assign(tw, d)) {
+ if (safe && !left.in_arg && safe_to_assign(tw, d)) {
push_ref(d, left);
mark(tw, d);
if (d.single_use) d.single_use = false;
@@ -1117,7 +1120,7 @@ merge(Compressor.prototype, {
var d = exp.definition();
d.assignments++;
var fixed = d.fixed;
- if (safe_to_read(tw, d) && safe_to_assign(tw, d)) {
+ if (safe_to_read(tw, d) && !exp.in_arg && safe_to_assign(tw, d)) {
push_ref(d, exp);
mark(tw, d);
if (d.single_use) d.single_use = false;