fix corner case in inline (#5635)

fixes #5634
This commit is contained in:
Alex Lam S.L
2022-08-29 17:45:35 +01:00
committed by GitHub
parent 7c52af0dec
commit 15b608f74c
2 changed files with 152 additions and 1 deletions

View File

@@ -13729,7 +13729,7 @@ Compressor.prototype.compress = function(node) {
}));
return !abort;
};
} else if (in_await && !is_async(fn) || in_async_generator(scope)) {
} else if (in_await || is_async(fn) || in_async_generator(scope)) {
verify_body = function(stat) {
var abort = false;
var find_return = new TreeWalker(function(node) {

View File

@@ -3229,3 +3229,154 @@ issue_5528_4: {
]
node_version: ">=8"
}
issue_5634_1: {
options = {
awaits: true,
inline: true,
side_effects: true,
}
input: {
var a = "foo";
(async function() {
(async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
})();
})();
console.log(a);
}
expect: {
var a = "foo";
(async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
})();
console.log(a);
}
expect_stdout: [
"moo",
"bar",
"baz",
]
node_version: ">=8"
}
issue_5634_2: {
options = {
inline: true,
}
input: {
var a = "foo";
(async function() {
await async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
}();
})();
console.log(a);
}
expect: {
var a = "foo";
(async function() {
await async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
}();
})();
console.log(a);
}
expect_stdout: [
"moo",
"bar",
"baz",
]
node_version: ">=8"
}
issue_5634_3: {
options = {
awaits: true,
inline: true,
}
input: {
var a = "foo";
(async function() {
return async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
}();
})();
console.log(a);
}
expect: {
var a = "foo";
(async function() {
return async function() {
try {
return {
then(resolve) {
console.log("bar");
resolve();
console.log("baz");
},
};
} finally {
a = "moo";
}
}();
})();
console.log(a);
}
expect_stdout: [
"moo",
"bar",
"baz",
]
node_version: ">=8"
}