@@ -3540,8 +3540,9 @@ Compressor.prototype.compress = function(node) {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var loop = in_loop && in_try && in_try.bfinally ? "try" : in_loop;
|
||||||
for (; index >= 0; index--) {
|
for (; index >= 0; index--) {
|
||||||
var inlined = statements[index].try_inline(compressor, block_scope, true, in_loop);
|
var inlined = statements[index].try_inline(compressor, block_scope, true, loop);
|
||||||
if (!inlined) continue;
|
if (!inlined) continue;
|
||||||
statements[index] = inlined;
|
statements[index] = inlined;
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -13263,6 +13264,11 @@ Compressor.prototype.compress = function(node) {
|
|||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
def(AST_New, noop);
|
def(AST_New, noop);
|
||||||
|
def(AST_Return, function(compressor, scope, no_return, in_loop) {
|
||||||
|
var value = this.value;
|
||||||
|
if (value) value = value.try_inline(compressor, scope, undefined, in_loop === "try");
|
||||||
|
return value || this;
|
||||||
|
});
|
||||||
function inline_sequence(compressor, scope, no_return, in_loop, node, skip) {
|
function inline_sequence(compressor, scope, no_return, in_loop, node, skip) {
|
||||||
var body = [], exprs = node.expressions, no_ret = no_return;
|
var body = [], exprs = node.expressions, no_ret = no_return;
|
||||||
for (var i = exprs.length - (skip || 0), j = i; --i >= 0; no_ret = true) {
|
for (var i = exprs.length - (skip || 0), j = i; --i >= 0; no_ret = true) {
|
||||||
@@ -13363,10 +13369,8 @@ Compressor.prototype.compress = function(node) {
|
|||||||
|
|
||||||
OPT(AST_Return, function(self, compressor) {
|
OPT(AST_Return, function(self, compressor) {
|
||||||
var value = self.value;
|
var value = self.value;
|
||||||
if (!value) return self;
|
|
||||||
var inlined = value.try_inline(compressor);
|
|
||||||
if (inlined) return inlined;
|
|
||||||
if (compressor.option("side_effects")
|
if (compressor.option("side_effects")
|
||||||
|
&& value
|
||||||
&& is_undefined(value, compressor)
|
&& is_undefined(value, compressor)
|
||||||
&& !in_async_generator(compressor.find_parent(AST_Scope))) {
|
&& !in_async_generator(compressor.find_parent(AST_Scope))) {
|
||||||
self.value = null;
|
self.value = null;
|
||||||
|
|||||||
@@ -1233,8 +1233,11 @@ issue_2105_2: {
|
|||||||
issue_2105_3: {
|
issue_2105_3: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
passes: 2,
|
join_vars: true,
|
||||||
|
passes: 3,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
sequences: true,
|
||||||
unused: true,
|
unused: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
@@ -1258,12 +1261,12 @@ issue_2105_3: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
!void void {
|
({
|
||||||
prop: function() {
|
prop: function() {
|
||||||
console.log;
|
console.log,
|
||||||
void console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
},
|
||||||
}.prop();
|
}).prop();
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6152,10 +6152,8 @@ issue_4265: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f() {
|
function f() {
|
||||||
return console, function() {
|
var a;
|
||||||
console.log(a);
|
return console, console.log(a), 0;
|
||||||
var a;
|
|
||||||
}(), 0;
|
|
||||||
}
|
}
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
@@ -8046,3 +8044,40 @@ issue_5290: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5296: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function() {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
try {
|
||||||
|
return function() {
|
||||||
|
while (!console);
|
||||||
|
var b = b && (a = b) || "FAIL";
|
||||||
|
}();
|
||||||
|
} finally {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "PASS";
|
||||||
|
(function() {
|
||||||
|
for (var i = 0; i < 2; i++)
|
||||||
|
try {
|
||||||
|
b = void 0;
|
||||||
|
while (!console);
|
||||||
|
var b = b && (a = b) || "FAIL";
|
||||||
|
return;
|
||||||
|
} finally {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -595,10 +595,10 @@ issue_3600_2: {
|
|||||||
expect: {
|
expect: {
|
||||||
var c = 0;
|
var c = 0;
|
||||||
(function() {
|
(function() {
|
||||||
if ([][c++]) {
|
if ([][c++])
|
||||||
var b = --b;
|
b = --b,
|
||||||
c = 42;
|
c = 42;
|
||||||
}
|
var b;
|
||||||
})();
|
})();
|
||||||
console.log(c);
|
console.log(c);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user