File tree 2 files changed +55
-1
lines changed
2 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -3620,7 +3620,7 @@ Compressor.prototype.compress = function(node) {
3620
3620
continue;
3621
3621
}
3622
3622
3623
- if (jump && jump === next) eliminate_returns(stat);
3623
+ if (declare_only && jump && jump === next) eliminate_returns(stat);
3624
3624
}
3625
3625
return changed;
3626
3626
@@ -3787,6 +3787,7 @@ Compressor.prototype.compress = function(node) {
3787
3787
if (stat instanceof AST_Exit) {
3788
3788
var mode = match_return(stat, true);
3789
3789
if (mode) {
3790
+ changed = true;
3790
3791
var value = trim_return(stat.value, mode);
3791
3792
if (value) return make_node(AST_SimpleStatement, value, { body: value });
3792
3793
return in_block ? null : make_node(AST_EmptyStatement, stat);
Original file line number Diff line number Diff line change @@ -2305,3 +2305,56 @@ issue_5597: {
2305
2305
}
2306
2306
expect_stdout: "PASS"
2307
2307
}
2308
+
2309
+ issue_5619_1: {
2310
+ options = {
2311
+ if_return : true ,
2312
+ }
2313
+ input: {
2314
+ console . log ( function ( ) {
2315
+ if ( console )
2316
+ if ( console )
2317
+ return "PASS" ;
2318
+ var a = FAIL ;
2319
+ return "PASS" ;
2320
+ } ( ) ) ;
2321
+ }
2322
+ expect: {
2323
+ console . log ( function ( ) {
2324
+ if ( console )
2325
+ if ( console )
2326
+ return "PASS" ;
2327
+ var a = FAIL ;
2328
+ return "PASS" ;
2329
+ } ( ) ) ;
2330
+ }
2331
+ expect_stdout: "PASS"
2332
+ }
2333
+
2334
+ issue_5619_2: {
2335
+ options = {
2336
+ dead_code : true ,
2337
+ if_return : true ,
2338
+ loops : true ,
2339
+ }
2340
+ input: {
2341
+ console . log ( function ( ) {
2342
+ if ( console )
2343
+ while ( console )
2344
+ return "PASS" ;
2345
+ var a = FAIL ;
2346
+ return "PASS" ;
2347
+ } ( ) ) ;
2348
+ }
2349
+ expect: {
2350
+ console . log ( function ( ) {
2351
+ if ( console ) {
2352
+ if ( console )
2353
+ return "PASS" ;
2354
+ }
2355
+ var a = FAIL ;
2356
+ return "PASS" ;
2357
+ } ( ) ) ;
2358
+ }
2359
+ expect_stdout: "PASS"
2360
+ }
You can’t perform that action at this time.
0 commit comments