Repository: mishoo/UglifyJS (JavaScript)

Issue:
ufuzz failure
```js
// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

switch ((a || a || 3).toString()) {
  default:
    if (a) {
        a && (a[(c = c + 1) + (a && typeof a.undefined == "function" && --_calls_ >= 0 && a.undefined("undefined", (c = 1 + c, 
        a && (a.foo += (a && (a[--b + [ (c = 1 + c, ~("undefined" == "c" || 23..toString() !== false)) ][c = 1 + c, 
        ("function" >>> Infinity || 22 | false) !== (25 >>> 5) - ("b" >= -2)]] = (4 | 22, 
        false <= -4))) >> +(38..toString() < 3)))))] = (NaN << 23..toString() & "function" != Infinity) << (undefined ^ "b" && "bar" << 0));
    }

  case a >>>= a++ + {
        3: ++a,
        1.5: (c = c + 1) + [ --b + "b" ][a ^= --b]
    }[((~a ? ([ , 0 ].length === 2) in [ a && a.c, --b + (typeof b_1 !== "function") ] : "bar") || a || 3).toString()]:
    +((24..toString() === "function") <= (2 | "foo") != (23..toString() == true) >= (-5 == 2));
    break;

  case ~a:
    break;

  case (c = c + 1) + +(-0 < ([ , 0 ].length === 2) < ("a" != 1) != ([] && true) < ("bar" ^ "foo")) ? [] : (c = c + 1) + a:
    (c = c + 1) + (Infinity in [ a++ + {
        foo: 0 === 1 ? a : b,
        Infinity: 0 === 1 ? a : b
    }.c ]);
}

{
    var bar = function f0(undefined_1, b_1) {
        let bar = function Math_2() {
            {
                var expr7 = Math_2;
                for (var key7 in expr7) {
                    c = 1 + c;
                    var NaN_2 = expr7[key7];
                }
            }
            try {
                {
                    var brake10 = 5;
                    do {
                        var b_2;
                    } while ((c = c + 1) + b-- && --brake10 > 0);
                }
            } finally {
                {
                    return;
                    (c = c + 1) + ([ , (c = c + 1) + (NaN_2 && typeof NaN_2.null == "function" && --_calls_ >= 0 && NaN_2.null("", "foo")) ] || a || 3).toString();
                }
                {
                    var expr13 = {}.c;
                    L66047: for (var key13 in expr13) {
                        c = c + 1;
                    }
                }
            }
            for (var brake15 = 5; a++ + /[abc4]/.test((a++ + Math_2 || b || 5).toString()) && brake15 > 0; --brake15) {
                try {
                    {}
                } finally {
                    {
                        var brake18 = 5;
                        do {
                            var b_1;
                        } while (--b + ((c = c + 1) + -((this >> "foo" && 3 >>> 4) * (Math_2 && (Math_2[--b + [].Infinity] <<= ("foo" || 2, 
                        /[a2][^e]+$/ - 38..toString())))) ? --b + (b += a) : (c = c + 1) + (typeof b_1 != "special")) && --brake18 > 0);
                    }
                    {
                        return;
                        {
                            var expr22 = NaN_2 && NaN_2[c = 1 + c, b_2 && (b_2.a = ((c = c + 1, -1) | /[a2][^e]+$/ << this) * (true <= -0 <= (-3 & 4)))];
                            L66048: for (var key22 in expr22) {
                                if (c = 1 + c, (b_2 && (b_2[b--] += (undefined && "a") + (c = c + 1, [ , 0 ].length === 2))) != ([ , 0 ].length === 2) << {} >> ("foo" != 0)) {
                                    c = 1 + c, ("a" == this, "a" >= undefined) >> (3 - 2 >= ("object" && -4));
                                }
                            }
                        }
                        {
                            return a++ + a++;
                        }
                        a++ + (undefined in [ (c = 1 + c, (0 + -3) / (undefined / "foo") < ([] & "a") + (1 >= Infinity)), (c = 1 + c, 
                        (null - -5 | "c" === /[a2][^e]+$/) !== ("bar" >>> "object") / +undefined), (c = 1 + c, 
                        (b_2 = ([ , 0 ].length === 2) / -1) >>> (-4 & "") != -("c" ^ 22)), (c = 1 + c, Math_2 += ((c = c + 1, 
                        -3) && 23..toString() == 38..toString(), Math_2 && (Math_2[typeof b_1_2] += undefined + true > (25, 
                        "function")))) ]);
                    }
                }
            }
        };
        {
            for (var brake28 = 5; --b + --b && brake28 > 0; --brake28) {
                var b_1_2 = --b + /[abc4]/.test((a++ + /[abc4]/.test((--b + (b_1 && b_1.c) || b || 5).toString()) || b || 5).toString());
            }
            {
                var brake30 = 5;
                while ((c = c + 1) + ((undefined_1 && (undefined_1[c = 1 + c, -5 % "b" & /[a2][^e]+$/ * "a" | (Infinity && 3) < (5 === 4)] = -3 > 1)) <= (b_1 && (b_1.in |= ([ , 0 ].length === 2) << true)) ^ (c = c + 1, 
                3 >= Infinity)) && --brake30 > 0) {
                    {
                        var expr32 = --b + [].foo;
                        L66049: for (var key32 in expr32) {
                            c = 1 + c;
                            var Infinity_2 = expr32[key32];
                            c = c + 1;
                        }
                    }
                    for (var brake34 = 5; (c = c + 1) + (typeof f2 == "function" && --_calls_ >= 0 && f2()) && brake34 > 0; --brake34) {
                        var a_2 = ((c = 1 + c, a_2 && (a_2.var = ((22 | -0) & ("bar", Infinity)) + ("b" >> false) * (25 | -2))) || a || 3).toString(), NaN = {
                            0: (c = 1 + c, (this < undefined >= "c" + 25) * (1 > "object" <= -0 / [])),
                            NaN: (c = 1 + c, (0 ^ -2) * (0 % -4) ^ ([] ^ "") != (b_1_2 >>>= this || -3)),
                            0: (c = 1 + c, [] / -1 <= (2 > [ , 0 ][1]) < ((-2 || {}) !== 38..toString() * -0))
                        }.var;
                    }
                    if (new function() {
                        this.null = (undefined || -2) + (c = c + 1, -4);
                        c = 1 + c, (undefined || 2) >= -22 !== (-5 != 3 || [ , 0 ][1] <= ([ , 0 ].length === 2));
                        c = 1 + c, ((2 & "a") >= ("bar" === -2)) % (c = c + 1, -2 == "function");
                        c = 1 + c, Infinity_2 && (Infinity_2[a_2 && a_2.null] = 24..toString() & 22 & null !== "number"), 
                        "b" === "b" ^ (2 || this);
                    }()) {
                        for (var brake40 = 5; (c = c + 1) + --b && brake40 > 0; --brake40) {
                            var a;
                        }
                    } else {
                        var expr42 = typeof f1 == "function" && --_calls_ >= 0 && f1(-2, {}, 24..toString());
                        L66050: for (var key42 in expr42) {
                            L66051: {
                            }
                        }
                    }
                    {
                        var a_2_1 = function f1(undefined, Infinity_1, bar_2) {
                            c = 1 + c, (c = c + 1, true) % ({} < true) * ((undefined_1 && (undefined_1.Infinity = 23..toString() >> "number")) === (24..toString() && 3));
                            c = 1 + c, +3 - (5 != "c") !== ("b" / "a" && -1 | 23..toString());
                        }();
                    }
                }
            }
            try {
                {
                    var expr48 = undefined_1 <<= b_1;
                    L66052: for (var key48 in expr48) {
                        c = 1 + c;
                        var bar_2 = expr48[key48];
                        {
                            var expr49 = a++ + --b;
                            for (var key49 in expr49) {
                                c = 1 + c;
                                var bar_2 = expr49[key49];
                                {
                                    var brake50 = 5;
                                    while ((c = c + 1) + (bar_2 -= 1 !== undefined !== "foo" / -3) * (c = c + 1, null / -2) && --brake50 > 0) {
                                        var brake51 = 5;
                                        do {
                                            {
                                                var expr52 = (c = 1 + c, (-0 === "number" & ([ , 0 ].length === 2) << false) % (-4 / 5 - (false || [])));
                                                for (var key52 in expr52) {
                                                    c = 1 + c;
                                                    var b = expr52[key52];
                                                    c = 1 + c, (b_1_2 && (b_1_2.c = ~false | (undefined_1 && (undefined_1.b >>>= ("b", 
                                                    "b"))))) % (25 || 25 || 1 % "a");
                                                }
                                            }
                                        } while (typeof f1 == "function" && --_calls_ >= 0 && f1((c = 1 + c, -1 - 5 + 25 / "b" !== ("function" ^ NaN) % ("undefined" % 5)), (c = 1 + c, 
                                        ("a" == "object") % (22 & 23..toString()) % (1 != /[a2][^e]+$/, -0 !== 25))) && --brake51 > 0);
                                    }
                                }
                            }
                        }
                    }
                }
            } finally {
                switch (!b) {
                  case {} in [ --b + (typeof bar == "function" && --_calls_ >= 0 && bar()), a++ + (0 === 1 ? a : b), b + 1 - .1 - .1 - .1, --b + b++ ]:
                    {
                        var brake55 = 5;
                        do {
                            switch (c = 1 + c, ((-5, undefined) || /[a2][^e]+$/ >>> 0) % (({} || "foo") ^ ("a" || null))) {
                              case c = 1 + c, (Infinity != -0) % -22 !== ([ , 0 ].length === 2 & -2 && "" << ([ , 0 ].length === 2)):
                                ;
                                break;

                              case c = 1 + c, a_2_1 && (a_2_1.Infinity += (false ^ /[a2][^e]+$/) != ([] | 4) && ((a_2_1 = 3 % -1) && [ , 0 ][1] >>> NaN)):
                                ;
                                break;

                              case c = 1 + c, +((-4 >= "number") >>> 4 / /[a2][^e]+$/):
                                ;
                                break;

                              case c = 1 + c, (-4 >= "b") - 25 % "foo" < (true >= -4 ^ (25 || 2)):
                                ;
                                break;
                            }
                        } while (--b + (a_2_1 && a_2_1[c = 1 + c, ("b" / -0 ^ 24..toString() << "c") - (Infinity_2 += "function" === undefined) % (-1 - 23..toString())]) && --brake55 > 0);
                    }

                  case --b:
                    break;

                  case --b + (typeof f2 == "function" && --_calls_ >= 0 && f2()):
                    break;

                  case (c = c + 1) + (bar_2 && typeof bar_2.foo == "function" && --_calls_ >= 0 && bar_2.foo()):
                    switch (Infinity_2 && Infinity_2.NaN) {
                      case +a:
                        c = 1 + c, (/[a2][^e]+$/ > -5) - (this !== "function") >>> (false % -2 || {} != true);
                        break;

                      case (c = c + 1) + (b_1 && b_1.Infinity):
                        break;

                      case c = c + 1, ("object" >= 25) % ("bar" == /[a2][^e]+$/):
                        c = 1 + c, (([ , 0 ].length === 2) >>> -0 & 24..toString() << "a") >>> (1 << -1 ^ -4 - "");
                        break;

                      default:
                        c = 1 + c, (23..toString(), false) >= (a_2_1 && (a_2_1.c = ([ , 0 ].length === 2) < [])) == (3 === "undefined") << (b_1_2 = -4 / 23..toString());
                        c = 1 + c, (25 - 0 >> (c = c + 1, /[a2][^e]+$/)) + (("function", "function") << -Infinity);
                    }
                    {}
                    break;
                }
                {
                    return --b + (typeof f2 == "function" && --_calls_ >= 0 && f2((c = 1 + c, (-1 || 22) ^ [ , 0 ][1] * 38..toString() ^ (-1 ^ [ , 0 ].length === 2) >> ([ , 0 ].length === 2) / 38..toString())) || 6).toString()[[ (c = 1 + c, 
                    "" % undefined >= (-1 === 22) !== (4 != -3) > (-4 <= "number")), (c = 1 + c, (c = c + 1, 
                    5) - 38..toString() % "undefined" - ((bar_2 && (bar_2.c = NaN & NaN)) >>> ("number" != "undefined"))), (c = 1 + c, 
                    bar_2 = "object" <= "a" ^ true <= "c" | (c = c + 1, "number" > "")) ]];
                }
            }
        }
        switch (~b) {
          case (c = c + 1) + typeof (a++ + [ !function() {
                return --b + typeof Infinity;
                if (a++ + (typeof a_2_1 == "function" && --_calls_ >= 0 && a_2_1((c = 1 + c, a_2_1 = ((-2 | Infinity) & -5 == 22) / ((bar_2 += "function" % -5) | (22 && "b"))), (c = 1 + c, 
                (b_1_2 && (b_1_2.foo = 38..toString() <= false)) != ("bar" | 2) ^ (3 > -3) % ("", 
                4)), 2))) {
                    var expr67 = (c = 1 + c, (b_1 && (b_1[(c = c + 1) + a++] = ([ , 0 ][1] !== "a") >>> (3, 
                    -5))) % (("number" !== 0) >>> (([ , 0 ].length === 2) <= NaN)));
                    for (var key67 in expr67) {
                        c = 1 + c, (true / -2 || NaN * -2) == (4 || 0) + (22, -4);
                    }
                } else {
                }
                return typeof b_1 == "function" && --_calls_ >= 0 && b_1();
                {
                    return;
                    --a;
                }
            }(), a++ + b++, 5 ]):
            ;
            break;

          case a++ + (typeof bar_2 == "function" && --_calls_ >= 0 && bar_2((c = c + 1) + (typeof f2 == "function" && --_calls_ >= 0 && f2("bar")), 1 === 1 ? a : b)):
          case a++ + ("b" in {
                1.5: (c = c + 1) + (b_1_2 && b_1_2.undefined),
                b: (c = c + 1) + (Infinity_2 && Infinity_2[a++ + (~a ? b_1_2 && typeof b_1_2.Infinity == "function" && --_calls_ >= 0 && b_1_2.Infinity(a++ + (38..toString() in {
                    foo: (c = 1 + c, [] > 0 <= -2 >> NaN < (-0 >= -1 == -5 <= -0)),
                    length: (c = 1 + c, ((25 ^ undefined) == (-0, "")) - ((c = c + 1, 24..toString()) ^ null < null)),
                    NaN: (c = 1 + c, (b_1 && (b_1.NaN = "undefined" != -0) && [ , 0 ][1] >> -1) < (Infinity_2 += 38..toString() >> -0 < (0 == -3)))
                }), this, 3) : [ function() {
                }, (c = c + 1) + (b + 1 - .1 - .1 - .1) ][(c = c + 1) + typeof (c = 1 + c, undefined_1 += !({} <= "bar") == ([ , 0 ][1] % 3 == Infinity < -2)) ? (c = c + 1) + (1 === 1 ? a : b) : a++ + ((c = 1 + c, 
                (-4 < Infinity) >> (-5, "foo") >>> (Infinity !== 0) / ("object" !== true)) || a || 3).toString()])]),
                var: typeof (--b + (typeof b != "number")),
                set Infinity(undefined_1) {
                    {
                        var brake73 = 5;
                        do {
                            c = c + 1;
                        } while (--b + (Infinity_2 && Infinity_2.b) && --brake73 > 0);
                    }
                    this.foo /= (-2 - [] >> delete 23..toString(), -5 >>> "c" && Infinity < {}) >= (24..toString() % "object" != "" > -4, 
                    [ , 0 ][1] - true - (undefined != [ , 0 ][1])) <= ((2 || "number") === "b" + 5 | ("object" && 4) != ("function" === this) && (Infinity_2 && (Infinity_2.c = (bar_2 && (bar_2.a = "bar" <= -5)) ^ (undefined_1 && (undefined_1[c = 1 + c, 
                    (c = c + 1, "function" != undefined) == [ , 0 ][1] - 2 >= (38..toString() | [])] |= "b" % "undefined")))) <= (bar_2 && (bar_2.NaN += ("a" & 3) >>> (this, 
                    "undefined")))) || (((-0 && 24..toString()) < ("" | "function") == (bar_2 && (bar_2[typeof bar_2 == "function" && --_calls_ >= 0 && bar_2(25, "")] = (undefined_1 && (undefined_1[c = 1 + c, 
                    (1 && -3) * ([ , 0 ][1] > "undefined") === ("function", "foo") >> (undefined_1 && (undefined_1[c = 1 + c, 
                    undefined_1 ^= - -4 >> (22 == "bar") === (24..toString() == 25 !== NaN + -3)] = -0 & 23..toString()))] = NaN ^ /[a2][^e]+$/)) == 38..toString() - []))) > ([ , 0 ][1] % 1 % (null || 25) & ("" << [ , 0 ][1]) % (undefined_1 &= /[a2][^e]+$/ > 0))) % ((4 | 38..toString()) % (2 < -3) | (bar && (bar.Infinity = (this && 2) - (3 & this))) && [] / Infinity == -1 >> ([ , 0 ].length === 2) == ((3 || 4) & Infinity % -1));
                },
                "\t": (c = c + 1) + (1 === 1 ? a : b)
            }):
            (c = c + 1) + --b;
            if (a++ + {
                3: a++,
                NaN: (c = c + 1) + [ 4 ]
            }[delete (((undefined <= this) << (-2 !== ([ , 0 ].length === 2))) / (undefined_1 && (undefined_1[a++ + /[abc4]/.test(((c = 1 + c, 
            Infinity_2 += (bar_2 && (bar_2[typeof f3 == "function" && --_calls_ >= 0 && f3((c = 1 + c, 
            ([] ^ 23..toString()) - "function" % [ , 0 ][1] + ((a_2_1 && (a_2_1[c = 1 + c, ("b" | {}) >>> ("foo" != "b") >>> (+{} < null << 3)] = 1 & [])) ^ (false && "b"))), "undefined")] += {} * -1 && [ , 0 ][1] * {})) == (c = c + 1, 
            38..toString() - NaN)) || b || 5).toString())] ^= (a_2 = "b" >> 5) + ([ , 0 ][1] === "c"))))]) {
                var a_1 = (c = c + 1) + ((-1 < false) + (-5 ^ 24..toString()) >> (4 << false >= (2 ^ 22)));
            }
            break;

          case a++ + ((0 % undefined != (-2 ^ -3)) < (undefined_1 && (undefined_1.undefined += null * this > {} << "function"))):
            {
                var expr78 = ++a;
                for (var key78 in expr78) {
                    c = 1 + c;
                    var a = expr78[key78];
                    for (var brake79 = 5; (0 === 1 ? a : b) && brake79 > 0; --brake79) {
                        switch ((c = c + 1) + a++) {
                          case (c = c + 1) + b--:
                            ;
                            L66053: for (var brake82 = 5; typeof bar_2 == "function" && --_calls_ >= 0 && bar_2() && brake82 > 0; --brake82) {
                                L66054: for (var brake83 = 5; (c = 1 + c, (this === 1) << (c = c + 1, 3) < delete ([ , 0 ][1] >= /[a2][^e]+$/)) && brake83 > 0; --brake83) {
                                    c = 1 + c, (([ , 0 ].length === 2) >> "bar" | "foo" ^ 25) == (/[a2][^e]+$/ || 3) + (23..toString() <= "c");
                                }
                            }
                            break;

                          case --b + +function() {
                                {
                                    var expr85 = (c = 1 + c, ~((Infinity_2 && (Infinity_2[c = 1 + c, void ([ , 0 ][1] >>> null >>> (bar_2 += undefined && []))] = 22 || 23..toString())) - ("" >> 3)));
                                    for (b_1_2 in expr85) {
                                        c = 1 + c, (bar && (bar[c = 1 + c, (1 | "") >> (25 < null) >> (bar_2 *= (null & 38..toString()) + ("function" !== 24..toString()))] += "undefined" !== 3)) * -([ , 0 ].length === 2), 
                                        delete ({} >= "b");
                                    }
                                }
                            }():
                            if (a++ + b++) {
                            }
                            if (a++ + (typeof foo_1 === "string")) {
                                var NaN_1;
                            }
                            break;

                          case a--:
                            {
                                var brake92 = 5;
                                while ((c = 1 + c, [] * "foo" - (4 | 5) || (a_2 = (-4 && -5) < ("number" & null))) && --brake92 > 0) {
                                    c = 1 + c, (("object" || {}) >>> (b_1 && (b_1.c = "number" != ([ , 0 ].length === 2)))) * (Infinity - 2 === ([ , 0 ][1] | []));
                                }
                            }
                            {}
                            break;

                          case "a":
                            {
                                var expr95 = typeof undefined_1 == "function" && --_calls_ >= 0 && undefined_1();
                                L66055: for (var key95 in expr95) {
                                    c = 1 + c;
                                    var a_1 = expr95[key95];
                                    {
                                    }
                                }
                            }
                            ;
                            break;
                        }
                    }
                }
            }
            break;
        }
    }(2);
}

console.log(null, a, b, c, Infinity, NaN, undefined);
```
```js
// uglified code
// (beautified)
var E = 10, n = 100, f = 10, F = 0;

switch ("" + (n || n || 3)) {
  default:
    n && n && (n[(F += 1) + (n && "function" == typeof n.undefined && 0 <= --E && n.undefined("undefined", (F = 1 + F, 
    n && (n.foo += (n && (n[--f + [ -2 ][F = 1 + (1 + F), !0]] = !1)) >> 0))))] = 0);

  case n >>>= n++ + {
        3: ++n,
        1.5: (F += 1) + [ --f + "b" ][n ^= --f]
    }["" + ((~n ? (2 === [ , 0 ].length) in [ n && n.c, --f + ("function" != typeof b_1) ] : "bar") || n || 3)]:
  case ~n:
    break;

  case (F += 1) + +(-0 < (2 === [ , 0 ].length) < !0 != 0) ? [] : (F += 1) + n:
    F += 1, n++;
}

!function(n, f) {
    function e() {
        for (var n in S) {
            F = 1 + F;
        }
        try {
            for (var f = 5; (F += 1) + m-- && 0 < --f; ) {}
        } finally {
            return;
        }
        for (var t = 5; q++ + /[abc4]/.test("" + (q++ + e || m || 5)) && 0 < t; --t) {
            for (var a = 5; --m + ((F += 1) + -((this >> "foo" && 0) * (e && (e[--m + [].Infinity] <<= NaN))) ? --m + (m += q) : (F += 1) + !0) && 0 < --a; ) {}
            return;
        }
    }
    for (var t = 5; --m + --m && 0 < t; --t) {
        var a = --m + /[abc4]/.test("" + (q++ + /[abc4]/.test("" + (--m + f || m || 5)) || m || 5));
    }
    for (var o = 5; (F += 1) + ((n && (n[F = 1 + F, 0] = !1)) <= f ^ (F += 1, !1)) && 0 < --o; ) {
        var i, r = --m + [].foo;
        for (i in r) {
            F = 1 + F;
            var c = r[i];
            F += 1;
        }
        for (var s = 5; (F += 1) + ("function" == typeof f2 && 0 <= --E && f2()) && 0 < s; --s) {
            var u = (F = 1 + F, "" + (u && (u.var = 0) || q || 3)), v = {
                0: !1 * ("c25" <= (this < void 0)),
                NaN: -0 ^ 0 != (a >>>= this || -3),
                0: (F = 1 + (1 + (1 + F)), !1)
            }.var;
        }
        if (new function() {
            this.null = (F += 1, -6), F = 1 + ((F = 1 + (1 + F)) + 1), c && (c[u && u.null] = 0);
        }()) {
            for (var y = 5; (F += 1) + --m && 0 < y; --y) {}
        } else {
            "function" == typeof f1 && 0 <= --E && f1(-2, {}, "24");
        }
        var N = (F = 1 + F, F += 1, n && (n.Infinity = 23), void (F = 1 + F));
    }
    try {
        var h, l = n <<= f;
        for (h in l) {
            F = 1 + F;
            var b, d = l[h], p = q++ + --m;
            for (b in p) {
                F = 1 + F;
                for (var d = p[b], g = 5; (F += 1) + (d -= !0) * (F += 1, -0) && 0 < --g; ) {
                    var k = 5;
                    do {
                        var w, I = (F = 1 + F, (!1 & (2 === [ , 0 ].length) << !1) % -.8);
                        for (w in I) {
                            var m = I[w];
                            F = 1 + (F = 1 + F), a && (a.c = -1 | (n && (n.b >>>= "b")));
                        }
                    } while ("function" == typeof f1 && 0 <= --E && f1(NaN !== ("function" ^ v) % NaN, (F = 1 + (F = 1 + F), 
                    0)) && 0 < --k);
                }
            }
        }
    } finally {
        switch (!m) {
          case {} in [ --m + (0 <= --E && e()), q++ + m, m + 1 - .1 - .1 - .1, --m + m++ ]:
            var $ = 5;
            do {
                switch (NaN) {
                  case F = 1 + (F = 1 + F), 1 !== (2 === [ , 0 ].length & -2 && "" << (2 === [ , 0 ].length)):
                  case F = 1 + F, N && (N.Infinity += N = 0):
                  case F = 1 + F, 0:
                  case F = 1 + F, !1:
                }
            } while (--m + (N && N[F = 1 + F, 24 - (c += !1) % -24]) && 0 < --$);

          case --m:
          case --m + ("function" == typeof f2 && 0 <= --E && f2()):
            break;

          case (F += 1) + (d && "function" == typeof d.foo && 0 <= --E && d.foo()):
            switch (c && c.NaN) {
              case +q:
                F = 1 + F;
                break;

              case (F += 1) + f:
                break;

              case F += 1, NaN:
                F = 1 + F;
                break;

              default:
                F = 1 + F, N && (N.c = (2 === [ , 0 ].length) < []), a = -4 / "23", F = 1 + F, F += 1;
            }
        }
        return --m, "function" == typeof f2 && 0 <= --E && f2((F = 1 + F, -1 ^ (-1 ^ 2 === [ , 0 ].length) >> (2 === [ , 0 ].length) / "38")), 
        F = 1 + (F = 1 + F), F += 1, d && (d.c = v & v), F = 1 + F, d = 0 | (F += 1, !0);
    }
    switch (~m) {
      case (F += 1) + typeof (q++ + [ (--m, !1), q++ + m++, 5 ]):
        break;

      case q++ + ("function" == typeof d && 0 <= --E && d((F += 1) + ("function" == typeof f2 && 0 <= --E && f2("bar")), q)):
      case q++ + ("b" in {
            1.5: (F += 1) + (a && a.undefined),
            b: (F += 1) + (c && c[q++ + (~q ? a && "function" == typeof a.Infinity && 0 <= --E && a.Infinity(q++ + ("38" in {
                foo: !1 <= -2 >> v < !0,
                length: -24,
                NaN: (F = 1 + ((F = 1 + (1 + F)) + 1), f < (c += !1))
            }), this, 3) : [ function() {}, (F += 1) + (m + 1 - .1 - .1 - .1) ][(F += 1) + (F = 1 + F, 
            typeof (n += !1)) ? (F += 1) + q : q++ + (F = 1 + F, "" + (q || 3))])]),
            var: typeof (--m + ("number" != typeof m)),
            set Infinity(n) {
                for (var f = 5; F += 1, --m + (c && c.b) && 0 < --f; ) {}
                this.foo /= !0 <= (!1 | 4 != ("function" === this) && (c && (c.c = (d && (d.a = !1)) ^ (n && (n[F = 1 + F, 
                0 == (F += 1, !0)] |= NaN)))) <= (d && (d.NaN += 0))) || ((0 == (d && (d["function" == typeof d && 0 <= --E && d(25, "")] = 38 == (n && (n[F = 1 + F, 
                -0 == "foo" >> (n && (n[F = 1 + F, n ^= 4 === (!1 !== v + -3)] = 0))] = v ^ /[a2][^e]+$/))))) > (0 & 0 % (n &= !1))) % (NaN | (e.Infinity = (this && 2) - (3 & this)) && 0 == -1 >> (2 === [ , 0 ].length) == 0);
            },
            "\t": (F += 1) + q
        }):
        F += 1, --m, q++ + {
            3: q++,
            NaN: (F += 1) + [ 4 ]
        }[n && (n[q++ + /[abc4]/.test((F = 1 + F, "" + ((c += (d && (d["function" == typeof f3 && 0 <= --E && f3((F = 1 + F, 
        NaN + (!1 ^ (N && (N[F = 1 + F, 0] = 0)))), "undefined")] += NaN)) == (F += 1, "38" - v)) || m || 5)))] ^= (u = 0) + !1), 
        !0] && (F += 1);
        break;

      case q++ + (!0 < (n && (n.undefined += 0 < null * this))):
        var _, j = ++q;
        for (_ in j) {
            F = 1 + F;
            for (var q = j[_], x = 5; m && 0 < x; --x) {
                switch ((F += 1) + q++) {
                  case (F += 1) + m--:
                    for (var z = 5; "function" == typeof d && 0 <= --E && d() && 0 < z; --z) {
                        for (var A = 5; F = 1 + F, (1 === this) << (F += 1, 3) < !0 && 0 < A; --A) {
                            F = 1 + F;
                        }
                    }
                    break;

                  case --m + +function() {
                        for (a in F = 1 + F, ~+(c && (c[F = 1 + F, void (d += void 0)] = 22))) {
                            e[F = 1 + (1 + F), 1 >> (d *= 1)] += !0;
                        }
                    }():
                    q++, m++, q++;
                    break;

                  case q--:
                    for (var B = 5; F = 1 + F, u = !0, 0 < --B; ) {
                        F = 1 + F;
                    }
                    break;

                  case "a":
                    var C, D = "function" == typeof n && 0 <= --E && n();
                    for (C in D) {
                        F = 1 + F, D[C];
                    }
                }
            }
        }
    }
}(2), console.log(null, n, f, F, 1 / 0, NaN, void 0);
```
```
original result:
null 100 7 165 Infinity NaN undefined

uglified result:
evalmachine.<anonymous>:1
(function(){var E=10,n=100,f=10,F=0;switch(""+(n||n||3)){default:n&&n&&(n[(F+=1)+(n&&"function"==typeof n.undefined&&0<=--E&&n.undefined("undefined",(F=1+F,n&&(n.foo+=(n&&(n[--f+[-2][F=1+(1+F),!0]]=!1))>>0))))]=0);case n>>>=n+++{3:++n,1.5:(F+=1)+[--f+"b"][n^=--f]}[""+((~n?(2===[,0].length)in[n&&n.c,--f+("function"!=typeof b_1)]:"bar")||n||3)]:case~n:break;case(F+=1)+ +(-0<(2===[,0].length)<!0!=0)?[]:(F+=1)+n:F+=1,n++}!function(n,f){function e(){for(var n in S)F=1+F;try{for(var f=5;(F+=1)+m--&&0<--f;);}finally{return}for(var t=5;q+++/[abc4]/.test(""+(q+++e||m||5))&&0<t;--t){for(var a=5;--m+((F+=1)+-((this>>"foo"&&0)*(e&&(e[--m+[].Infinity]<<=NaN)))?--m+(m+=q):(F+=1)+!0)&&0<--a;);return}}for(var t=5;--m+--m&&0<t;--t)var a=--m+/[abc4]/.test(""+(q+++/[abc4]/.test(""+(--m+f||m||5))||m||5));for(var o=5;(F+=1)+((n&&(n[F=1+F,0]=!1))<=f^(F+=1,!1))&&0<--o;){var i,r=--m+[].foo;for(i in r){F=1+F;var c=r[i];F+=1}for(var s=5;(F+=1)+("function"==typeof f2&&0<=--E&&f2())&&0<s;--s)var u=(F=1+F,""+(

ReferenceError: S is not defined
    at e (evalmachine.<anonymous>:1:463)
    at evalmachine.<anonymous>:1:1701
    at evalmachine.<anonymous>:1:3993
    at evalmachine.<anonymous>:1:4038
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at Object.runInContext (vm.js:120:6)
    at Object.exports.run_code (D:\a\UglifyJS\UglifyJS\test\sandbox.js:65:12)
    at D:\a\UglifyJS\UglifyJS\test\ufuzz\index.js:1357:37
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (D:\a\UglifyJS\UglifyJS\test\ufuzz\index.js:1349:20)
```
```js
// reduced test case (output will differ)

// (beautified)
let bar = function Math_2() {
    var expr7 = Math_2;
    for (var key7 in expr7) {
        0();
        expr7;
    }
    Math_2 += 0;
};

bar();

switch (0) {
  case 0():
    switch (0) {
      case function() {
            0(bar);
        }:
      case 0:
        brake92;
    }
}
// output: TypeError: 0 is not a function
// minify: ReferenceError: b is not defined
// options: {
//   "compress": {
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "toplevel": true,
//   "validate": true
// }
```
```
minify(options):
{
  "compress": {
    "passes": 1000000,
    "unsafe": true
  },
  "toplevel": true
}

Suspicious compress options:
  collapse_vars
  dead_code
  functions
  passes
  pure_getters
  reduce_vars
  unused
  varify

Suspicious options:
  rename
  toplevel
```


Discussion:

Patch:
diff --git a/lib/compress.js b/lib/compress.js
index 0c49d49d78d..ab837f60da1 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1424,8 +1424,9 @@ merge(Compressor.prototype, {
                     if (!--replaced) abort = true;
                     if (is_lhs(node, multi_replacer.parent())) return node;
                     def.replaced++;
-                    value_def.replaced--;
-                    return rvalue.clone();
+                    var ref = rvalue.clone();
+                    value_def.references.push(ref);
+                    return ref;
                 }
                 // Skip (non-executed) functions and (leading) default case in switch statements
                 if (node instanceof AST_Default || node instanceof AST_Scope) return node;
@@ -5433,7 +5434,7 @@ merge(Compressor.prototype, {
                     vars.set(def.name.name, def);
                     ++vars_found;
                 });
-                var seq = node.to_assignments(compressor);
+                var seq = node.to_assignments();
                 var p = tt.parent();
                 if (p instanceof AST_ForIn && p.init === node) {
                     if (seq) return seq;
@@ -6716,21 +6717,19 @@ merge(Compressor.prototype, {
     AST_Let.DEFMETHOD("remove_initializers", remove_initializers);
     AST_Var.DEFMETHOD("remove_initializers", remove_initializers);
 
-    AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
-        var reduce_vars = compressor.option("reduce_vars");
-        var assignments = this.definitions.reduce(function(a, def) {
-            if (def.value) {
-                var name = make_node(AST_SymbolRef, def.name, def.name);
-                a.push(make_node(AST_Assign, def, {
+    AST_Definitions.DEFMETHOD("to_assignments", function() {
+        var assignments = this.definitions.reduce(function(a, defn) {
+            var def = defn.name.definition();
+            if (defn.value) {
+                var name = make_node(AST_SymbolRef, defn.name, defn.name);
+                a.push(make_node(AST_Assign, defn, {
                     operator : "=",
                     left     : name,
-                    right    : def.value
+                    right    : defn.value
                 }));
-                if (reduce_vars) name.definition().fixed = false;
+                def.references.push(name);
             }
-            def = def.name.definition();
             def.eliminated++;
-            def.replaced--;
             return a;
         }, []);
         if (assignments.length == 0) return null;


Test patch:
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 4ed0dc1bc1e..c2ab23f6601 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -5115,3 +5115,29 @@ issue_4233: {
     }
     expect_stdout: "number"
 }
+
+issue_4259: {
+    options = {
+        collapse_vars: true,
+        functions: true,
+        reduce_vars: true,
+        toplevel: true,
+        unused: true,
+    }
+    input: {
+        var a = function b() {
+            var c = b;
+            for (b in c);
+        };
+        a();
+        console.log(typeof a);
+    }
+    expect: {
+        function a() {
+            for (a in a);
+        }
+        a();
+        console.log(typeof a);
+    }
+    expect_stdout: "function"
+}
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index ea3703c1222..838b130a496 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -1999,7 +1999,7 @@ issue_1606: {
             var a, b;
             function g(){};
             b = 2;
-            x(b);
+            x(2);
         }
     }
 }