Repository: mishoo/UglifyJS (JavaScript)

Issue:
ufuzz failure
```js
// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

function f0(c_1) {
    function f1(let_2 = "", undefined_1, yield) {
        try {
            return --b + ++a;
        } catch (foo_2) {
            return;
            {
                var foo_2 = function f2(a_1, yield_2) {
                }();
            }
        } finally {
            {
                c = 1 + c, ((-3 != "function") < "" - "") << (~23..toString() && {} ^ "number");
                c = 1 + c, (yield += "number" >>> this & 3 <= 1) % (undefined_1 && (undefined_1[c = 1 + c, 
                ("" <= 25) - (c_1 /= {} ?? "b") & (-5 || "function") == ("" != undefined)] >>= "c" ?? 23..toString()) && (let_2 = 38..toString() !== /[a2][^e]+$/));
            }
            try {
                for (var brake9 = 5; (c = 1 + c, (yield && (yield.undefined += Number(0xdeadn << 16n | 0xbeefn) != {} == -5 >= null)) ^ (/[a2][^e]+$/ ^ 4 ^ -2 >>> 0)) && brake9 > 0; --brake9) {
                    c = 1 + c, ((undefined_1 = 0 === 38..toString()) && + -0) >= ((c = c + 1, 
                    "a") | "foo" < "b");
                }
            } catch (let_2) {
                c = 1 + c, c = c + 1, "number" >>> undefined ^ (-3 && this);
                c = 1 + c, undefined_1 && (undefined_1[typeof f4 == "function" && --_calls_ >= 0 && f4((c = 1 + c, 
                (let_2 && (let_2.next += (c = c + 1, null) && 38..toString() != "")) * (("number" & "function") + ("a" ^ []))), (c = 1 + c, 
                (3 || []) - ("bar" + (-42n).toString()) <= (3 >= false ^ 5 != this)), (c = 1 + c, 
                (yield = 23..toString() == {}) >> (undefined <= "foo") ^ (c = c + 1, 
                -3) % (4 <= /[a2][^e]+$/)))] = (!"number" ?? (yield && (yield[c = 1 + c, 
                ((-0 != -3) - (-0 <= false)) % (yield && (yield.undefined &&= void undefined && 1 != 2))] += false >> "object"))) >> (c = c + 1, 
                -0) / (false ^ 5));
            }
        }
        {
            var foo = function async_2(foo_1, b_2, a_1) {
                {
                    var brake14 = 5;
                    do {
                        c = 1 + c, c_1 && (c_1[typeof (typeof foo_1_1 === "string")] |= (-3 > /[a2][^e]+$/) * (true ^ "a") ^ Infinity * {} >= ~"foo");
                    } while ((c = 1 + c, c = c + 1, undefined_1 && (undefined_1.b = ({} <= 38..toString()) - (3 && "a"))) && --brake14 > 0);
                }
                {
                    var expr16 = (c = 1 + c, undefined_1 %= ("number" & "c") === Infinity >>> NaN ^ (-4 !== 3, 
                    -5 >= null));
                    L23732: for (var key16 in expr16) {
                        c = 1 + c;
                        let c_2 = expr16[key16];
                        c = 1 + c, (-4 | [] || a_1 && (a_1.get = /[a2][^e]+$/ | [])) === (-4 !== 38..toString() != {} << 22);
                    }
                }
            }(typeof f3 == "function" && --_calls_ >= 0 && f3());
        }
    }
    var b_1 = f1();
    function f3(b, undefined_1) {
        function f4() {
            {
            }
            c = 1 + c, (b_1 = +"function" >>> (-1 ^ NaN)) !== ("a" >> 22 | false < 38..toString());
        }
        var NaN = f4({});
        function f5(async) {
            function f6() {
            }
            var foo_2 = f6((c = 1 + c, 2 << 0 >= (([ , 0 ].length === 2) <= true) > /[a2][^e]+$/ % "number" - (b_1 /= -3 / "a")), (c = 1 + c, 
            ([ , 0 ][1] >> NaN !== undefined >>> -2) % (async && (async.next = -4 + [] - ("" >= -0)))), (c = 1 + c, 
            ~("function" / -3) << ([ , 0 ][1] % "a" == 1 / -4)));
            function f7(Infinity_2, arguments_2) {
            }
            var b = f7();
            function f8(b_2) {
            }
            var await = f8();
            function f9(b_1, b_2) {
            }
            var await_2 = f9(Infinity);
            function f10() {
            }
            var undefined_1_1 = f10(0, [ , 0 ][1]);
        }
        var await = f5("undefined", a++ + b--);
        function f11(b, bar) {
            function f12(b_1, [], c_1_1) {
            }
            var yield_1 = f12(0, "");
            function f13(NaN_2, foo_2, let_2) {
            }
            var a_2 = f13(3);
            function f14(await, c_1_2, async_1) {
            }
            var foo_1 = f14`\`
 
${c = 1 + c, (undefined_1 && (undefined_1["a" in {}] = (await && (await.done = NaN === 0)) / (-2 === ""))) - ("object" ^ [ , 0 ][1] || undefined && 5)}
${c = 1 + c, (23..toString() ^ 1) > ("foo" === NaN) == delete (Infinity % 0)}`;
        }
        var arguments = f11(typeof b_1, b_1 && b_1.done);
        function f15(arguments) {
            {
                var brake20 = 5;
                L23733: do {
                    c = 1 + c, arguments && (arguments[{} in {
                        a: (c = 1 + c, (0, false) + ("object" === -5) <= (-3 <= true == "object" >> "undefined")),
                        NaN: (c = 1 + c, ~0 * (24..toString() * 38..toString()) !== ("" ?? 4) >> (-4 <= undefined))
                    }] = "foo" - -1 | ("a", "undefined")) || (38..toString() ?? []) << (3 > "number");
                } while ((c = 1 + c, (3 >> 2 ^ (4 | "object")) === (b_1 && (b_1.a = NaN - "foo" + (-4 < [])))) && --brake20 > 0);
            }
            c = c + 1;
        }
        var b = f15();
    }
    function f16(...await) {
        {
            var brake28 = 5;
            while (a++ + b-- && --brake28 > 0) {
                var brake29 = 5;
                while ({}.done && --brake29 > 0) {
                    L23735: {
                        c = 1 + c, 1 <= 22 < -0 << "c" | (-3 != 25) < false << "undefined";
                        c = 1 + c, await && (await.a &= ("" ^ -4, "undefined" % 1) << ((false == [ , 0 ][1]) <= (c = c + 1, 
                        -5)));
                    }
                }
            }
        }
        try {
        } catch (b_1_2) {
            {
                var brake36 = 5;
                L23736: while (--b + (c = 1 + c, await += (22 | "number" | 38..toString() ^ 24..toString()) + (-0 % 3 >> (4 < NaN))) && --brake36 > 0) {
                    var brake37 = 5;
                    L23737: while ((c = 1 + c, (this | "b") % (1 <= this) % ((c_1 ^= -0 | -2) << (38..toString() <= undefined))) && --brake37 > 0) {
                        c = 1 + c, await && ([ await.NaN ] = [ (b_1_2 -= "foo" >> []) * (/[a2][^e]+$/ >>> -2) >> ("foo" * "function" >= "object" - Infinity) ]);
                    }
                }
            }
        } finally {
            {
                var brake39 = 5;
                do {
                    try {
                        c = 1 + c, 22 % 1 >> (await && (await[c = 1 + c, (NaN >>> "foo" || "function" | "object") >>> (c_1 = ({} ^ null) <= (22 | []))] = undefined <= 25)) != null % Number(0xdeadn << 16n | 0xbeefn) >= ([ , 0 ].length === 2) - Infinity;
                    } catch (async_1) {
                    }
                } while ((c = c + 1) + ((c = 1 + c, delete !"a" / ((5 || Infinity) ?? (await && (await.done >>= "c" << -4)))) || a || 3).toString() && --brake39 > 0);
            }
            {
                var brake42 = 5;
                while (typeof b_1 == "function" && --_calls_ >= 0 && b_1(1, -5, -1) && --brake42 > 0) {
                    for (var brake43 = 5; (c = 1 + c, ("function" * [] && 25 + "number") >>> ("undefined" !== [ , 0 ][1]) - 4 % 1) && brake43 > 0; --brake43) {
                        c = 1 + c, 38..toString() >> "object" >= (1 === 23..toString()) > (-1 != 0, 
                        4 ?? 22);
                    }
                }
            }
        }
    }
    var b = f16([ , 0 ].length === 2, /[abc4]/.test((a++ + ((c = c + 1) + (c_1 && typeof c_1.var == "function" && --_calls_ >= 0 && c_1.var("undefined", this, -0)) ? --b + void function() {
        c = 1 + c, (b_1 && (b_1[--b] ^= ("object" ^ this) + ("object" & 5))) >>> ("object" - -5 <= (5 & 24..toString()));
        return;
        {
            var brake25 = 5;
            L23734: do {
                c = 1 + c, ("object", [ , 0 ].length === 2, !0o644n << 22) ^ "" + null !== ("function" === ([ , 0 ].length === 2));
            } while ((c = 1 + c, ((c = c + 1, NaN) >= (b_1 && (b_1[c = 1 + c, void (-2 > "function" == "number" / 2)] += undefined ?? null))) << ((c = c + 1, 
            this) <= (c_1 && (c_1.b -= "bar" - 23..toString())))) && --brake25 > 0);
        }
        var bar_1 = (c = 1 + c, (NaN & {}) >>> (-3 ?? this) != -3 - undefined < (4 & "c"));
    }() : /[abc4]/g.exec((((c = c + 1) + (1 === 1 ? a : b) || 4).toString()[-a] || b || 5).toString())) || b || 5).toString()), "a");
    function f17(b, foo_1) {
        function f18(bar, arguments_1, b_2) {
            function f19() {
            }
            var c_1 = f19(this, -2);
            function f20(foo_1, bar) {
            }
            var b_2 = f20("c", null);
            function f21(b_2, a_1) {
            }
            var b = f21((c = 1 + c, false + "function" > (b_2 && (b_2.done += -2 ?? 1)) ?? (Infinity ^ -1) + !true), 1);
            function f22(b_2, Infinity_2, arguments) {
            }
            var foo_1 = f22("object");
            async function f23(async_2, b_2_2) {
            }
            var bar_1 = f23(23..toString(), 22, (c = 1 + c, (("number" & 1) === +"function") >> (1 % "number" == ("c" !== ""))));
        }
        var undefined_2 = f18();
        function f24(Infinity) {
            {
            }
            {
                var expr46 = (c = 1 + c, 24..toString() < 22 === (c = c + 1, "foo") == (-5 - [] === (b && (b[c = 1 + c, 
                (0 << "number" & (undefined ^ "undefined")) % ((22 | 24..toString()) !== ("function" === -1))] = 0 && -0))));
                for (b in expr46) {
                    c = 1 + c, -22 >= (c_1 && (c_1[c = 1 + c, foo_1 && (foo_1[--b + !((undefined > ([ , 0 ].length === 2)) >> ("function" >> true) === (undefined !== "undefined") * ("bar" || "number"))] /= 22 * -1 >> ({} < "function")) || 22 === "bar" & ("" ^ NaN)] = this !== NaN)) == (-3 !== ([ , 0 ].length === 2), 
                    2 ^ 3);
                }
            }
        }
        var a_2 = f24(24..toString(), 5);
    }
    var NaN_2 = f17();
    function f25({
        3: foo,
        "-2": b_1,
        then: async
    }, c_1_1, c_1) {
        c_1 && c_1[typeof f21 == "function" && --_calls_ >= 0 && f21((c = 1 + c, 
        (async = -5 >>> "a" ^ (-1 ?? "function")) % ((c_1_1 += ([ , 0 ].length === 2) >= 1) == {} < "")), ...[], undefined)];
        {
            for (var brake50 = 5; c_1 && typeof c_1.b == "function" && --_calls_ >= 0 && c_1.b((c = 1 + c, 
            (-0 ^ true) + (NaN || /[a2][^e]+$/) === (b_1 && (b_1[c = 1 + c, (b && (b.done += 25 / -5 ^ -1 < -1)) ?? "function" - 23..toString() !== ([], 
            undefined)] ??= "" ?? 23..toString())) / (-2 & "undefined"))) && brake50 > 0; --brake50) {
                var expr51 = (c = 1 + c, 23..toString() > this ^ (-3 || -4) && !(Number(0xdeadn << 16n | 0xbeefn) || [ , 0 ][1]));
                L23738: for (NaN_2 in expr51) {
                    c = 1 + c;
                    var b_2 = expr51[NaN_2];
                    c = 1 + c, ((b_2 && (b_2.set = NaN >= 38..toString())) ^ "foo" + "c") - (((-42n).toString() !== undefined) > 38..toString() << null);
                }
            }
            {
                return [ (c = 1 + c, (c_1 && (c_1[(c = 1 + c, (Infinity ^ Infinity) === (-0, 
                (-42n).toString()) !== 4 % "b" >= (NaN_2 && (NaN_2.set += "a" >= "number"))) ? (c = 1 + c, 
                ("function" << "" && true >> Number(0xdeadn << 16n | 0xbeefn)) | "a" + "bar" + (23..toString() >>> 23..toString())) : (c = 1 + c, 
                (-2 / -1 | null > /[a2][^e]+$/) >= ([ , 0 ][1] !== {} === ([ , 0 ].length === 2 ^ /[a2][^e]+$/)))] = (true >> -3) - (Infinity - ([ 3n ][0] > 2)))) & (!4 ^ "bar" <= /[a2][^e]+$/)), (c = 1 + c, 
                +((Infinity, true) ^ NaN !== 22)), (c = 1 + c, c_1_1 && (c_1_1[(c = c + 1) + (([ , 0 ].length === 2) in [])] += (-1 ?? 25) / (-0 ?? -1) || foo && (foo[c_1] ^= (c = c + 1, 
                []) == [] ** -1))), (c = 1 + c, (38..toString() * -2, null >>> "number") - ([] >= Infinity, 
                "object" % "bar")) ].b;
            }
        }
    }
    var b_1_1 = f25({});
}

var b_1 = f0();

console.log(null, a, b, c, Infinity, NaN, undefined);
```
```
// !!! uglify failed !!!
TypeError: inlined.body.push is not a function
    at AST_For.eval [as try_inline] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:19488:34)
    at inline_iife (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9704:49)
    at tighten_body (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:7971:21)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:12000:21)
    at AST_Function.eval [as optimize] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:19653:19)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6298:20)
    at AST_Function.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_Function.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2568:43)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
    at AST_Call.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_Call.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2535:49)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
    at AST_VarDef.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_VarDef.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2464:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:103:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2463:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2531:28)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
    at AST_Var.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_Var.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2464:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:103:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2463:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2545:21)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
    at AST_Defun.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_Defun.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2464:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:103:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2463:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2477:21)
    at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
    at AST_Toplevel.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
    at AST_Toplevel.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
    at Compressor.compress (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6335:21)
    at Object.minify (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:23529:57)
    at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2481:32
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2477:20)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47
```
```js
// reduced test case (output will differ)

// (beautified)
function f0() {
    (function async_2() {
        do {} while (1);
    })(_calls_ && f3());
    function f3() {
        function f15(arguments) {
            do {} while (1);
        }
        f15();
    }
}
// minify error: TypeError: inlined.body.push is not a function
//     at AST_For.eval [as try_inline] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:19488:34)
//     at inline_iife (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9696:49)
//     at tighten_body (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:7971:21)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:11972:21)
//     at AST_Defun.eval [as optimize] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:19653:19)
//     at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6298:20)
//     at AST_Defun.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
//     at AST_Defun.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2464:25)
//     at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:103:23)
//     at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2463:16)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2477:21)
//     at Compressor.eval [as before] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6293:5)
//     at AST_Toplevel.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2646:31)
//     at AST_Toplevel.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:504:34)
//     at Compressor.compress (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:6335:21)
//     at Object.minify (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:23529:57)
//     at test_minify (/Users/runner/work/UglifyJS/UglifyJS/test/reduce.js:780:22)
//     at reduce_test (/Users/runner/work/UglifyJS/UglifyJS/test/reduce.js:610:16)
//     at log (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2230:23)
//     at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2578:80
//     at Array.forEach (<anonymous>)
//     at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:2477:20)
//     at Module._compile (node:internal/modules/cjs/loader:1097:14)
//     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
//     at Module.load (node:internal/modules/cjs/loader:975:32)
//     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
//     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
//     at node:internal/main/run_main_module:17:47
// options: {
//   "compress": {
//     "passes": 1000000,
//     "sequences": 1000000,
//     "unsafe": true,
//     "unsafe_Function": true,
//     "unsafe_math": true,
//     "unsafe_proto": true,
//     "unsafe_regexp": true
//   },
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
```
```
minify(options):
{
  "compress": {
    "passes": 1000000,
    "sequences": 1000000,
    "unsafe": true,
    "unsafe_Function": true,
    "unsafe_math": true,
    "unsafe_proto": true,
    "unsafe_regexp": true
  },
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  evaluate
  inline
  loops
  passes
  reduce_vars
  sequences
  unsafe
  unused
```


Discussion:

Patch:
diff --git a/lib/compress.js b/lib/compress.js
index 6bab55792a6..91ce765277f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -13393,8 +13393,11 @@ Compressor.prototype.compress = function(node) {
                 inlined = inlined.try_inline(compressor, scope, true, in_loop);
                 if (inlined) {
                     this.init = null;
-                    inlined.body.push(this);
-                    return inlined;
+                    if (inlined instanceof AST_BlockStatement) {
+                        inlined.body.push(this);
+                        return inlined;
+                    }
+                    return make_node(AST_BlockStatement, inlined, { body: [ inlined, this ] });
                 }
             }
             return body && this;


Test patch:
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 3cbb2a3c128..a3628ba84c9 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -8207,3 +8207,24 @@ issue_5332_2: {
     }
     expect_stdout: "NaN"
 }
+
+issue_5366: {
+    options = {
+        inline: true,
+    }
+    input: {
+        for (console.log("foo") || function() {
+            while (console.log("bar"));
+        }(); console.log("baz") ;);
+    }
+    expect: {
+        if (!console.log("foo"))
+            while (console.log("bar"));
+        for (;console.log("baz"););
+    }
+    expect_stdout: [
+        "foo",
+        "bar",
+        "baz",
+    ]
+}