aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-18 16:52:37 +0000
committerGitHub <noreply@github.com>2020-12-19 00:52:37 +0800
commit44e494f16f5ce7fc1272e6ca6ae227f77623c2f9 (patch)
treec20e467ce792c1857369a617e41e0ab4fa2ab618
parent2415a72e755c7685c677c2edf0c1e91fbed54e2e (diff)
downloadtracifyjs-44e494f16f5ce7fc1272e6ca6ae227f77623c2f9.tar.gz
tracifyjs-44e494f16f5ce7fc1272e6ca6ae227f77623c2f9.zip
fix corner case in `merge_vars` (#4407)
fixes #4406
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/async.js30
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 1249e620..ab68c45d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4801,7 +4801,7 @@ merge(Compressor.prototype, {
if (node instanceof AST_Call) {
var exp = node.expression;
var tail = exp.tail_node();
- if (!(tail instanceof AST_Function)) return;
+ if (!is_function(tail)) return;
if (exp !== tail) exp.expressions.slice(0, -1).forEach(function(node) {
node.walk(tw);
});
diff --git a/test/compress/async.js b/test/compress/async.js
index 79189c7d..4fd16efd 100644
--- a/test/compress/async.js
+++ b/test/compress/async.js
@@ -567,3 +567,33 @@ issue_4377: {
expect_stdout: "function"
node_version: ">=8"
}
+
+issue_4406: {
+ options = {
+ merge_vars: true,
+ }
+ input: {
+ A = "PASS";
+ B = "FAIL";
+ (function() {
+ var a, b;
+ a = A;
+ (async function({
+ [console.log(a)]: {},
+ }) {})((b = B) && { undefined: b });
+ })();
+ }
+ expect: {
+ A = "PASS";
+ B = "FAIL";
+ (function() {
+ var a, b;
+ a = A;
+ (async function({
+ [console.log(a)]: {},
+ }) {})((b = B) && { undefined: b });
+ })();
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}