retain @__PURE__ call when return value is used (#3874)
This commit is contained in:
@@ -3499,6 +3499,7 @@ merge(Compressor.prototype, {
|
|||||||
if (fn instanceof AST_Lambda) {
|
if (fn instanceof AST_Lambda) {
|
||||||
if (fn.evaluating) return this;
|
if (fn.evaluating) return this;
|
||||||
if (fn.name && fn.name.definition().recursive_refs > 0) return this;
|
if (fn.name && fn.name.definition().recursive_refs > 0) return this;
|
||||||
|
if (this.is_expr_pure(compressor)) return this;
|
||||||
var stat = fn.first_statement();
|
var stat = fn.first_statement();
|
||||||
if (!(stat instanceof AST_Return)) return this;
|
if (!(stat instanceof AST_Return)) return this;
|
||||||
var args = eval_args(this.args);
|
var args = eval_args(this.args);
|
||||||
|
|||||||
@@ -782,3 +782,28 @@ inline_pure_call_3: {
|
|||||||
"undefined",
|
"undefined",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline_pure_call_4: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = /*@__PURE__*/ function() {
|
||||||
|
return console.log("PASS"), 42;
|
||||||
|
}();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function() {
|
||||||
|
return console.log("PASS"), 42;
|
||||||
|
}();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"PASS",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user