fix corner case with parentheses around await (#4344)
This commit is contained in:
@@ -810,6 +810,16 @@ function OutputStream(options) {
|
|||||||
return needs_parens_assign_cond(this, output);
|
return needs_parens_assign_cond(this, output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
PARENS(AST_Await, function(output) {
|
||||||
|
var p = output.parent();
|
||||||
|
// new (await foo)
|
||||||
|
// (await foo)(bar)
|
||||||
|
if (p instanceof AST_Call) return p.expression === this;
|
||||||
|
// (await foo).prop
|
||||||
|
// (await foo)["prop"]
|
||||||
|
if (p instanceof AST_PropAccess) return p.expression === this;
|
||||||
|
});
|
||||||
|
|
||||||
/* -----[ PRINTERS ]----- */
|
/* -----[ PRINTERS ]----- */
|
||||||
|
|
||||||
DEFPRINT(AST_Directive, function(output) {
|
DEFPRINT(AST_Directive, function(output) {
|
||||||
|
|||||||
@@ -306,3 +306,25 @@ issue_4340: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=8"
|
node_version: ">=8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
call_expression: {
|
||||||
|
input: {
|
||||||
|
console.log(typeof async function(log) {
|
||||||
|
(await log)("FAIL");
|
||||||
|
}(console.log).then);
|
||||||
|
}
|
||||||
|
expect_exact: 'console.log(typeof async function(log){(await log)("FAIL")}(console.log).then);'
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|
||||||
|
property_access_expression: {
|
||||||
|
input: {
|
||||||
|
console.log(typeof async function(con) {
|
||||||
|
(await con).log("FAIL");
|
||||||
|
}(console).then);
|
||||||
|
}
|
||||||
|
expect_exact: 'console.log(typeof async function(con){(await con).log("FAIL")}(console).then);'
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=8"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user