aboutsummary
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-03-06 18:27:06 +0000
committerGitHub <noreply@github.com>2020-03-06 18:27:06 +0000
commitbdc8ef221802a4da600ff1cdca34e9cc5c5fafc2 (patch)
treef1a12c9a8d5f6439bca36a138ed43a0bf1aabda2
parentbca52fcba2a99433ce0e30ef7357bd46b676380c (diff)
downloadtracifyjs-bdc8ef221802a4da600ff1cdca34e9cc5c5fafc2.tar.gz
tracifyjs-bdc8ef221802a4da600ff1cdca34e9cc5c5fafc2.zip
fix corner case in `collapse_vars` (#3745)
fixes #3744
-rw-r--r--lib/compress.js5
-rw-r--r--test/compress/collapse_vars.js41
2 files changed, 45 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index ab89e927..763aabd8 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1384,7 +1384,10 @@ merge(Compressor.prototype, {
function is_last_node(node, parent) {
if (node instanceof AST_Call) {
var fn = node.expression;
- if (fn instanceof AST_SymbolRef) fn = fn.fixed_value();
+ if (fn instanceof AST_SymbolRef) {
+ if (fn.definition().recursive_refs > 0) return true;
+ fn = fn.fixed_value();
+ }
if (!(fn instanceof AST_Lambda)) return true;
if (fn.collapse_scanning) return false;
fn.collapse_scanning = true;
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 58ae5c62..99e57b32 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -7765,3 +7765,44 @@ issue_3700: {
}
expect_stdout: "PASS"
}
+
+issue_3744: {
+ options = {
+ collapse_vars: true,
+ inline: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ (function f(a) {
+ ({
+ get p() {
+ switch (1) {
+ case 0:
+ f((a = 2, 3));
+ case 1:
+ console.log(function g(b) {
+ return b || "PASS";
+ }());
+ }
+ }
+ }).p;
+ })();
+ }
+ expect: {
+ (function f(a) {
+ ({
+ get p() {
+ switch (1) {
+ case 0:
+ f();
+ case 1:
+ console.log(b || "PASS");
+ }
+ var b;
+ }
+ }).p;
+ })();
+ }
+ expect_stdout: "PASS"
+}