@@ -3032,7 +3032,11 @@ merge(Compressor.prototype, {
3032
3032
if ( ! compressor . option ( "side_effects" ) )
3033
3033
return self ;
3034
3034
self . car = self . car . drop_side_effect_free ( compressor , first_in_statement ( compressor ) ) ;
3035
- if ( ! self . car ) return maintain_this_binding ( compressor . parent ( ) , self , self . cdr ) ;
3035
+ if ( ! self . car ) {
3036
+ if ( self . cdr instanceof AST_NaN || self . cdr instanceof AST_Infinity )
3037
+ return self . cdr . clone ( ) . optimize ( compressor ) ;
3038
+ return maintain_this_binding ( compressor . parent ( ) , self , self . cdr ) ;
3039
+ }
3036
3040
if ( compressor . option ( "cascade" ) ) {
3037
3041
var left ;
3038
3042
if ( self . car instanceof AST_Assign
@@ -3607,6 +3611,14 @@ merge(Compressor.prototype, {
3607
3611
return self ;
3608
3612
} ) ;
3609
3613
3614
+ function in_delete ( parent ) {
3615
+ return parent instanceof AST_UnaryPrefix && parent . operator == "delete" ;
3616
+ }
3617
+
3618
+ function is_atomic ( parent , self ) {
3619
+ return parent . expression instanceof AST_SymbolRef || parent . expression . TYPE === self . TYPE ;
3620
+ }
3621
+
3610
3622
OPT ( AST_Undefined , function ( self , compressor ) {
3611
3623
if ( compressor . option ( "unsafe" ) ) {
3612
3624
var undef = find_variable ( compressor , "undefined" ) ;
@@ -3621,10 +3633,7 @@ merge(Compressor.prototype, {
3621
3633
}
3622
3634
}
3623
3635
var parent = compressor . parent ( ) ;
3624
- if ( parent instanceof AST_UnaryPrefix
3625
- && parent . operator == "delete"
3626
- && ( parent . expression instanceof AST_SymbolRef
3627
- || parent . expression . TYPE === self . TYPE ) ) return self ;
3636
+ if ( in_delete ( parent ) && is_atomic ( parent , self ) ) return self ;
3628
3637
return make_node ( AST_UnaryPrefix , self , {
3629
3638
operator : "void" ,
3630
3639
expression : make_node ( AST_Number , self , {
@@ -3635,12 +3644,10 @@ merge(Compressor.prototype, {
3635
3644
3636
3645
OPT ( AST_Infinity , function ( self , compressor ) {
3637
3646
var parent = compressor . parent ( ) ;
3638
- if ( parent instanceof AST_UnaryPrefix
3639
- && parent . operator == "delete"
3640
- && ( parent . expression instanceof AST_SymbolRef
3641
- || parent . expression . TYPE === self . TYPE ) )
3642
- return self ;
3647
+ var del = in_delete ( parent ) ;
3648
+ if ( del && is_atomic ( parent , self ) ) return self ;
3643
3649
if ( compressor . option ( "keep_infinity" )
3650
+ && ! ( del && ! is_atomic ( parent , self ) )
3644
3651
&& ! find_variable ( compressor , "Infinity" ) )
3645
3652
return self ;
3646
3653
return make_node ( AST_Binary , self , {
@@ -3656,10 +3663,7 @@ merge(Compressor.prototype, {
3656
3663
3657
3664
OPT ( AST_NaN , function ( self , compressor ) {
3658
3665
var parent = compressor . parent ( ) ;
3659
- if ( parent instanceof AST_UnaryPrefix
3660
- && parent . operator == "delete"
3661
- && ! ( parent . expression instanceof AST_SymbolRef
3662
- || parent . expression . TYPE === self . TYPE )
3666
+ if ( in_delete ( parent ) && ! is_atomic ( parent , self )
3663
3667
|| find_variable ( compressor , "NaN" ) ) {
3664
3668
return make_node ( AST_Binary , self , {
3665
3669
operator : "/" ,
0 commit comments