diff --git a/lib/compress.js b/lib/compress.js index 45a2cdff..2a026ba3 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -686,6 +686,7 @@ merge(Compressor.prototype, { d.escaped = true; return; } else if (parent instanceof AST_Array + || parent instanceof AST_Await || parent instanceof AST_Conditional && node !== parent.condition || parent instanceof AST_Sequence && node === parent.tail_node()) { mark_escaped(d, scope, parent, parent, level + 1); diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index 38207cd9..c0713730 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -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"); + }); + })(); + } +}