better extends paren fix (#1962)
This commit is contained in:
@@ -644,7 +644,6 @@ function OutputStream(options) {
|
|||||||
* ==> 20 (side effect, set a := 10 and b := 20) */
|
* ==> 20 (side effect, set a := 10 and b := 20) */
|
||||||
|| p instanceof AST_Arrow // x => (x, x)
|
|| p instanceof AST_Arrow // x => (x, x)
|
||||||
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
|| p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
|
||||||
|| (p instanceof AST_Class && p.extends === this) // class D extends (calls++, C) {}
|
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1474,8 +1473,12 @@ function OutputStream(options) {
|
|||||||
output.space();
|
output.space();
|
||||||
}
|
}
|
||||||
if (self.extends) {
|
if (self.extends) {
|
||||||
var parens = self.extends instanceof AST_Binary ||
|
var parens = (
|
||||||
self.extends instanceof AST_Conditional;
|
!(self.extends instanceof AST_SymbolRef)
|
||||||
|
&& !(self.extends instanceof AST_PropAccess)
|
||||||
|
&& !(self.extends instanceof AST_ClassExpression)
|
||||||
|
&& !(self.extends instanceof AST_Function)
|
||||||
|
);
|
||||||
output.print("extends");
|
output.print("extends");
|
||||||
if (parens) {
|
if (parens) {
|
||||||
output.print("(");
|
output.print("(");
|
||||||
|
|||||||
@@ -534,14 +534,52 @@ issue_1753_disable: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class_extends_expression: {
|
class_extends: {
|
||||||
options = {
|
options = {
|
||||||
evaluate: true
|
evaluate: true,
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
|
function f() {
|
||||||
|
class foo extends bar {}
|
||||||
|
class pro extends some.prop {}
|
||||||
|
class arr extends stuff[1 - 1] {}
|
||||||
class bin extends (a || b) {}
|
class bin extends (a || b) {}
|
||||||
class seq extends (a, b) {}
|
class seq extends (a, b) {}
|
||||||
class ter extends (a ? b : c) {}
|
class ter extends (a ? b : c) {}
|
||||||
|
class uni extends (!0) {}
|
||||||
}
|
}
|
||||||
expect_exact: "class bin extends(a||b){}class seq extends(a,b){}class ter extends(a?b:c){}"
|
}
|
||||||
|
expect_exact: "function f(){class foo extends bar{}class pro extends some.prop{}class arr extends stuff[0]{}class bin extends(a||b){}class seq extends(a,b){}class ter extends(a?b:c){}class uni extends(!0){}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
class_extends_class: {
|
||||||
|
options = {
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class anon extends class {} {}
|
||||||
|
class named extends class base {} {}
|
||||||
|
}
|
||||||
|
expect_exact: "class anon extends class{}{}class named extends class base{}{}"
|
||||||
|
}
|
||||||
|
|
||||||
|
class_extends_function: {
|
||||||
|
options = {
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
class anon extends function(){} {}
|
||||||
|
class named extends function base(){} {}
|
||||||
|
}
|
||||||
|
expect_exact: "class anon extends function(){}{}class named extends function base(){}{}"
|
||||||
|
}
|
||||||
|
|
||||||
|
class_extends_regex: {
|
||||||
|
options = {
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
class rx1 extends (/rx/) {}
|
||||||
|
// class rx2 extends /rx/ {} // FIXME - parse error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_exact: "function f(){class rx1 extends(/rx/){}}"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user