parent
4298201938
commit
dc575919e2
|
|
@ -5881,24 +5881,31 @@ merge(Compressor.prototype, {
|
||||||
if (!property) return expression;
|
if (!property) return expression;
|
||||||
return make_sequence(this, [ expression, property ]);
|
return make_sequence(this, [ expression, property ]);
|
||||||
});
|
});
|
||||||
def(AST_SymbolRef, function(compressor) {
|
function drop_symbol(ref) {
|
||||||
return this.is_declared(compressor) && all(this.definition().orig, function(sym) {
|
return all(ref.definition().orig, function(sym) {
|
||||||
return !(sym instanceof AST_SymbolConst);
|
return !(sym instanceof AST_SymbolConst);
|
||||||
}) ? null : this;
|
});
|
||||||
|
}
|
||||||
|
def(AST_SymbolRef, function(compressor) {
|
||||||
|
return this.is_declared(compressor) && drop_symbol(this) ? null : this;
|
||||||
});
|
});
|
||||||
def(AST_This, return_null);
|
def(AST_This, return_null);
|
||||||
def(AST_Unary, function(compressor, first_in_statement) {
|
def(AST_Unary, function(compressor, first_in_statement) {
|
||||||
|
var exp = this.expression;
|
||||||
if (unary_side_effects[this.operator]) {
|
if (unary_side_effects[this.operator]) {
|
||||||
this.write_only = !this.expression.has_side_effects(compressor);
|
this.write_only = !exp.has_side_effects(compressor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef) return null;
|
if (this.operator == "typeof" && exp instanceof AST_SymbolRef) {
|
||||||
var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
|
if (drop_symbol(exp)) return null;
|
||||||
if (first_in_statement && expression && is_iife_call(expression)) {
|
if (exp.is_declared(compressor)) return exp;
|
||||||
if (expression === this.expression && this.operator == "!") return this;
|
|
||||||
return expression.negate(compressor, first_in_statement);
|
|
||||||
}
|
}
|
||||||
return expression;
|
var node = exp.drop_side_effect_free(compressor, first_in_statement);
|
||||||
|
if (first_in_statement && node && is_iife_call(node)) {
|
||||||
|
if (node === exp && this.operator == "!") return this;
|
||||||
|
return node.negate(compressor, first_in_statement);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
});
|
});
|
||||||
})(function(node, func) {
|
})(function(node, func) {
|
||||||
node.DEFMETHOD("drop_side_effect_free", func);
|
node.DEFMETHOD("drop_side_effect_free", func);
|
||||||
|
|
|
||||||
|
|
@ -1134,3 +1134,20 @@ issue_4222: {
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4225: {
|
||||||
|
options = {
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
const a = void typeof b;
|
||||||
|
const b = 42;
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
const a = void b;
|
||||||
|
const b = 42;
|
||||||
|
console.log(a, b);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user