From 2320d00ad34026c5df29c70ccfff65b443f2ed7f Mon Sep 17 00:00:00 2001 From: kzc Date: Thu, 29 Jun 2017 19:56:05 -0400 Subject: [PATCH] [ES8] async arrow function IIFE fix --- lib/output.js | 2 +- test/compress/async.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index 06ff762f..357ac82c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1039,11 +1039,11 @@ function OutputStream(options) { var needs_parens = parent instanceof AST_Binary || parent instanceof AST_Unary || (parent instanceof AST_Call && self === parent.expression); + if (needs_parens) { output.print("(") } if (self.async) { output.print("async"); output.space(); } - if (needs_parens) { output.print("(") } if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) { self.argnames[0].print(output); } else { diff --git a/test/compress/async.js b/test/compress/async.js index 7ffc1454..680ab94b 100644 --- a/test/compress/async.js +++ b/test/compress/async.js @@ -252,3 +252,12 @@ async_arrow_wait: { } expect_exact: "var a=async(x,y)=>await x(y);" } + +async_arrow_iife: { + input: { + (async () => { + await fetch({}); + })(); + } + expect_exact: "(async()=>{await fetch({})})();" +}