@@ -4913,10 +4913,10 @@ merge(Compressor.prototype, {
4913
4913
return self ;
4914
4914
} ) ;
4915
4915
4916
- function trim_block ( node ) {
4916
+ function trim_block ( node , in_list ) {
4917
4917
switch ( node . body . length ) {
4918
4918
case 0 :
4919
- return make_node ( AST_EmptyStatement , node ) ;
4919
+ return in_list ? List . skip : make_node ( AST_EmptyStatement , node ) ;
4920
4920
case 1 :
4921
4921
var stat = node . body [ 0 ] ;
4922
4922
if ( ! ( stat instanceof AST_Const || stat instanceof AST_Let ) ) return stat ;
@@ -5983,12 +5983,8 @@ merge(Compressor.prototype, {
5983
5983
return node ;
5984
5984
}
5985
5985
} , function ( node , in_list ) {
5986
- if ( node instanceof AST_BlockStatement ) switch ( node . body . length ) {
5987
- case 0 :
5988
- return in_list ? List . skip : make_node ( AST_EmptyStatement , node ) ;
5989
- case 1 :
5990
- var stat = node . body [ 0 ] ;
5991
- if ( ! ( stat instanceof AST_Const || stat instanceof AST_Let ) ) return stat ;
5986
+ if ( node instanceof AST_BlockStatement ) {
5987
+ return trim_block ( node , in_list ) ;
5992
5988
} else if ( node instanceof AST_For ) {
5993
5989
// Certain combination of unused name + side effect leads to invalid AST:
5994
5990
// https://github.com/mishoo/UglifyJS/issues/44
@@ -7515,7 +7511,7 @@ merge(Compressor.prototype, {
7515
7511
var exprs = [ ] ;
7516
7512
for ( var i = 0 ; i < stat . body . length ; i ++ ) {
7517
7513
var line = stat . body [ i ] ;
7518
- if ( line instanceof AST_Defun ) {
7514
+ if ( is_defun ( line ) ) {
7519
7515
defuns . push ( line ) ;
7520
7516
} else if ( line instanceof AST_EmptyStatement ) {
7521
7517
continue ;
@@ -7532,7 +7528,7 @@ merge(Compressor.prototype, {
7532
7528
}
7533
7529
return exprs ;
7534
7530
}
7535
- if ( stat instanceof AST_Defun ) {
7531
+ if ( is_defun ( stat ) ) {
7536
7532
defuns . push ( stat ) ;
7537
7533
return [ ] ;
7538
7534
}
0 commit comments