account for catch variable when inline (#2605)

fixes #2604
This commit is contained in:
Alex Lam S.L
2017-12-16 15:21:09 +08:00
committed by GitHub
parent 6c686ce593
commit 21794c9b8d
2 changed files with 88 additions and 2 deletions

View File

@@ -3924,10 +3924,20 @@ merge(Compressor.prototype, {
return self;
function can_flatten_args(fn) {
var scope = compressor.find_parent(AST_Scope);
var scope, level = 0;
var catches = Object.create(null);
do {
scope = compressor.parent(level++);
if (scope instanceof AST_Catch) {
catches[scope.argname.name] = true;
}
} while (!(scope instanceof AST_Scope));
var safe_to_inject = compressor.toplevel.vars || !(scope instanceof AST_Toplevel);
return all(fn.argnames, function(arg) {
return arg.__unused || safe_to_inject && !scope.var_names()[arg.name];
return arg.__unused
|| safe_to_inject
&& !catches[arg.name]
&& !scope.var_names()[arg.name];
}) && scope;
}