@@ -6278,21 +6278,24 @@ Compressor.prototype.compress = function(node) {
|
|||||||
var call = stat.value;
|
var call = stat.value;
|
||||||
if (!call || call.TYPE != "Call") break;
|
if (!call || call.TYPE != "Call") break;
|
||||||
if (call.is_expr_pure(compressor)) break;
|
if (call.is_expr_pure(compressor)) break;
|
||||||
var fn = call.expression;
|
var exp = call.expression, fn;
|
||||||
if (fn instanceof AST_SymbolRef) {
|
if (!(exp instanceof AST_SymbolRef)) {
|
||||||
if (self.name && self.name.definition() === fn.definition()) break;
|
fn = exp;
|
||||||
fn = fn.fixed_value();
|
} else if (self.name && self.name.definition() === exp.definition()) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
fn = exp.fixed_value();
|
||||||
}
|
}
|
||||||
if (!(fn instanceof AST_Defun || fn instanceof AST_Function)) break;
|
if (!(fn instanceof AST_Defun || fn instanceof AST_Function)) break;
|
||||||
if (fn.rest) break;
|
if (fn.rest) break;
|
||||||
if (fn.uses_arguments) break;
|
if (fn.uses_arguments) break;
|
||||||
if (fn === call.expression) {
|
if (fn === exp) {
|
||||||
if (fn.parent_scope !== self) break;
|
if (fn.parent_scope !== self) break;
|
||||||
if (!all(fn.enclosed, function(def) {
|
if (!all(fn.enclosed, function(def) {
|
||||||
return def.scope !== self;
|
return def.scope !== self;
|
||||||
})) break;
|
})) break;
|
||||||
}
|
}
|
||||||
if (fn.name
|
if ((fn !== exp || fn.name)
|
||||||
&& (parent instanceof AST_ClassMethod || parent instanceof AST_ObjectMethod)
|
&& (parent instanceof AST_ClassMethod || parent instanceof AST_ObjectMethod)
|
||||||
&& parent.value === compressor.self()) break;
|
&& parent.value === compressor.self()) break;
|
||||||
if (fn.contains_this()) break;
|
if (fn.contains_this()) break;
|
||||||
@@ -6321,7 +6324,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
fn.argnames.push(fn.make_var(AST_SymbolFunarg, fn, "argument_" + len));
|
fn.argnames.push(fn.make_var(AST_SymbolFunarg, fn, "argument_" + len));
|
||||||
} while (++len < self.argnames.length);
|
} while (++len < self.argnames.length);
|
||||||
}
|
}
|
||||||
return call.expression;
|
return exp;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3586,3 +3586,36 @@ issue_5531_3: {
|
|||||||
expect_stdout: "foo"
|
expect_stdout: "foo"
|
||||||
node_version: ">=16"
|
node_version: ">=16"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5662: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(new (function() {
|
||||||
|
var g = function(a) {
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
return class {
|
||||||
|
h(b) {
|
||||||
|
return g(b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}())().h("PASS"));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(new (function() {
|
||||||
|
var g = function(a) {
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
return class {
|
||||||
|
h(b) {
|
||||||
|
return g(b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}())().h("PASS"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node instanceof U.AST_VarDef) {
|
else if (node instanceof U.AST_VarDef) {
|
||||||
if (node.value && !(parent instanceof U.AST_Const)) {
|
if (node.value && !(node.name instanceof U.AST_Destructured || parent instanceof U.AST_Const)) {
|
||||||
node.start._permute++;
|
node.start._permute++;
|
||||||
CHANGED = true;
|
CHANGED = true;
|
||||||
return new U.AST_VarDef({
|
return new U.AST_VarDef({
|
||||||
|
|||||||
Reference in New Issue
Block a user