fix corner case in inline (#5343)

fixes #5342
This commit is contained in:
Alex Lam S.L
2022-02-05 05:19:42 +00:00
committed by GitHub
parent d338e45033
commit 6fb7de7787
3 changed files with 84 additions and 20 deletions

View File

@@ -9469,16 +9469,12 @@ Compressor.prototype.compress = function(node) {
if (self.bfinally) {
body.push(make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor));
}
return make_node(AST_BlockStatement, self, {
body: body
}).optimize(compressor);
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
}
if (self.bfinally && has_declarations_only(self.bfinally)) {
var body = make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor);
body = self.body.concat(body);
if (!self.bcatch) return make_node(AST_BlockStatement, self, {
body: body
}).optimize(compressor);
if (!self.bcatch) return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
self.body = body;
self.bfinally = null;
}
@@ -13174,6 +13170,7 @@ Compressor.prototype.compress = function(node) {
if (fn.contains_this()) return;
if (!scope) scope = find_scope(compressor);
var defined = new Dictionary();
defined.set("NaN", true);
while (!(scope instanceof AST_Scope)) {
scope.variables.each(function(def) {
defined.set(def.name, true);
@@ -13263,13 +13260,6 @@ Compressor.prototype.compress = function(node) {
if (sym instanceof AST_SymbolCatch) return;
body.push(make_node(AST_SimpleStatement, sym, { body: init_ref(compressor, flatten_var(sym)) }));
});
if (fn.variables.has("NaN")) scope.transform(new TreeTransformer(function(node) {
if (node instanceof AST_NaN) return make_node(AST_Binary, node, {
operator: "/",
left: make_node(AST_Number, node, { value: 0 }),
right: make_node(AST_Number, node, { value: 0 }),
});
}));
var defs = Object.create(null), syms = new Dictionary();
if (simple_argnames && all(call.args, function(arg) {
return !(arg instanceof AST_Spread);