fix escape analysis for `AST_Await

fixes #2566
This commit is contained in:
alexlamsl
2017-12-10 14:43:09 +08:00
parent f778a0aa01
commit c7e8fc4830
2 changed files with 47 additions and 0 deletions

View File

@@ -5187,3 +5187,49 @@ escape_yield: {
expect_stdout: "PASS"
node_version: ">=4"
}
escape_await: {
options = {
reduce_funcs: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
function main() {
var thing;
baz().then(x => {
thing = x;
});
baz().then(x => {
if (thing !== (thing = x))
console.log("FAIL");
else
console.log("PASS");
});
}
function foo() {}
async function baz() {
return await foo;
}
main();
}
expect: {
function foo() {}
async function baz() {
return await foo;
}
(function() {
var thing;
baz().then(x => {
thing = x;
});
baz().then(x => {
if (thing !== (thing = x))
console.log("FAIL");
else
console.log("PASS");
});
})();
}
}