[Pkg-javascript-commits] [uglifyjs] 369/491: retain recursive function names (#2667)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:53 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 5205dbcbf4f522f8b4dc9f9f9727b621982c9f28
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Wed Dec 27 07:00:12 2017 +0800
retain recursive function names (#2667)
fixes #2665
---
lib/compress.js | 11 ++++++++---
test/compress/drop-unused.js | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 4a2a436..c8cddc3 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;
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 714e1d1..21d4b7c 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1488,3 +1488,37 @@ issue_2660_2: {
}
expect_stdout: "0"
}
+
+issue_2665: {
+ options = {
+ evaluate: true,
+ inline: true,
+ keep_fargs: false,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ typeofs: true,
+ unused: true,
+ }
+ input: {
+ var a = 1;
+ function g() {
+ a-- && g();
+ }
+ typeof h == "function" && h();
+ function h() {
+ typeof g == "function" && g();
+ }
+ console.log(a);
+ }
+ expect: {
+ var a = 1;
+ !function g() {
+ a-- && g();
+ }();
+ console.log(a);
+ }
+ expect_stdout: "-1"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list