fix corner case in inline (#3343)

This commit is contained in:
Alex Lam S.L
2019-03-17 05:31:40 +08:00
committed by GitHub
parent 9707ccdc9f
commit 4430a436eb
2 changed files with 152 additions and 12 deletions

View File

@@ -5005,8 +5005,7 @@ merge(Compressor.prototype, {
}
function can_inject_vars(catches, safe_to_inject) {
var len = fn.body.length;
for (var i = 0; i < len; i++) {
for (var i = 0, len = fn.body.length; i < len; i++) {
var stat = fn.body[i];
if (!(stat instanceof AST_Var)) continue;
if (!safe_to_inject) return false;
@@ -5035,7 +5034,8 @@ merge(Compressor.prototype, {
if (scope.fixed_value() instanceof AST_Scope) return false;
}
} while (!(scope instanceof AST_Scope));
var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
var safe_to_inject = (!(scope instanceof AST_Toplevel) || compressor.toplevel.vars)
&& fn.parent_scope === compressor.find_parent(AST_Scope);
var inline = compressor.option("inline");
if (!can_inject_vars(catches, inline >= 3 && safe_to_inject)) return false;
if (!can_inject_args(catches, inline >= 2 && safe_to_inject)) return false;