fix parenthesis output of AST_ClassExpression (#2677)

fixes #2676
This commit is contained in:
Alex Lam S.L
2017-12-28 05:07:19 +08:00
committed by GitHub
parent 9f7d1f7ac6
commit 0a3fac6e68
2 changed files with 16 additions and 7 deletions

View File

@@ -730,15 +730,9 @@ function OutputStream(options) {
return p instanceof AST_PropAccess && p.expression === this; 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 // same goes for an object literal, because otherwise it would be
// interpreted as a block of code. // interpreted as a block of code.
PARENS(AST_Object, function(output){ PARENS([ AST_ClassExpression, AST_Object ], first_in_statement);
return first_in_statement(output);
});
PARENS(AST_Unary, function(output){ PARENS(AST_Unary, function(output){
var p = output.parent(); var p = output.parent();

View File

@@ -1197,3 +1197,18 @@ class_method_using_arguments: {
expect_stdout: "PASS" expect_stdout: "PASS"
node_version: ">=6" node_version: ">=6"
} }
issue_2676: {
options = {
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
class A {}
A.a = 42;
}
expect: {
(class {}).a = 42;
}
}