@@ -9297,10 +9297,9 @@ merge(Compressor.prototype, {
|
|||||||
OPT(AST_Infinity, function(self, compressor) {
|
OPT(AST_Infinity, function(self, compressor) {
|
||||||
var lhs = is_lhs(compressor.self(), compressor.parent());
|
var lhs = is_lhs(compressor.self(), compressor.parent());
|
||||||
if (lhs && is_atomic(lhs, self)) return self;
|
if (lhs && is_atomic(lhs, self)) return self;
|
||||||
if (compressor.option("keep_infinity")
|
if (compressor.option("keep_infinity") && !lhs && !find_scope(compressor).find_variable("Infinity")) {
|
||||||
&& !(lhs && !is_atomic(lhs, self))
|
|
||||||
&& !find_scope(compressor).find_variable("Infinity"))
|
|
||||||
return self;
|
return self;
|
||||||
|
}
|
||||||
return make_node(AST_Binary, self, {
|
return make_node(AST_Binary, self, {
|
||||||
operator: "/",
|
operator: "/",
|
||||||
left: make_node(AST_Number, self, {
|
left: make_node(AST_Number, self, {
|
||||||
@@ -9314,18 +9313,17 @@ merge(Compressor.prototype, {
|
|||||||
|
|
||||||
OPT(AST_NaN, function(self, compressor) {
|
OPT(AST_NaN, function(self, compressor) {
|
||||||
var lhs = is_lhs(compressor.self(), compressor.parent());
|
var lhs = is_lhs(compressor.self(), compressor.parent());
|
||||||
if (lhs && !is_atomic(lhs, self) || find_scope(compressor).find_variable("NaN")) {
|
if (lhs && is_atomic(lhs, self)) return self;
|
||||||
return make_node(AST_Binary, self, {
|
if (!lhs && !find_scope(compressor).find_variable("NaN")) return self;
|
||||||
operator: "/",
|
return make_node(AST_Binary, self, {
|
||||||
left: make_node(AST_Number, self, {
|
operator: "/",
|
||||||
value: 0
|
left: make_node(AST_Number, self, {
|
||||||
}),
|
value: 0
|
||||||
right: make_node(AST_Number, self, {
|
}),
|
||||||
value: 0
|
right: make_node(AST_Number, self, {
|
||||||
})
|
value: 0
|
||||||
});
|
})
|
||||||
}
|
});
|
||||||
return self;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function is_reachable(self, defs) {
|
function is_reachable(self, defs) {
|
||||||
|
|||||||
@@ -2037,3 +2037,90 @@ issue_4425: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4436_Infinity: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function({
|
||||||
|
[delete Infinity]: a,
|
||||||
|
}) {
|
||||||
|
var Infinity;
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function({
|
||||||
|
[delete Infinity]: a,
|
||||||
|
}) {
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4436_NaN: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function({
|
||||||
|
[delete NaN]: a,
|
||||||
|
}) {
|
||||||
|
var NaN;
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function({
|
||||||
|
[delete NaN]: a,
|
||||||
|
}) {
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4436_undefined: {
|
||||||
|
options = {
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function({
|
||||||
|
[delete undefined]: a,
|
||||||
|
}) {
|
||||||
|
var undefined;
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function({
|
||||||
|
[delete undefined]: a,
|
||||||
|
}) {
|
||||||
|
return a;
|
||||||
|
}({
|
||||||
|
true: "FAIL",
|
||||||
|
false: "PASS",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
node_version: ">=6"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user