retain (1,eval) as is when it's the expression of an AST_Call
otherwise we change the meaning of eval from global to lexical.
This commit is contained in:
@@ -1549,8 +1549,19 @@ merge(Compressor.prototype, {
|
|||||||
OPT(AST_Seq, function(self, compressor){
|
OPT(AST_Seq, function(self, compressor){
|
||||||
if (!compressor.option("side_effects"))
|
if (!compressor.option("side_effects"))
|
||||||
return self;
|
return self;
|
||||||
if (!self.car.has_side_effects())
|
if (!self.car.has_side_effects()) {
|
||||||
return self.cdr;
|
// we shouldn't compress (1,eval)(something) to
|
||||||
|
// eval(something) because that changes the meaning of
|
||||||
|
// eval (becomes lexical instead of global).
|
||||||
|
var p;
|
||||||
|
if (!(self.cdr instanceof AST_SymbolRef
|
||||||
|
&& self.cdr.name == "eval"
|
||||||
|
&& self.cdr.undeclared()
|
||||||
|
&& (p = compressor.parent()) instanceof AST_Call
|
||||||
|
&& p.expression === self)) {
|
||||||
|
return self.cdr;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (compressor.option("cascade")) {
|
if (compressor.option("cascade")) {
|
||||||
if (self.car instanceof AST_Assign
|
if (self.car instanceof AST_Assign
|
||||||
&& !self.car.left.has_side_effects()
|
&& !self.car.left.has_side_effects()
|
||||||
|
|||||||
Reference in New Issue
Block a user