fix corner case in sequences (#3350)
This commit is contained in:
@@ -4080,12 +4080,10 @@ merge(Compressor.prototype, {
|
|||||||
def(AST_ObjectProperty, function(compressor, first_in_statement) {
|
def(AST_ObjectProperty, function(compressor, first_in_statement) {
|
||||||
return this.value.drop_side_effect_free(compressor, first_in_statement);
|
return this.value.drop_side_effect_free(compressor, first_in_statement);
|
||||||
});
|
});
|
||||||
def(AST_Sequence, function(compressor) {
|
def(AST_Sequence, function(compressor, first_in_statement) {
|
||||||
var last = this.tail_node();
|
var expressions = trim(this.expressions, compressor, first_in_statement);
|
||||||
var expr = last.drop_side_effect_free(compressor);
|
if (expressions === this.expressions) return this;
|
||||||
if (expr === last) return this;
|
if (!expressions) return null;
|
||||||
var expressions = this.expressions.slice(0, -1);
|
|
||||||
if (expr) expressions.push(expr);
|
|
||||||
return make_sequence(this, expressions);
|
return make_sequence(this, expressions);
|
||||||
});
|
});
|
||||||
def(AST_Sub, function(compressor, first_in_statement) {
|
def(AST_Sub, function(compressor, first_in_statement) {
|
||||||
|
|||||||
@@ -924,14 +924,14 @@ call: {
|
|||||||
b.c = function() {
|
b.c = function() {
|
||||||
console.log(this === b ? "bar" : "baz");
|
console.log(this === b ? "bar" : "baz");
|
||||||
},
|
},
|
||||||
a, b(),
|
b(),
|
||||||
(a, b.c)(),
|
(a, b.c)(),
|
||||||
a, function() {
|
function() {
|
||||||
console.log(this === a);
|
console.log(this === a);
|
||||||
}(),
|
}(),
|
||||||
a, new b(),
|
new b(),
|
||||||
a, new b.c(),
|
new b.c(),
|
||||||
a, new function() {
|
new function() {
|
||||||
console.log(this === a);
|
console.log(this === a);
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
@@ -944,3 +944,23 @@ call: {
|
|||||||
"false",
|
"false",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
missing_link: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
sequences: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 100;
|
||||||
|
a;
|
||||||
|
a++ + (0 ? 2 : 1);
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 100;
|
||||||
|
a,
|
||||||
|
a++,
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user