suppress collapse_vars of this into "use strict" (#2326)

fixes #2319
This commit is contained in:
Alex Lam S.L
2017-09-20 05:23:20 +08:00
committed by GitHub
parent aceb0af36b
commit 00f509405b
3 changed files with 75 additions and 5 deletions

View File

@@ -842,6 +842,8 @@ merge(Compressor.prototype, {
&& !fn.uses_eval
&& (iife = compressor.parent()) instanceof AST_Call
&& iife.expression === fn) {
var fn_strict = compressor.has_directive("use strict");
if (fn_strict && fn.body.indexOf(fn_strict) < 0) fn_strict = false;
var names = Object.create(null);
for (var i = fn.argnames.length; --i >= 0;) {
var sym = fn.argnames[i];
@@ -859,7 +861,7 @@ merge(Compressor.prototype, {
}
arg = null;
}
if (node instanceof AST_This && !tw.find_parent(AST_Scope)) {
if (node instanceof AST_This && (fn_strict || !tw.find_parent(AST_Scope))) {
arg = null;
return true;
}