Repository: mishoo/UglifyJS (JavaScript)

Issue:
ufuzz failure
```js
// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

switch ({
    c: --b + [ (c = c + 1) + (typeof f1 == "function" && --_calls_ >= 0 && f1("function", ++a, "undefined")), (c = c + 1) + (typeof a === "symbol") ],
    a: {
        length: a++ + +(a && (a[c = 1 + c, (a = 2 ^ -2 | (NaN || "number")) / (undefined / 1 ^ -5 + {})] = -4 === "foo") && "" <= -5, 
        ([ , 0 ][1] != 1) >= (22 ^ 22))
    }.foo,
    [--b + (this in [])]: [ 1 === 1 ? a : b, (c = c + 1) + (0 === 1 ? a : b), a++ + (a && typeof a.b == "function" && --_calls_ >= 0 && a.b()) ][a++ + (typeof a == "function" && --_calls_ >= 0 && a(0 === 1 ? a : b, undefined))] ? --b + !(-0 != 3 ^ 24..toString() * -4 && "function" >= {} !== - -1) : --b + (a && a.a),
    3: typeof a == "function" && --_calls_ >= 0 && a(),
    var: typeof a == "function" && --_calls_ >= 0 && a(false, 5, "b")
}.c) {
  case (c = c + 1) + b--:
    break;

  default:
    {
        var brake2 = 5;
        while (typeof a == "undefined" && --brake2 > 0) {
            var brake3 = 5;
            while (a++ + (--b + /[abc4]/g.exec(((a && (a[a && a.null] = - -5 != "a" / 4)) - ("foo" >> 2 === (-2 === 38..toString())) || b || 5).toString()) || a || 3).toString() && --brake3 > 0) {
                var brake4 = 5;
                do {
                    if (--b + function await_1() {
                        var c_2 = (c = c + 1) + ~("c" % /[a2][^e]+$/ && (await_1 && (await_1.null = 3 || 0)));
                        if (b + 1 - .1 - .1 - .1) {
                            L64388: for (var brake8 = 5; (c = 1 + c, ((23..toString() !== "object") >> (-3 >>> "foo")) - ((c_2 && (c_2.undefined |= ([ , 0 ].length === 2) - false)) & 0 === "a")) && brake8 > 0; --brake8) {
                                var brake9 = 5;
                                L64389: do {
                                    c = 1 + c, null / NaN & (-3 | /[a2][^e]+$/) ^ -0 * "function" >= 22 % "number";
                                } while ((c = 1 + c, (c_2 && (c_2.b >>= Infinity >= 4)) + ("number" >>> 25) > ((await_1 += 1 || 25) > (0 >= -2))) && --brake9 > 0);
                            }
                        }
                        return 0 === 1 ? a : b;
                        c = c + 1;
                    }) {
                        c = c + 1;
                    } else {
                        a--;
                    }
                } while ((c = c + 1) + a && --brake4 > 0);
            }
        }
    }
    --b + b++;

  case --b + [].NaN:
    break;

  case a && a[(c = c + 1) + (1 === 1 ? a : b)]:
    for (var brake16 = 5; typeof a == "function" && --_calls_ >= 0 && a(...[ /[abc4]/.test(((1 === 1 ? a : b) || b || 5).toString()) ], "", (([ ...[ {
        a_1: a_1
    } ] ] = -5, ...foo_1) => a++ + (a_1 && a_1.in))([ {
        [delete a]: a++ + (a ^= /[abc4]/g.exec((--b + a || b || 5).toString()))
    }, typeof a == "function" && --_calls_ >= 0 && a(), /[a2][^e]+$/  in [ ((c = 1 + c, 
    (a && (a.b += ("foo" | 4) ^ "number" / ([ , 0 ].length === 2))) >> ([ , 0 ][1] - ([ , 0 ].length === 2)) * (-1 & -5)) || a || 3).toString(), (c = c + 1) + ((c = 1 + c, 
    (a && (a.c += (a >>= [ , 0 ].length === 2 != "bar") > 0 - [ , 0 ][1])) ^ -2 << -2 >>> -1 + true) || 4).toString()[c = 1 + c, 
    (NaN || -1) % (0 >= "foo") > false * "function" - delete {}], a++ + b++ ] ? (c = c + 1) + ~(-"" != (24..toString() ^ Infinity) == ((a = 5 * "bar") ^ null == {})) : (c = c + 1) + (function await_2() {} || 6).toString()[typeof ((c = c + 1) + --b)] ])) && brake16 > 0; --brake16) {
        var NaN_1;
    }
    var foo_1 = a++ + {
        0: a++ + ("foo" + 3 != 23..toString() - "bar") * (22 == "function" !== "foo" >= "a"),
        in: --b + ((b = a) || a || 3).toString()
    }, bar_2 = void function() {
        if ((c = c + 1) + (--b + ~b || 8).toString()[b *= a]) {
            var b = function f0() {
                L64390: for (var brake21 = 5; NaN_1 && NaN_1[c = 1 + c, (38..toString() != "function" !== -3 << 38..toString()) >>> -2 * /[a2][^e]+$/ - (null ^ 5)] && brake21 > 0; --brake21) {
                    var brake22 = 5;
                    do {
                        c = 1 + c, ("c" == 23..toString() && "" > 1) >= (22 & -1) >>> ("c" >> "function");
                    } while ((c = 1 + c, ("b" & 4 || bar_2 && (bar_2.foo = "a" ^ 5)) * (NaN + 1 > 2 % "c")) && --brake22 > 0);
                }
                try {
                    {
                        return c = 1 + c, (3 != 24..toString() ^ "foo" & [ , 0 ][1]) + (-4 || {}) * (-5 << "a");
                    }
                } catch (foo) {
                    c = 1 + c, foo = (25 & [ , 0 ][1]) == -4 * [ , 0 ][1] ^ (NaN_1 = (/[a2][^e]+$/ ^ [ , 0 ].length === 2) << ([], 
                    /[a2][^e]+$/));
                    c = 1 + c, (c = c + 1, 2 | "") | ([ , 0 ].length === 2) << ([ , 0 ].length === 2) < ("" >= []);
                } finally {
                    c = 1 + c, ("c" >> []) % ("object" & [ , 0 ][1]) == (-4 && "undefined" && (c = c + 1, 
                    null));
                    c = 1 + c, (foo_1 && (foo_1[c = 1 + c, ("" & [ , 0 ].length === 2 || bar_2 && ([ bar_2.a ] = [ 1 / -5 ])) | (foo_1 && (foo_1[c = 1 + c, 
                    !("undefined" % "c") - (25 - 22 >> ("number" == NaN))] >>>= -5 || undefined)) !== "number" + 23..toString()] = [ , 0 ][1] & NaN)) - (22 & 5) >> (~"object" != (bar_2 = "undefined" != 2));
                }
            }("b", 38..toString());
        }
    }();
    break;
}

{
    var brake30 = 5;
    L64391: do {
        /[abc4]/g.exec((~b || b || 5).toString());
    } while ((typeof Infinity_1 !== "object" ? 0 === 1 ? a : b : --b + (2 in {
        undefined: --b + (--b + (NaN_1 && typeof NaN_1.undefined == "function" && --_calls_ >= 0 && NaN_1.undefined(1, 38..toString(), --b + (a++ + delete b ? --b + (bar_2 && bar_2[b *= a]) : a++ + b--))) ? 23..toString() in {
            in: [ foo_1 && typeof foo_1.null == "function" && --_calls_ >= 0 && foo_1.null((c = 1 + c, 
            !(NaN_1 += -1 !== "foo") > ("b" ^ this) << (Infinity != "c")), (c = 1 + c, (1 * "a" ^ -0 != undefined) & (-4 & {}) !== -0 >= 4)) ].length
        } : --b + (a++ + -a || a || 3).toString())
    })) && --brake30 > 0);
}

console.log(null, a, b, c, Infinity, NaN, undefined);
```
```
// !!! uglify failed !!!
TypeError: Cannot read property '_eval' of null
    at AST_Sub.eval [as _eval] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9147:31)
    at AST_Dot.eval [as _eval] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9147:31)
    at AST_Dot.eval [as evaluate] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:8829:28)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:14707:36)
    at AST_SymbolRef.eval [as optimize] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:15764:19)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5133:24)
    at AST_SymbolRef.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_SymbolRef.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2037:31)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Binary.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Binary.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2038:33)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Binary.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Binary.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at transform_arrow (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2006:37)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Arrow.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Arrow.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2014:43)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Call.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Call.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1919:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:120:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1918:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2015:21)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Call.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Call.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2038:33)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Binary.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Binary.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2037:31)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Binary.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Binary.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1944:61)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_For.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_For.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1919:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:120:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1918:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1974:21)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Case.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Case.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1919:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:120:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1918:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1970:21)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Switch.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Switch.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1919:25)
    at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:120:23)
    at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1918:16)
    at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1932:21)
    at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
    at AST_Toplevel.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
    at AST_Toplevel.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
    at Compressor.compress (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5087:25)
    at Object.minify (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:18702:57)
    at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:1877:32
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:1873:20)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47
```
```js
// reduced test case (output will differ)

// (beautified)
(([ ...[ {
    a_1: a_1
} ] ], ...foo_1) => a_1)();
// minify error: TypeError: Cannot read property '_eval' of null
//     at AST_Sub.eval [as _eval] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9147:31)
//     at AST_Dot.eval [as _eval] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:9147:31)
//     at AST_Dot.eval [as evaluate] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:8829:28)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:14707:36)
//     at AST_SymbolRef.eval [as optimize] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:15764:19)
//     at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5133:24)
//     at AST_SymbolRef.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
//     at AST_SymbolRef.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
//     at transform_arrow (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2006:37)
//     at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
//     at AST_Arrow.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
//     at AST_Arrow.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2014:43)
//     at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
//     at AST_Call.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
//     at AST_Call.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1929:31)
//     at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
//     at AST_SimpleStatement.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
//     at AST_SimpleStatement.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1919:25)
//     at List (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:120:23)
//     at do_list (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1918:16)
//     at eval (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:1932:21)
//     at Compressor.before (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5128:9)
//     at AST_Toplevel.eval [as transform] (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:2071:31)
//     at AST_Toplevel.ctor.transform (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:434:34)
//     at Compressor.compress (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:5087:25)
//     at Object.minify (eval at <anonymous> (/Users/runner/work/UglifyJS/UglifyJS/tools/node.js:1:1), <anonymous>:18702:57)
//     at test_minify (/Users/runner/work/UglifyJS/UglifyJS/test/reduce.js:752:22)
//     at reduce_test (/Users/runner/work/UglifyJS/UglifyJS/test/reduce.js:586:20)
//     at log (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:1720:23)
//     at /Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:1916:80
//     at Array.forEach (<anonymous>)
//     at Object.<anonymous> (/Users/runner/work/UglifyJS/UglifyJS/test/ufuzz/index.js:1873:20)
//     at Module._compile (node:internal/modules/cjs/loader:1108:14)
//     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
//     at Module.load (node:internal/modules/cjs/loader:973:32)
//     at Function.Module._load (node:internal/modules/cjs/loader:813:14)
//     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
//     at node:internal/main/run_main_module:17:47
// options: {
//   "compress": {
//     "hoist_vars": true,
//     "keep_infinity": true,
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "keep_fnames": true,
//   "toplevel": true,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
```
```
minify(options):
{
  "compress": {
    "hoist_vars": true,
    "keep_infinity": true,
    "passes": 1000000,
    "unsafe": true
  },
  "keep_fnames": true,
  "toplevel": true,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  evaluate
  reduce_vars
  rests
  unsafe
```


Discussion:

Patch:
diff --git a/lib/compress.js b/lib/compress.js
index 6bbae0ffead..d5334a95d28 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -620,7 +620,7 @@ merge(Compressor.prototype, {
                     var save = fixed;
                     if (save) fixed = function() {
                         var value = save();
-                        return is_undefined(value) ? make_sequence(node, [ value, node.value ]) : node.name;
+                        return is_undefined(value) ? make_sequence(node, [ value, node.value ]) : node;
                     };
                     node.name.walk(scanner);
                     fixed = save;
@@ -646,7 +646,7 @@ merge(Compressor.prototype, {
                             var value = save();
                             return value instanceof AST_Array ? make_node(AST_Array, node, {
                                 elements: value.elements.slice(node.elements.length),
-                            }) : node.rest;
+                            }) : node;
                         };
                         node.rest.walk(scanner);
                     }


Test patch:
diff --git a/test/compress/rests.js b/test/compress/rests.js
index 6bc5b756b5f..017f871bc91 100644
--- a/test/compress/rests.js
+++ b/test/compress/rests.js
@@ -646,3 +646,20 @@ issue_4544_2: {
     expect_stdout: "PASS"
     node_version: ">=6"
 }
+
+issue_4562: {
+    options = {
+        evaluate: true,
+        reduce_vars: true,
+        rests: true,
+        unsafe: true,
+    }
+    input: {
+        console.log((([ ...[ a ] ]) => a)("foo"));
+    }
+    expect: {
+        console.log((([ a ]) => a)("foo"));
+    }
+    expect_stdout: "f"
+    node_version: ">=6"
+}
diff --git a/test/input/reduce/destructured_catch.reduced.js b/test/input/reduce/destructured_catch.reduced.js
index c7a6736d93b..1979b99db7c 100644
--- a/test/input/reduce/destructured_catch.reduced.js
+++ b/test/input/reduce/destructured_catch.reduced.js
@@ -1,14 +1,12 @@
 // (beautified)
 try {
     1 in 0;
-} catch ({
-    message: message
-}) {
+} catch (message) {
     console.log(message);
 }
-// output: Cannot use 'in' operator to search for '1' in 0
+// output: TypeError: Cannot use 'in' operator to search for '1' in 0
 // 
-// minify: Cannot use 'in' operator to search for '0' in 0
+// minify: TypeError: Cannot use 'in' operator to search for '0' in 0
 // 
 // options: {
 //   "mangle": false
diff --git a/test/reduce.js b/test/reduce.js
index 3f24b7b47a8..c478da5fbcc 100644
--- a/test/reduce.js
+++ b/test/reduce.js
@@ -104,15 +104,14 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
 
             // quick ignores
             if (node instanceof U.AST_Accessor) return;
-            if (node instanceof U.AST_Destructured) return;
             if (node instanceof U.AST_Directive) return;
             if (!in_list && node instanceof U.AST_EmptyStatement) return;
             if (node instanceof U.AST_Label) return;
             if (node instanceof U.AST_LabelRef) return;
-            if (!in_list && node instanceof U.AST_SymbolDeclaration) return;
             if (node instanceof U.AST_Toplevel) return;
             var parent = tt.parent();
             if (node instanceof U.AST_SymbolFunarg && parent instanceof U.AST_Accessor) return;
+            if (!in_list && parent.rest !== node && node instanceof U.AST_SymbolDeclaration) return;
 
             // ensure that the _permute prop is a number.
             // can not use `node.start._permute |= 0;` as it will erase fractional part.
@@ -124,6 +123,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
 
             // ignore lvalues
             if (parent instanceof U.AST_Assign && parent.left === node) return;
+            if (parent instanceof U.AST_DefaultValue && parent.name === node) return;
             if (parent instanceof U.AST_DestructuredKeyVal && parent.value === node) return;
             if (parent instanceof U.AST_Unary && parent.expression === node) switch (parent.operator) {
               case "++":
@@ -229,6 +229,23 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
                 CHANGED = true;
                 return node.name;
             }
+            else if (node instanceof U.AST_DestructuredArray) {
+                var expr = node.elements[0];
+                if (expr && !(expr instanceof U.AST_Hole)) {
+                    node.start._permute++;
+                    CHANGED = true;
+                    return expr;
+                }
+            }
+            else if (node instanceof U.AST_DestructuredObject) {
+                // first property's value
+                var expr = node.properties[0];
+                if (expr) {
+                    node.start._permute++;
+                    CHANGED = true;
+                    return expr.value;
+                }
+            }
             else if (node instanceof U.AST_Defun) {
                 switch (((node.start._permute += step) * steps | 0) % 2) {
                   case 0:
@@ -443,15 +460,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
                     CHANGED = true;
                     return List.skip;
                 }
-
-                // skip element/property from (destructured) array/object
-                if (parent instanceof U.AST_Array
-                    || parent instanceof U.AST_Destructured
-                    || parent instanceof U.AST_Object) {
-                    node.start._permute++;
-                    CHANGED = true;
-                    return List.skip;
-                }
             } else if (parent.rest === node) {
                 node.start._permute++;
                 CHANGED = true;