@@ -4913,10 +4913,10 @@ merge(Compressor.prototype, {
|
|||||||
return self;
|
return self;
|
||||||
});
|
});
|
||||||
|
|
||||||
function trim_block(node) {
|
function trim_block(node, in_list) {
|
||||||
switch (node.body.length) {
|
switch (node.body.length) {
|
||||||
case 0:
|
case 0:
|
||||||
return make_node(AST_EmptyStatement, node);
|
return in_list ? List.skip : make_node(AST_EmptyStatement, node);
|
||||||
case 1:
|
case 1:
|
||||||
var stat = node.body[0];
|
var stat = node.body[0];
|
||||||
if (!(stat instanceof AST_Const || stat instanceof AST_Let)) return stat;
|
if (!(stat instanceof AST_Const || stat instanceof AST_Let)) return stat;
|
||||||
@@ -5983,12 +5983,8 @@ merge(Compressor.prototype, {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}, function(node, in_list) {
|
}, function(node, in_list) {
|
||||||
if (node instanceof AST_BlockStatement) switch (node.body.length) {
|
if (node instanceof AST_BlockStatement) {
|
||||||
case 0:
|
return trim_block(node, in_list);
|
||||||
return in_list ? List.skip : make_node(AST_EmptyStatement, node);
|
|
||||||
case 1:
|
|
||||||
var stat = node.body[0];
|
|
||||||
if (!(stat instanceof AST_Const || stat instanceof AST_Let)) return stat;
|
|
||||||
} else if (node instanceof AST_For) {
|
} else if (node instanceof AST_For) {
|
||||||
// Certain combination of unused name + side effect leads to invalid AST:
|
// Certain combination of unused name + side effect leads to invalid AST:
|
||||||
// https://github.com/mishoo/UglifyJS/issues/44
|
// https://github.com/mishoo/UglifyJS/issues/44
|
||||||
@@ -7515,7 +7511,7 @@ merge(Compressor.prototype, {
|
|||||||
var exprs = [];
|
var exprs = [];
|
||||||
for (var i = 0; i < stat.body.length; i++) {
|
for (var i = 0; i < stat.body.length; i++) {
|
||||||
var line = stat.body[i];
|
var line = stat.body[i];
|
||||||
if (line instanceof AST_Defun) {
|
if (is_defun(line)) {
|
||||||
defuns.push(line);
|
defuns.push(line);
|
||||||
} else if (line instanceof AST_EmptyStatement) {
|
} else if (line instanceof AST_EmptyStatement) {
|
||||||
continue;
|
continue;
|
||||||
@@ -7532,7 +7528,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
return exprs;
|
return exprs;
|
||||||
}
|
}
|
||||||
if (stat instanceof AST_Defun) {
|
if (is_defun(stat)) {
|
||||||
defuns.push(stat);
|
defuns.push(stat);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1047,3 +1047,20 @@ issue_4595: {
|
|||||||
expect_stdout: "0"
|
expect_stdout: "0"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4598: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
if (console.log("PASS")) {
|
||||||
|
async function f() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
async function f() {}
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user