Minifier emits `if (…) async function` for #8953 input again
Describe the bug
The input from #8953 produces an invalid program again. #9677 fixed it, and its fixture output was console.log(1);. The snapshot at crates/swc_ecma_minifier/tests/fixture/issues/8953/output.js changed to an invalid program with #10201, back to valid with its revert, and to invalid again with the re-land. It currently records:
if (1 === x) async function x() {}As in the original report, only async function is affected; function and function* still fold to 1.
Input code
"use strict";
const k = (() => {
let x = 1;
switch (x) {
case x: async function x() {}
}
return x;
})();
console.log(k);Config
@swc/core 1.16.2, minifySync(src, { compress: {}, mangle: true }). Same output on main (the fixture above).
Output
"use strict";const k=(()=>{if(1===n)async function n(){}return 1})();console.log(k);SyntaxError: Async functions can only be declared at the top level or inside a block.
Expected behavior
A valid program printing 1, as before #10201.
Additional context
Found with a differential fuzzer I run over the minifier's own test corpus.
Source: swc-project/swc