aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-21 15:05:31 +0100
committerGitHub <noreply@github.com>2020-05-21 22:05:31 +0800
commitaeb9ea5ac22fe37d0a74bb8cacd6edfa1ae9ef8c (patch)
tree41eb20a3379f311c930033a519f4b5a9d7da34d8
parent798841be82be847b357d2498d171f3a33de88b92 (diff)
downloadtracifyjs-aeb9ea5ac22fe37d0a74bb8cacd6edfa1ae9ef8c.tar.gz
tracifyjs-aeb9ea5ac22fe37d0a74bb8cacd6edfa1ae9ef8c.zip
fix corner case in `inline` (#3915)
fixes #3911
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/functions.js25
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 006b635a..06d04cc5 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -6234,9 +6234,9 @@ merge(Compressor.prototype, {
&& !fn.uses_arguments
&& !fn.pinned()
&& !(fn.name && fn instanceof AST_Function)
- && (value = can_flatten_body(stat))
&& (exp === fn
|| !recursive_ref(compressor, def = exp.definition()) && fn.is_constant_expression(exp.scope))
+ && (value = can_flatten_body(stat))
&& !fn.contains_this()) {
if (can_substitute_directly()) {
var args = self.args.slice();
diff --git a/test/compress/functions.js b/test/compress/functions.js
index db5466ea..7ad6ff03 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -4680,3 +4680,28 @@ issue_3852: {
}
expect_stdout: "PASS"
}
+
+issue_3911: {
+ options = {
+ collapse_vars: true,
+ conditionals: true,
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f() {
+ return function() {
+ if (a) (a++, b += a);
+ f();
+ };
+ }
+ var a = f, b;
+ console.log("PASS");
+ }
+ expect: {
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+}