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:
kzc
2017-06-03 14:45:26 -04:00
committed by Alex Lam S.L
parent 753932b302
commit 82fefc5d29
3 changed files with 50 additions and 0 deletions

View File

@@ -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){