fix corner case in `inline` (#4596)
authorAlex Lam S.L <alexlamsl@gmail.com>
Tue, 26 Jan 2021 17:30:05 +0000 (17:30 +0000)
committerGitHub <noreply@github.com>
Tue, 26 Jan 2021 17:30:05 +0000 (01:30 +0800)
fixes #4595

lib/compress.js
test/compress/awaits.js

index ac380cf..a662b99 100644 (file)
@@ -8270,7 +8270,7 @@ merge(Compressor.prototype, {
             if (can_inline
                 && !fn.uses_arguments
                 && !fn.pinned()
-                && !(fn.name && fn instanceof AST_Function)
+                && !(fn.name && is_function(fn))
                 && (exp === fn || !recursive_ref(compressor, def = exp.definition())
                     && fn.is_constant_expression(find_scope(compressor)))
                 && !has_spread
index 0ffa1a9..01a5571 100644 (file)
@@ -1024,3 +1024,26 @@ issue_4581: {
     expect_stdout: "PASS"
     node_version: ">=8"
 }
+
+issue_4595: {
+    options = {
+        awaits: true,
+        inline: true,
+    }
+    input: {
+        (async function() {
+            await async function f() {
+                console.log(f.length);
+            }();
+        })();
+    }
+    expect: {
+        (async function() {
+            await async function f() {
+                console.log(f.length);
+            }();
+        })();
+    }
+    expect_stdout: "0"
+    node_version: ">=8"
+}