@@ -938,31 +938,35 @@ merge(Compressor.prototype, {
|
|||||||
node.variables.each(function(def) {
|
node.variables.each(function(def) {
|
||||||
reset_def(tw, compressor, def);
|
reset_def(tw, compressor, def);
|
||||||
});
|
});
|
||||||
if (!node.name) return;
|
if (node.extends) node.extends.walk(tw);
|
||||||
var d = node.name.definition();
|
if (node.name) {
|
||||||
var parent = tw.parent();
|
var d = node.name.definition();
|
||||||
if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) d.single_use = false;
|
var parent = tw.parent();
|
||||||
if (safe_to_assign(tw, d, true)) {
|
if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) d.single_use = false;
|
||||||
mark(tw, d);
|
if (safe_to_assign(tw, d, true)) {
|
||||||
tw.loop_ids[d.id] = tw.in_loop;
|
mark(tw, d);
|
||||||
d.fixed = function() {
|
tw.loop_ids[d.id] = tw.in_loop;
|
||||||
return node;
|
d.fixed = function() {
|
||||||
};
|
return node;
|
||||||
d.fixed.assigns = [ node ];
|
};
|
||||||
if (!is_safe_lexical(d)) d.single_use = false;
|
d.fixed.assigns = [ node ];
|
||||||
} else {
|
if (!is_safe_lexical(d)) d.single_use = false;
|
||||||
d.fixed = false;
|
} else {
|
||||||
}
|
d.fixed = false;
|
||||||
});
|
}
|
||||||
def(AST_ClassField, function(tw) {
|
|
||||||
var node = this;
|
|
||||||
if (node.static) return;
|
|
||||||
if (node.key instanceof AST_Node) node.key.walk(tw);
|
|
||||||
if (node.value) {
|
|
||||||
push(tw);
|
|
||||||
node.value.walk(tw);
|
|
||||||
pop(tw);
|
|
||||||
}
|
}
|
||||||
|
node.properties.filter(function(prop) {
|
||||||
|
if (prop.key instanceof AST_Node) prop.key.walk(tw);
|
||||||
|
return prop.value;
|
||||||
|
}).forEach(function(prop) {
|
||||||
|
if (prop.static) {
|
||||||
|
prop.value.walk(tw);
|
||||||
|
} else {
|
||||||
|
push(tw);
|
||||||
|
prop.value.walk(tw);
|
||||||
|
pop(tw);
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
def(AST_Conditional, function(tw) {
|
def(AST_Conditional, function(tw) {
|
||||||
|
|||||||
@@ -747,3 +747,24 @@ issue_4687_2: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4705: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "PASS";
|
||||||
|
class A {
|
||||||
|
p = a = "FAIL";
|
||||||
|
[console.log(a)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("PASS");
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=12"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user