diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-28 17:02:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-28 17:02:20 +0800 |
commit | fb177a6312ccd90918c9f8f0f867c2fddd85a2c8 (patch) | |
tree | 1dd736b01a7262fcb5dd1504d8de9a5100cbe869 /lib/compress.js | |
parent | 65da9acce6bd2548e5ffc7f35527ff62ff3f2fdd (diff) | |
download | tracifyjs-fb177a6312ccd90918c9f8f0f867c2fddd85a2c8.tar.gz tracifyjs-fb177a6312ccd90918c9f8f0f867c2fddd85a2c8.zip |
drop anonymous function name when overshadowed by other declarations (#1712)
fixes #1709
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js index e2fde883..e4863d9f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -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"); |