Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
retain @__PURE__ call when return value is used (#3874)
  • Loading branch information
alexlamsl committed May 10, 2020
1 parent 63adfb1 commit 7e0ad23
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -3499,6 +3499,7 @@ merge(Compressor.prototype, {
if (fn instanceof AST_Lambda) {
if (fn.evaluating) 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();
if (!(stat instanceof AST_Return)) return this;
var args = eval_args(this.args);
Expand Down
25 changes: 25 additions & 0 deletions test/compress/pure_funcs.js
Expand Up @@ -782,3 +782,28 @@ inline_pure_call_3: {
"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",
]
}

0 comments on commit 7e0ad23

Please sign in to comment.