aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-05-10 09:35:03 +0100
committerGitHub <noreply@github.com>2020-05-10 16:35:03 +0800
commit33f3b0c1d9654e137b54802afbfb6d8e70c8cbd6 (patch)
treeb12bd4c6ccecbd4271c98afc22e6537dfcc0ef38 /lib/compress.js
parentabb8ae02a55b3e3585685362cbae99c6b7a9a380 (diff)
downloadtracifyjs-33f3b0c1d9654e137b54802afbfb6d8e70c8cbd6.tar.gz
tracifyjs-33f3b0c1d9654e137b54802afbfb6d8e70c8cbd6.zip
fix corner case in `reduce_vars` (#3867)
fixes #3866
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index fb4836bf..6e0d36a7 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -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