it's not safe to assume that property access is side-effect-free
(getters/setters + various browser bugs will trigger side effects; also, an exception is thrown when the expression is undefined)
This commit is contained in:
@@ -732,12 +732,15 @@ function Compressor(options, false_by_default) {
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
def(AST_Dot, function(){
|
// def(AST_Dot, function(){
|
||||||
return this.expression.has_side_effects();
|
// return this.expression.has_side_effects();
|
||||||
});
|
// });
|
||||||
def(AST_Sub, function(){
|
// def(AST_Sub, function(){
|
||||||
return this.expression.has_side_effects()
|
// return this.expression.has_side_effects()
|
||||||
|| this.property.has_side_effects();
|
// || this.property.has_side_effects();
|
||||||
|
// });
|
||||||
|
def(AST_PropAccess, function(){
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
def(AST_Seq, function(){
|
def(AST_Seq, function(){
|
||||||
return this.car.has_side_effects()
|
return this.car.has_side_effects()
|
||||||
@@ -1405,9 +1408,9 @@ function Compressor(options, false_by_default) {
|
|||||||
|
|
||||||
AST_Seq.DEFMETHOD("optimize", function(compressor){
|
AST_Seq.DEFMETHOD("optimize", function(compressor){
|
||||||
var self = this;
|
var self = this;
|
||||||
if (self.cdr instanceof AST_Seq)
|
|
||||||
self.cdr = self.cdr.optimize(compressor);
|
|
||||||
if (compressor.option("cascade")) {
|
if (compressor.option("cascade")) {
|
||||||
|
if (self.cdr instanceof AST_Seq)
|
||||||
|
self.cdr = self.cdr.optimize(compressor);
|
||||||
if (self.car instanceof AST_Assign
|
if (self.car instanceof AST_Assign
|
||||||
&& !self.car.left.has_side_effects()
|
&& !self.car.left.has_side_effects()
|
||||||
&& self.car.left.equivalent_to(self.cdr)) {
|
&& self.car.left.equivalent_to(self.cdr)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user