fix corner case in awaits (#5828)

fixes #5791
This commit is contained in:
Alex Lam S.L
2024-06-06 04:51:02 +03:00
committed by GitHub
parent c21a8eee7b
commit 09910771a1
2 changed files with 81 additions and 2 deletions

View File

@@ -3642,3 +3642,66 @@ issue_5692_2: {
]
node_version: ">=8"
}
issue_5791: {
options = {
awaits: true,
reduce_funcs: true,
reduce_vars: true,
side_effects: true,
unused: true,
}
input: {
(async function() {
async function f() {
try {
await {
then(resolve) {
setImmediate(() => {
console.log("foo");
resolve();
});
},
};
} catch (e) {
console.log("FAIL", e);
}
}
async function g() {
try {
await f();
} catch (e) {}
}
await g();
console.log("bar");
})();
}
expect: {
(async function() {
await async function() {
try {
await async function() {
try {
await {
then(resolve) {
setImmediate(() => {
console.log("foo");
resolve();
});
},
};
} catch (e) {
console.log("FAIL", e);
}
}();
} catch (e) {}
}();
console.log("bar");
})();
}
expect_stdout: [
"foo",
"bar",
]
node_version: ">=8"
}