handle AST_Arrow IIFEs in collapse_vars

This commit is contained in:
alexlamsl
2017-07-08 14:27:06 +08:00
parent 2539fb8096
commit ef63de6968
2 changed files with 73 additions and 5 deletions

View File

@@ -850,8 +850,8 @@ merge(Compressor.prototype, {
}
function has_overlapping_symbol(fn, arg) {
var found = false;
var tw = new TreeWalker(function(node) {
var found = false, scan_this = !(fn instanceof AST_Arrow);
arg.walk(new TreeWalker(function(node, descend) {
if (found) return true;
if (node instanceof AST_SymbolRef && fn.variables.has(node.name)) {
var s = node.definition().scope;
@@ -860,11 +860,17 @@ merge(Compressor.prototype, {
}
return found = true;
}
if (node instanceof AST_This && !tw.find_parent(AST_Scope)) {
if (scan_this && node instanceof AST_This) {
return found = true;
}
});
arg.walk(tw);
if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
var prev = scan_this;
scan_this = false;
descend();
scan_this = prev;
return true;
}
}));
return found;
}