drop anonymous function name when overshadowed by other declarations (#1712)

fixes #1709
This commit is contained in:
Alex Lam S.L
2017-03-28 17:02:20 +08:00
committed by GitHub
parent 65da9acce6
commit fb177a6312
2 changed files with 46 additions and 3 deletions

View File

@@ -1850,9 +1850,13 @@ merge(Compressor.prototype, {
function before(node, descend, in_list) {
if (node instanceof AST_Function
&& node.name
&& !compressor.option("keep_fnames")
&& !(node.name.definition().id in in_use_ids)) {
node.name = null;
&& !compressor.option("keep_fnames")) {
var def = node.name.definition();
// any declarations with same name will overshadow
// name of this anonymous function and can therefore
// never be used anywhere
if (!(def.id in in_use_ids) || def.orig.length > 1)
node.name = null;
}
if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
var trim = !compressor.option("keep_fargs");