aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-27 07:00:12 +0800
committerGitHub <noreply@github.com>2017-12-27 07:00:12 +0800
commit5205dbcbf4f522f8b4dc9f9f9727b621982c9f28 (patch)
tree030b4d6115b0b5454543ce52b5b0c1ce58d39b07 /lib
parent3ff625de7e3d381de43b4703faae402381844c9f (diff)
downloadtracifyjs-5205dbcbf4f522f8b4dc9f9f9727b621982c9f28.tar.gz
tracifyjs-5205dbcbf4f522f8b4dc9f9f9727b621982c9f28.zip
retain recursive function names (#2667)
fixes #2665
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 4a2a436b..c8cddc37 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4700,9 +4700,14 @@ merge(Compressor.prototype, {
if (d.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
value = fixed.clone(true);
var defun_def = value.name.definition();
- value.name = make_node(AST_SymbolLambda, value.name, value.name);
- value.name.scope = value;
- var lambda_def = value.def_function(value.name);
+ var lambda_def = value.variables.get(value.name.name);
+ var name = lambda_def && lambda_def.orig[0];
+ if (!(name instanceof AST_SymbolLambda)) {
+ name = make_node(AST_SymbolLambda, value.name, value.name);
+ name.scope = value;
+ value.name = name;
+ lambda_def = value.def_function(name);
+ }
value.walk(new TreeWalker(function(node) {
if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
node.thedef = lambda_def;