uglifier
uglifier copied to clipboard
Incorrect JS with with multiple passes
The defaults in README indicate that the compress passes is set to 1 by default, while the code has a different value.
https://github.com/lautis/uglifier/blob/master/lib/uglifier.rb#L83
This potentially an issue with UglifyJS, I have a problem where using multiple pass option tends to insert a trailing comma in for loop as below (perhaps due to incorrect loop optimization ?)
for(i=b.K,K-=i.col1.x*k+i.col2.x*z,W-=i.col1.y*k+i.col2.y*z,;;)
Source
for (;;) {
tMat = c.normalMass;
var xX = -(tMat.col1.x * bX + tMat.col2.x * bY);
var xY = -(tMat.col1.y * bX + tMat.col2.y * bY);
Thanks for reporting. That wasn't intentional, I'll fix the default.
Fixed in https://github.com/lautis/uglifier/commit/50e8620daf75e5913a1f2336b5b274c4d07517ef, released as 3.1.3.
That was quick, appreciate it :+1:
@deepfryed could you post a more complete example? When I try to reproduce the example, for loop seems to be left as-is.
Ran into this when precompiling Box2d at work
https://github.com/babyzone2004/tank/blob/master/box2d/src/Box2dweb.js
Thanks. Indeed a bug in UglifyJS. The same reproduces with curl https://raw.githubusercontent.com/babyzone2004/tank/master/box2d/src/Box2dweb.js | uglifyjs -c passes=2 -m > box2dweb.min.js
. Running UglifyJS twice does not lead to the corruption, though.