mishoo / UglifyJS

JavaScript parser / mangler / compressor / beautifier toolkit

Home Page:http://lisperator.net/uglifyjs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ufuzz failure

alexlamsl opened this issue · comments

// original code
// (beautified)
var _calls_ = 10, a = 100, b = 10, c = 0;

function f0(b_1) {
    class C0 {
        [+b] = [ , 0 ].length === 2;
    }
    a++;
    (c = c + 1) + /[abc4]/g.exec((--b + (typeof b_1 == "function" && --_calls_ >= 0 && b_1()) || b || 5).toString());
    {
        return --_calls_ >= 0 && new C0("b", {
            "": typeof f0 == "function" && --_calls_ >= 0 && f0("foo"),
            NaN: (c = c + 1) + --b,
            then: (c = c + 1) + b_1,
            b: --b + ++b
        });
    }
}

var c = f0("", 5, undefined);

console.log(null, a, b, c, Infinity, NaN, undefined);
// uglified code
// (beautified)
var n, o = 100, t = n = 10, f = 0, f = function f0(b_1) {
    return o++, f += 1, (--t + ("function" == typeof b_1 && 0 <= --n && b_1()) || t || 5).toString(), 
    0 <= --n && new class C0 {
        [+t] = 2 === [ , 0 ].length;
    }("b", {
        "": 0 <= --n && f0("foo"),
        NaN: (f += 1) + --t,
        then: (f += 1) + b_1,
        b: --t + ++t
    });
}("");

console.log(null, o, t, f, Infinity, NaN, void 0);
original result:
null 106 -1 { '10': true } Infinity NaN undefined

uglified result:
null 106 -1 { '9': true } Infinity NaN undefined
// reduced test case (output will differ)

// (beautified)
var b;

function f0() {
    class C0 {
        [b] = 0;
    }
    --b;
    return new C0();
}

var c = f0();

console.log(c);
// output: { undefined: 0 }
// 
// minify: { NaN: 0 }
// 
// options: {
//   "compress": {
//     "hoist_vars": true,
//     "keep_infinity": true,
//     "passes": 1000000,
//     "unsafe": true
//   },
//   "keep_fargs": true,
//   "keep_fnames": true,
//   "module": false,
//   "toplevel": true,
//   "output": {
//     "v8": true
//   },
//   "validate": true
// }
minify(options):
{
  "compress": {
    "hoist_vars": true,
    "keep_infinity": true,
    "passes": 1000000,
    "unsafe": true
  },
  "keep_fargs": true,
  "keep_fnames": true,
  "module": false,
  "toplevel": true,
  "output": {
    "v8": true
  }
}

Suspicious compress options:
  passes
  reduce_vars
  unused