aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-06-22 17:36:07 +0100
committerGitHub <noreply@github.com>2021-06-23 00:36:07 +0800
commit95090dbf24dbda120924eb3cd003f80e0128f52a (patch)
treee3716c1d407492288c6c0f929eebb333ea59e820
parent7c5b6f349e5818a13ccb93c88b79a607d236bd0b (diff)
downloadtracifyjs-95090dbf24dbda120924eb3cd003f80e0128f52a.tar.gz
tracifyjs-95090dbf24dbda120924eb3cd003f80e0128f52a.zip
fix corner case in `side_effects` (#5024)
fixes #5023
-rw-r--r--lib/compress.js2
-rw-r--r--test/compress/awaits.js46
2 files changed, 47 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 0d98e456..66441e80 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -5275,7 +5275,7 @@ merge(Compressor.prototype, {
|| any(this.body, compressor);
});
def(AST_SymbolRef, function(compressor) {
- return !this.is_declared(compressor);
+ return !this.is_declared(compressor) || !can_drop_symbol(this, compressor);
});
def(AST_Template, function(compressor) {
if (any(this.expressions, compressor)) return true;
diff --git a/test/compress/awaits.js b/test/compress/awaits.js
index 9b4d8ba7..adfc9e4a 100644
--- a/test/compress/awaits.js
+++ b/test/compress/awaits.js
@@ -1869,3 +1869,49 @@ issue_5019_3: {
]
node_version: ">=8"
}
+
+issue_5023_1: {
+ options = {
+ awaits: true,
+ reduce_vars: true,
+ side_effects: true,
+ }
+ input: {
+ (async function() {
+ let a = a;
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (async function() {
+ let a = a;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}
+
+issue_5023_2: {
+ options = {
+ awaits: true,
+ reduce_vars: true,
+ side_effects: true,
+ }
+ input: {
+ (async function() {
+ let a;
+ a = a;
+ })();
+ console.log("PASS");
+ }
+ expect: {
+ (function() {
+ let a;
+ a = a;
+ })();
+ console.log("PASS");
+ }
+ expect_stdout: "PASS"
+ node_version: ">=8"
+}