aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-11 21:01:14 +0100
committerGitHub <noreply@github.com>2020-05-12 04:01:14 +0800
commitee7647dc676b18355286609e9a4404dbcdcecc90 (patch)
treed3cad823d792c7716cf83b57906e3d9e951ecd3c
parentbd2f53bc8b505ff5bba4e899ea4886d856128b39 (diff)
downloadtracifyjs-ee7647dc676b18355286609e9a4404dbcdcecc90.tar.gz
tracifyjs-ee7647dc676b18355286609e9a4404dbcdcecc90.zip
fix corner case in `collapse_vars` (#3885)
fixes #3884
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/collapse_vars.js25
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index cb5d9c7b..415f9bdb 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1243,6 +1243,7 @@ merge(Compressor.prototype, {
col: node.start.col
});
if (candidate instanceof AST_UnaryPostfix) {
+ delete candidate.expression.fixed;
return make_node(AST_UnaryPrefix, candidate, candidate);
}
if (candidate instanceof AST_VarDef) {
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index c93a1465..ff0837a2 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -7954,3 +7954,28 @@ mangleable_var: {
}
expect_stdout: "PASS"
}
+
+issue_3884: {
+ options = {
+ collapse_vars: true,
+ evaluate: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 100, b = 1;
+ {
+ a++ + a || a;
+ b <<= a;
+ }
+ console.log(a, b);
+ }
+ expect: {
+ var a = 100;
+ ++a;
+ console.log(a, 32);
+ }
+ expect_stdout: "101 32"
+}