fix corner case in reduce_vars (#3867)

fixes #3866
This commit is contained in:
Alex Lam S.L
2020-05-10 09:35:03 +01:00
committed by GitHub
parent abb8ae02a5
commit 33f3b0c1d9
3 changed files with 28 additions and 5 deletions

View File

@@ -577,9 +577,10 @@ merge(Compressor.prototype, {
sym.fixed = d.fixed = eq ? function() {
return node.right;
} : function() {
return make_node(AST_Binary, node, {
var value = fixed instanceof AST_Node ? fixed : fixed();
return value && make_node(AST_Binary, node, {
operator: node.operator.slice(0, -1),
left: fixed instanceof AST_Node ? fixed : fixed(),
left: value,
right: node.right
});
};
@@ -858,11 +859,12 @@ merge(Compressor.prototype, {
var fixed = d.fixed;
if (!fixed) return;
exp.fixed = d.fixed = function() {
return make_node(AST_Binary, node, {
var value = fixed instanceof AST_Node ? fixed : fixed();
return value && make_node(AST_Binary, node, {
operator: node.operator.slice(0, -1),
left: make_node(AST_UnaryPrefix, node, {
operator: "+",
expression: fixed instanceof AST_Node ? fixed : fixed()
expression: value
}),
right: make_node(AST_Number, node, {
value: 1