@@ -9469,16 +9469,12 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (self.bfinally) {
|
if (self.bfinally) {
|
||||||
body.push(make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor));
|
body.push(make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor));
|
||||||
}
|
}
|
||||||
return make_node(AST_BlockStatement, self, {
|
return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
||||||
body: body
|
|
||||||
}).optimize(compressor);
|
|
||||||
}
|
}
|
||||||
if (self.bfinally && has_declarations_only(self.bfinally)) {
|
if (self.bfinally && has_declarations_only(self.bfinally)) {
|
||||||
var body = make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor);
|
var body = make_node(AST_BlockStatement, self.bfinally, self.bfinally).optimize(compressor);
|
||||||
body = self.body.concat(body);
|
body = self.body.concat(body);
|
||||||
if (!self.bcatch) return make_node(AST_BlockStatement, self, {
|
if (!self.bcatch) return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
|
||||||
body: body
|
|
||||||
}).optimize(compressor);
|
|
||||||
self.body = body;
|
self.body = body;
|
||||||
self.bfinally = null;
|
self.bfinally = null;
|
||||||
}
|
}
|
||||||
@@ -13174,6 +13170,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (fn.contains_this()) return;
|
if (fn.contains_this()) return;
|
||||||
if (!scope) scope = find_scope(compressor);
|
if (!scope) scope = find_scope(compressor);
|
||||||
var defined = new Dictionary();
|
var defined = new Dictionary();
|
||||||
|
defined.set("NaN", true);
|
||||||
while (!(scope instanceof AST_Scope)) {
|
while (!(scope instanceof AST_Scope)) {
|
||||||
scope.variables.each(function(def) {
|
scope.variables.each(function(def) {
|
||||||
defined.set(def.name, true);
|
defined.set(def.name, true);
|
||||||
@@ -13263,13 +13260,6 @@ Compressor.prototype.compress = function(node) {
|
|||||||
if (sym instanceof AST_SymbolCatch) return;
|
if (sym instanceof AST_SymbolCatch) return;
|
||||||
body.push(make_node(AST_SimpleStatement, sym, { body: init_ref(compressor, flatten_var(sym)) }));
|
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();
|
var defs = Object.create(null), syms = new Dictionary();
|
||||||
if (simple_argnames && all(call.args, function(arg) {
|
if (simple_argnames && all(call.args, function(arg) {
|
||||||
return !(arg instanceof AST_Spread);
|
return !(arg instanceof AST_Spread);
|
||||||
|
|||||||
@@ -927,3 +927,78 @@ issue_5251: {
|
|||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5342_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var a in 0) {
|
||||||
|
(() => {
|
||||||
|
while (1);
|
||||||
|
})(new function(NaN) {
|
||||||
|
a.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
console.log(function() {
|
||||||
|
return b;
|
||||||
|
try {
|
||||||
|
b;
|
||||||
|
} catch (e) {
|
||||||
|
var b;
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var a in 0) {
|
||||||
|
(function(NaN) {
|
||||||
|
a.p;
|
||||||
|
})();
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
console.log(b);
|
||||||
|
var b;
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_5342_2: {
|
||||||
|
rename = true
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
inline: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
for (var a in 0) {
|
||||||
|
(() => {
|
||||||
|
while (1);
|
||||||
|
})(new function(NaN) {
|
||||||
|
a.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
console.log(function() {
|
||||||
|
return b;
|
||||||
|
try {
|
||||||
|
b;
|
||||||
|
} catch (e) {
|
||||||
|
var b;
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
for (var a in 0) {
|
||||||
|
a.p;
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
console.log(c);
|
||||||
|
var c;
|
||||||
|
}
|
||||||
|
expect_stdout: "undefined"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1713,16 +1713,14 @@ issue_2620_5: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var c = "FAIL";
|
var c = "FAIL";
|
||||||
(function() {
|
!function(a, NaN) {
|
||||||
var a = 0/0;
|
|
||||||
var NaN = void 0;
|
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case a:
|
case a:
|
||||||
break;
|
break;
|
||||||
case c = "PASS", NaN:
|
case c = "PASS", NaN:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})();
|
}(NaN);
|
||||||
console.log(c);
|
console.log(c);
|
||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
@@ -7635,9 +7633,10 @@ issue_5237: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
function f() {
|
function f() {
|
||||||
while (console.log(0/0));
|
while (console.log(NaN));
|
||||||
var NaN = console && console.log(NaN);
|
(function() {
|
||||||
return;
|
var NaN = console && console.log(NaN);
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user