UglifyJS-old icon indicating copy to clipboard operation
UglifyJS-old copied to clipboard

Join assignment

Open thejh opened this issue 14 years ago • 2 comments

See #223 - basically, this is about joining assignment statements into expressions when appropriate:

a=1;f(2,5,1)
f(2,5,a=1)

thejh avatar Sep 09 '11 17:09 thejh

This one is buggy:

// problem 1: this.foo is dropped
this.foo = 0;
this.bar = 0;
this.baz = 0;
// problem 2: b -= b += 5?
if (a < 0) b += 5;
else b -= 5;

===> uglified:

this.baz = this.bar = 0, a < 0 && (b -= b += 5);

mishoo avatar Sep 11 '11 06:09 mishoo

Fixed one easy bug, only simple assignments (=) are treated this way now, but the problems with this.foo being dropped and if (a) b=2; else c=2 getting compiled to a&&(c=b=2) still remain. :(

thejh avatar Sep 11 '11 15:09 thejh