[Pkg-javascript-commits] [uglifyjs] 15/228: fix corner case in keep_fnames happens when inner function: - just below top level - not referenced - `unused` is disabled
Jonas Smedegaard
dr at jones.dk
Sat Apr 15 14:25:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository uglifyjs.
commit fa668a28b47e06d838659d4e0910460c84ca3a61
Author: alexlamsl <alexlamsl at gmail.com>
Date: Sat Feb 18 19:00:54 2017 +0800
fix corner case in keep_fnames
happens when inner function:
- just below top level
- not referenced
- `unused` is disabled
closes #1445
---
lib/scope.js | 4 ++--
test/compress/issue-1431.js | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/lib/scope.js b/lib/scope.js
index 0fe8d83..d5cadd3 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -268,12 +268,12 @@ AST_SymbolRef.DEFMETHOD("reference", function(options) {
var s = this.scope;
while (s) {
push_uniq(s.enclosed, def);
- if (s === def.scope) break;
if (options.keep_fnames) {
- s.variables.each(function(d) {
+ s.functions.each(function(d) {
push_uniq(def.scope.enclosed, d);
});
}
+ if (s === def.scope) break;
s = s.parent_scope;
}
});
diff --git a/test/compress/issue-1431.js b/test/compress/issue-1431.js
index 731ebba..9493fd3 100644
--- a/test/compress/issue-1431.js
+++ b/test/compress/issue-1431.js
@@ -1,3 +1,32 @@
+level_zero: {
+ options = {
+ keep_fnames: true
+ }
+ mangle = {
+ keep_fnames: true
+ }
+ input: {
+ function f(x) {
+ function n(a) {
+ return a * a;
+ }
+ return function() {
+ return x;
+ };
+ }
+ }
+ expect: {
+ function f(r) {
+ function n(n) {
+ return n * n;
+ }
+ return function() {
+ return r;
+ };
+ }
+ }
+}
+
level_one: {
options = {
keep_fnames: true
--
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