diff options
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/output.js b/lib/output.js index 9e704e8c..ae068462 100644 --- a/lib/output.js +++ b/lib/output.js @@ -692,7 +692,7 @@ function OutputStream(options) { // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ] return p instanceof AST_Array // () => (foo, bar) - || p instanceof AST_Arrow && p.value === this + || is_arrow(p) && p.value === this // await (foo, bar) || p instanceof AST_Await // 1 + (2, 3) + 4 ==> 8 @@ -813,6 +813,9 @@ function OutputStream(options) { // ({ p: a } = o); if (this.left instanceof AST_DestructuredObject) return needs_parens_obj(output); }); + PARENS(AST_AsyncArrow, function(output) { + return needs_parens_assign_cond(this, output); + }); PARENS(AST_Conditional, function(output) { return needs_parens_assign_cond(this, output); }); @@ -1005,8 +1008,7 @@ function OutputStream(options) { } }); } - DEFPRINT(AST_Arrow, function(output) { - var self = this; + function print_arrow(self, output) { if (self.argnames.length == 1 && self.argnames[0] instanceof AST_SymbolFunarg && !self.rest) { self.argnames[0].print(output); } else { @@ -1020,6 +1022,14 @@ function OutputStream(options) { } else { print_braced(self, output, true); } + } + DEFPRINT(AST_Arrow, function(output) { + print_arrow(this, output); + }); + DEFPRINT(AST_AsyncArrow, function(output) { + output.print("async"); + output.space(); + print_arrow(this, output); }); function print_lambda(self, output) { if (self.name) { @@ -1207,7 +1217,7 @@ function OutputStream(options) { if (noin) node.walk(new TreeWalker(function(node) { if (parens) return true; if (node instanceof AST_Binary && node.operator == "in") return parens = true; - if (node instanceof AST_Scope && !(node instanceof AST_Arrow && node.value)) return true; + if (node instanceof AST_Scope && !(is_arrow(node) && node.value)) return true; })); node.print(output, parens); } |