Skip to content

Commit

Permalink
fix corner case in inline (#5068)
Browse files Browse the repository at this point in the history
fixes #5067
  • Loading branch information
alexlamsl committed Jul 10, 2021
1 parent aae1fcd commit d147d5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2207,7 +2207,7 @@ merge(Compressor.prototype, {
fn = fn.fixed_value();
}
if (!(fn instanceof AST_Lambda)) return !node.is_expr_pure(compressor);
if (def && recursive_ref(compressor, def)) return true;
if (def && recursive_ref(compressor, def, fn)) return true;
if (fn.collapse_scanning) return false;
fn.collapse_scanning = true;
var replace = can_replace;
Expand Down Expand Up @@ -9481,7 +9481,7 @@ merge(Compressor.prototype, {
&& !fn.uses_arguments
&& !fn.pinned()
&& !(fn.name && fn instanceof AST_LambdaExpression)
&& (exp === fn || !recursive_ref(compressor, def = exp.definition())
&& (exp === fn || !recursive_ref(compressor, def = exp.definition(), fn)
&& fn.is_constant_expression(find_scope(compressor)))
&& !has_spread
&& (value = can_flatten_body(stat))
Expand Down
15 changes: 15 additions & 0 deletions test/compress/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6398,3 +6398,18 @@ issue_5061_2: {
"bar",
]
}

issue_5067: {
options = {
inline: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var f = function() {
f();
};
}
expect: {}
}

0 comments on commit d147d5d

Please sign in to comment.