fix corner case in side_effects (#5315)

fixes #5314
This commit is contained in:
Alex Lam S.L
2022-01-27 00:13:19 +00:00
committed by GitHub
parent 371d25944d
commit 67438f3ff9
3 changed files with 90 additions and 3 deletions

View File

@@ -10019,7 +10019,7 @@ Compressor.prototype.compress = function(node) {
return make_sequence(self, convert_args(value)).optimize(compressor);
}
}
if (is_func) {
if (is_func && !fn.contains_this()) {
var def, value, var_assigned = false;
if (can_inline
&& !fn.uses_arguments
@@ -10027,8 +10027,7 @@ Compressor.prototype.compress = function(node) {
&& !(fn.name && fn instanceof AST_LambdaExpression)
&& (exp === fn || !recursive_ref(compressor, def = exp.definition(), fn)
&& fn.is_constant_expression(find_scope(compressor)))
&& (value = can_flatten_body(stat))
&& !fn.contains_this()) {
&& (value = can_flatten_body(stat))) {
var replacing = exp === fn || def.single_use && def.references.length - def.replaced == 1;
if (can_substitute_directly()) {
var args = self.args.slice();