File tree Expand file tree Collapse file tree 3 files changed +109
-6
lines changed Expand file tree Collapse file tree 3 files changed +109
-6
lines changed Original file line number Diff line number Diff line change @@ -1953,7 +1953,7 @@ Compressor.prototype.compress = function(node) {
1953
1953
function last_of(compressor, predicate) {
1954
1954
var block = compressor.self(), level = 0;
1955
1955
do {
1956
- if (block instanceof AST_Catch || block instanceof AST_Finally ) {
1956
+ if (block instanceof AST_Catch) {
1957
1957
block = compressor.parent(level++);
1958
1958
} else if (block instanceof AST_LabeledStatement) {
1959
1959
block = block.body;
@@ -1968,7 +1968,6 @@ Compressor.prototype.compress = function(node) {
1968
1968
} while (stat
1969
1969
&& (block instanceof AST_BlockStatement
1970
1970
|| block instanceof AST_Catch
1971
- || block instanceof AST_Finally
1972
1971
|| block instanceof AST_Scope
1973
1972
|| block instanceof AST_Try)
1974
1973
&& is_last_statement(block.body, stat));
@@ -3690,7 +3689,7 @@ Compressor.prototype.compress = function(node) {
3690
3689
function eliminate_dead_code(statements, compressor) {
3691
3690
var has_quit;
3692
3691
var self = compressor.self();
3693
- if (self instanceof AST_Catch || self instanceof AST_Finally ) {
3692
+ if (self instanceof AST_Catch) {
3694
3693
self = compressor.parent();
3695
3694
} else if (self instanceof AST_LabeledStatement) {
3696
3695
self = self.body;
Original file line number Diff line number Diff line change @@ -963,3 +963,57 @@ issue_4374: {
963
963
}
964
964
expect_stdout: "0"
965
965
}
966
+
967
+ issue_5521: {
968
+ options = {
969
+ if_return : true ,
970
+ }
971
+ input: {
972
+ console . log ( function ( ) {
973
+ if ( console )
974
+ try {
975
+ return "FAIL" ;
976
+ } finally {
977
+ return ;
978
+ }
979
+ } ( ) ) ;
980
+ }
981
+ expect: {
982
+ console . log ( function ( ) {
983
+ if ( console )
984
+ try {
985
+ return "FAIL" ;
986
+ } finally {
987
+ return ;
988
+ }
989
+ } ( ) ) ;
990
+ }
991
+ expect_stdout: "undefined"
992
+ }
993
+
994
+ issue_5523: {
995
+ options = {
996
+ if_return : true ,
997
+ }
998
+ input: {
999
+ console . log ( function ( ) {
1000
+ if ( console )
1001
+ try {
1002
+ FAIL ;
1003
+ } finally {
1004
+ return ;
1005
+ }
1006
+ } ( ) ) ;
1007
+ }
1008
+ expect: {
1009
+ console . log ( function ( ) {
1010
+ if ( console )
1011
+ try {
1012
+ FAIL ;
1013
+ } finally {
1014
+ return ;
1015
+ }
1016
+ } ( ) ) ;
1017
+ }
1018
+ expect_stdout: "undefined"
1019
+ }
Original file line number Diff line number Diff line change @@ -230,7 +230,6 @@ labels_12: {
230
230
conditionals : true ,
231
231
dead_code : true ,
232
232
if_return : true ,
233
- unused : true ,
234
233
}
235
234
input: {
236
235
L: try {
@@ -246,13 +245,14 @@ labels_12: {
246
245
}
247
246
}
248
247
expect: {
249
- try {
248
+ L: try {
250
249
if ( ! console . log ( "foo" ) )
251
250
throw "bar" ;
252
251
} catch ( e ) {
253
252
console . log ( e ) ;
254
253
} finally {
255
- console . log ( "baz" )
254
+ if ( console . log ( "baz" ) )
255
+ break L;
256
256
}
257
257
}
258
258
expect_stdout: [
@@ -381,3 +381,53 @@ issue_4466_2_toplevel_v8: {
381
381
}
382
382
expect_stdout: "PASS"
383
383
}
384
+
385
+ issue_5522: {
386
+ options = {
387
+ dead_code : true ,
388
+ }
389
+ input: {
390
+ console . log ( function ( ) {
391
+ L: try {
392
+ return "FAIL" ;
393
+ } finally {
394
+ break L;
395
+ }
396
+ return "PASS" ;
397
+ } ( ) ) ;
398
+ }
399
+ expect: {
400
+ console . log ( function ( ) {
401
+ L: try {
402
+ return "FAIL" ;
403
+ } finally {
404
+ break L;
405
+ }
406
+ return "PASS" ;
407
+ } ( ) ) ;
408
+ }
409
+ expect_stdout: "PASS"
410
+ }
411
+
412
+ issue_5524: {
413
+ options = {
414
+ dead_code : true ,
415
+ }
416
+ input: {
417
+ L: try {
418
+ FAIL ;
419
+ } finally {
420
+ break L;
421
+ }
422
+ console . log ( "PASS" ) ;
423
+ }
424
+ expect: {
425
+ L: try {
426
+ FAIL ;
427
+ } finally {
428
+ break L;
429
+ }
430
+ console . log ( "PASS" ) ;
431
+ }
432
+ expect_stdout: "PASS"
433
+ }
You can’t perform that action at this time.
0 commit comments