@@ -8901,12 +8901,11 @@ Compressor.prototype.compress = function(node) {
|
|||||||
exprs = trim(exprs, compressor, first_in_statement, array_spread);
|
exprs = trim(exprs, compressor, first_in_statement, array_spread);
|
||||||
return exprs && make_sequence(self, exprs.map(convert_spread));
|
return exprs && make_sequence(self, exprs.map(convert_spread));
|
||||||
}
|
}
|
||||||
if (compressor.option("yields") && is_generator(exp)) {
|
if (compressor.option("yields") && is_generator(exp) && fn_name_unused(exp, compressor)) {
|
||||||
var call = self.clone();
|
var call = self.clone();
|
||||||
call.expression = make_node(AST_Function, exp);
|
call.expression = make_node(AST_Function, exp);
|
||||||
call.expression.body = [];
|
call.expression.body = [];
|
||||||
var opt = call.transform(compressor);
|
return call;
|
||||||
if (opt !== call) return opt.drop_side_effect_free(compressor, first_in_statement);
|
|
||||||
}
|
}
|
||||||
var dropped = drop_returns(compressor, exp);
|
var dropped = drop_returns(compressor, exp);
|
||||||
if (dropped) {
|
if (dropped) {
|
||||||
|
|||||||
@@ -896,7 +896,7 @@ dont_inline_nested: {
|
|||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_body: {
|
drop_body_1: {
|
||||||
options = {
|
options = {
|
||||||
side_effects: true,
|
side_effects: true,
|
||||||
yields: true,
|
yields: true,
|
||||||
@@ -906,6 +906,27 @@ drop_body: {
|
|||||||
console.log("bar");
|
console.log("bar");
|
||||||
})([ console.log("baz") ]);
|
})([ console.log("baz") ]);
|
||||||
}
|
}
|
||||||
|
expect: {
|
||||||
|
void ([ [ , [][0] = console.log("foo") ] ] = [ [ console.log("baz") ] ]);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"baz",
|
||||||
|
"foo",
|
||||||
|
]
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
drop_body_2: {
|
||||||
|
options = {
|
||||||
|
passes: 2,
|
||||||
|
side_effects: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function*([ , a = console.log("foo") ]) {
|
||||||
|
console.log("bar");
|
||||||
|
})([ console.log("baz") ]);
|
||||||
|
}
|
||||||
expect: {
|
expect: {
|
||||||
[ [ , [][0] = console.log("foo") ] ] = [ [ console.log("baz") ] ];
|
[ [ , [][0] = console.log("foo") ] ] = [ [ console.log("baz") ] ];
|
||||||
}
|
}
|
||||||
@@ -2019,7 +2040,7 @@ issue_5684: {
|
|||||||
node_version: ">=10"
|
node_version: ">=10"
|
||||||
}
|
}
|
||||||
|
|
||||||
issue_5707: {
|
issue_5707_1: {
|
||||||
options = {
|
options = {
|
||||||
hoist_props: true,
|
hoist_props: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
@@ -2033,6 +2054,28 @@ issue_5707: {
|
|||||||
function* f(c = (b = 42, console.log("PASS"))) {}
|
function* f(c = (b = 42, console.log("PASS"))) {}
|
||||||
b = f();
|
b = f();
|
||||||
}
|
}
|
||||||
|
expect: {
|
||||||
|
(function(c = console.log("PASS")) {})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5707_2: {
|
||||||
|
options = {
|
||||||
|
hoist_props: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
function* f(c = (b = 42, console.log("PASS"))) {}
|
||||||
|
b = f();
|
||||||
|
}
|
||||||
expect: {
|
expect: {
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
@@ -2076,3 +2119,53 @@ issue_5710: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=10"
|
node_version: ">=10"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5749_1: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
function* f() {}
|
||||||
|
a = f(new function() {
|
||||||
|
var b = a |= 0, c = a += console.log("PASS");
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {})(function() {
|
||||||
|
console.log("PASS");
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5749_2: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
yields: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a;
|
||||||
|
function* f() {}
|
||||||
|
a = f(new function() {
|
||||||
|
var b = a |= 0, c = a += console.log("PASS");
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user