@@ -4404,9 +4404,15 @@ Compressor.prototype.compress = function(node) {
|
|||||||
def(AST_Sequence, function(compressor) {
|
def(AST_Sequence, function(compressor) {
|
||||||
return this.tail_node().is_number(compressor);
|
return this.tail_node().is_number(compressor);
|
||||||
});
|
});
|
||||||
def(AST_SymbolRef, function(compressor) {
|
def(AST_SymbolRef, function(compressor, keep_unary) {
|
||||||
var fixed = this.fixed_value();
|
var fixed = this.fixed_value();
|
||||||
if (!fixed) return false;
|
if (!fixed) return false;
|
||||||
|
if (keep_unary
|
||||||
|
&& fixed instanceof AST_UnaryPrefix
|
||||||
|
&& fixed.operator == "+"
|
||||||
|
&& fixed.expression.equivalent_to(this)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.is_number = return_false;
|
this.is_number = return_false;
|
||||||
var result = fixed.is_number(compressor);
|
var result = fixed.is_number(compressor);
|
||||||
delete this.is_number;
|
delete this.is_number;
|
||||||
@@ -10772,7 +10778,7 @@ Compressor.prototype.compress = function(node) {
|
|||||||
}
|
}
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case "+":
|
case "+":
|
||||||
if (compressor.option("evaluate") && exp.is_number(compressor)) return exp;
|
if (compressor.option("evaluate") && exp.is_number(compressor, true)) return exp;
|
||||||
break;
|
break;
|
||||||
case "-":
|
case "-":
|
||||||
if (exp instanceof AST_Infinity) exp = exp.transform(compressor);
|
if (exp instanceof AST_Infinity) exp = exp.transform(compressor);
|
||||||
|
|||||||
@@ -1002,3 +1002,19 @@ issue_5342_2: {
|
|||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5356: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log((a => a++)(console));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log((a => +a)(console));
|
||||||
|
}
|
||||||
|
expect_stdout: "NaN"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
@@ -3273,3 +3273,24 @@ issue_5354: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "number string number"
|
expect_stdout: "number string number"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5356: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
return a++;
|
||||||
|
var a = a;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(+a);
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
expect_stdout: "NaN"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user