fix class expression statements (#2051)
- class expression statements require parentheses - allow unused class expression statements to be dropped fixes #1782 closes #1784
This commit is contained in:
@@ -2610,6 +2610,7 @@ merge(Compressor.prototype, {
|
||||
def(AST_Accessor, return_null);
|
||||
def(AST_Function, return_null);
|
||||
def(AST_Arrow, return_null);
|
||||
def(AST_ClassExpression, return_null);
|
||||
def(AST_Binary, function(compressor, first_in_statement){
|
||||
var right = this.right.drop_side_effect_free(compressor);
|
||||
if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement);
|
||||
|
||||
@@ -642,6 +642,10 @@ function OutputStream(options) {
|
||||
return p instanceof AST_PropAccess && p.expression === this;
|
||||
});
|
||||
|
||||
PARENS(AST_ClassExpression, function(output){
|
||||
return output.parent() instanceof AST_SimpleStatement;
|
||||
});
|
||||
|
||||
// same goes for an object literal, because otherwise it would be
|
||||
// interpreted as a block of code.
|
||||
PARENS(AST_Object, function(output){
|
||||
|
||||
Reference in New Issue
Block a user