Fix unneeded parens around unary args in new expression.
This commit is contained in:
@@ -533,7 +533,7 @@ function OutputStream(options) {
|
|||||||
PARENS([ AST_Unary, AST_Undefined ], function(output){
|
PARENS([ AST_Unary, AST_Undefined ], function(output){
|
||||||
var p = output.parent();
|
var p = output.parent();
|
||||||
return p instanceof AST_PropAccess && p.expression === this
|
return p instanceof AST_PropAccess && p.expression === this
|
||||||
|| p instanceof AST_New;
|
|| p instanceof AST_Call && p.expression === this;
|
||||||
});
|
});
|
||||||
|
|
||||||
PARENS(AST_Seq, function(output){
|
PARENS(AST_Seq, function(output){
|
||||||
|
|||||||
@@ -50,3 +50,28 @@ new_with_many_parameters: {
|
|||||||
}
|
}
|
||||||
expect_exact: 'new foo.bar("baz");new x(/123/,456);'
|
expect_exact: 'new foo.bar("baz");new x(/123/,456);'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_constructor_with_unary_arguments: {
|
||||||
|
input: {
|
||||||
|
new x();
|
||||||
|
new x(-1);
|
||||||
|
new x(-1, -2);
|
||||||
|
new x(void 1, +2, -3, ~4, !5, --a, ++b, c--, d++, typeof e, delete f);
|
||||||
|
new (-1); // should parse despite being invalid at runtime.
|
||||||
|
new (-1)(); // should parse despite being invalid at runtime.
|
||||||
|
new (-1)(-2); // should parse despite being invalid at runtime.
|
||||||
|
}
|
||||||
|
expect_exact: "new x;new x(-1);new x(-1,-2);new x(void 1,+2,-3,~4,!5,--a,++b,c--,d++,typeof e,delete f);new(-1);new(-1);new(-1)(-2);"
|
||||||
|
}
|
||||||
|
|
||||||
|
call_with_unary_arguments: {
|
||||||
|
input: {
|
||||||
|
x();
|
||||||
|
x(-1);
|
||||||
|
x(-1, -2);
|
||||||
|
x(void 1, +2, -3, ~4, !5, --a, ++b, c--, d++, typeof e, delete f);
|
||||||
|
(-1)(); // should parse despite being invalid at runtime.
|
||||||
|
(-1)(-2); // should parse despite being invalid at runtime.
|
||||||
|
}
|
||||||
|
expect_exact: "x();x(-1);x(-1,-2);x(void 1,+2,-3,~4,!5,--a,++b,c--,d++,typeof e,delete f);(-1)();(-1)(-2);"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user