fix corner case in keep_fnames
happens when inner function: - just below top level - not referenced - `unused` is disabled closes #1445
This commit is contained in:
@@ -268,12 +268,12 @@ AST_SymbolRef.DEFMETHOD("reference", function(options) {
|
|||||||
var s = this.scope;
|
var s = this.scope;
|
||||||
while (s) {
|
while (s) {
|
||||||
push_uniq(s.enclosed, def);
|
push_uniq(s.enclosed, def);
|
||||||
if (s === def.scope) break;
|
|
||||||
if (options.keep_fnames) {
|
if (options.keep_fnames) {
|
||||||
s.variables.each(function(d) {
|
s.functions.each(function(d) {
|
||||||
push_uniq(def.scope.enclosed, d);
|
push_uniq(def.scope.enclosed, d);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (s === def.scope) break;
|
||||||
s = s.parent_scope;
|
s = s.parent_scope;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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: {
|
level_one: {
|
||||||
options = {
|
options = {
|
||||||
keep_fnames: true
|
keep_fnames: true
|
||||||
|
|||||||
Reference in New Issue
Block a user