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) {
19531953 function last_of(compressor, predicate) {
19541954 var block = compressor.self(), level = 0;
19551955 do {
1956- if (block instanceof AST_Catch || block instanceof AST_Finally ) {
1956+ if (block instanceof AST_Catch) {
19571957 block = compressor.parent(level++);
19581958 } else if (block instanceof AST_LabeledStatement) {
19591959 block = block.body;
@@ -1968,7 +1968,6 @@ Compressor.prototype.compress = function(node) {
19681968 } while (stat
19691969 && (block instanceof AST_BlockStatement
19701970 || block instanceof AST_Catch
1971- || block instanceof AST_Finally
19721971 || block instanceof AST_Scope
19731972 || block instanceof AST_Try)
19741973 && is_last_statement(block.body, stat));
@@ -3690,7 +3689,7 @@ Compressor.prototype.compress = function(node) {
36903689 function eliminate_dead_code(statements, compressor) {
36913690 var has_quit;
36923691 var self = compressor.self();
3693- if (self instanceof AST_Catch || self instanceof AST_Finally ) {
3692+ if (self instanceof AST_Catch) {
36943693 self = compressor.parent();
36953694 } else if (self instanceof AST_LabeledStatement) {
36963695 self = self.body;
Original file line number Diff line number Diff line change @@ -963,3 +963,57 @@ issue_4374: {
963963 }
964964 expect_stdout: "0"
965965}
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: {
230230 conditionals : true ,
231231 dead_code : true ,
232232 if_return : true ,
233- unused : true ,
234233 }
235234 input: {
236235 L: try {
@@ -246,13 +245,14 @@ labels_12: {
246245 }
247246 }
248247 expect: {
249- try {
248+ L: try {
250249 if ( ! console . log ( "foo" ) )
251250 throw "bar" ;
252251 } catch ( e ) {
253252 console . log ( e ) ;
254253 } finally {
255- console . log ( "baz" )
254+ if ( console . log ( "baz" ) )
255+ break L;
256256 }
257257 }
258258 expect_stdout: [
@@ -381,3 +381,53 @@ issue_4466_2_toplevel_v8: {
381381 }
382382 expect_stdout: "PASS"
383383}
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