fix corner cases in dead_code & if_return (#5525)

fixes #5521
fixes #5522
fixes #5523
fixes #5524
This commit is contained in:
Alex Lam S.L
2022-06-26 11:40:56 +01:00
committed by GitHub
parent 8b464331ba
commit fcc87edb71
3 changed files with 109 additions and 6 deletions

View File

@@ -1953,7 +1953,7 @@ Compressor.prototype.compress = function(node) {
function last_of(compressor, predicate) {
var block = compressor.self(), level = 0;
do {
if (block instanceof AST_Catch || block instanceof AST_Finally) {
if (block instanceof AST_Catch) {
block = compressor.parent(level++);
} else if (block instanceof AST_LabeledStatement) {
block = block.body;
@@ -1968,7 +1968,6 @@ Compressor.prototype.compress = function(node) {
} while (stat
&& (block instanceof AST_BlockStatement
|| block instanceof AST_Catch
|| block instanceof AST_Finally
|| block instanceof AST_Scope
|| block instanceof AST_Try)
&& is_last_statement(block.body, stat));
@@ -3690,7 +3689,7 @@ Compressor.prototype.compress = function(node) {
function eliminate_dead_code(statements, compressor) {
var has_quit;
var self = compressor.self();
if (self instanceof AST_Catch || self instanceof AST_Finally) {
if (self instanceof AST_Catch) {
self = compressor.parent();
} else if (self instanceof AST_LabeledStatement) {
self = self.body;