--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -1804,16 +1804,17 @@ class ASTSerializer
bool literal(ParseNode* pn, MutableHandleValue dst);
bool pattern(ParseNode* pn, MutableHandleValue dst);
bool arrayPattern(ParseNode* pn, MutableHandleValue dst);
bool objectPattern(ParseNode* pn, MutableHandleValue dst);
bool function(ParseNode* pn, ASTType type, MutableHandleValue dst);
bool functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
+ bool isAsync, bool isExpression,
MutableHandleValue body, MutableHandleValue rest);
bool functionBody(ParseNode* pn, TokenPos* pos, MutableHandleValue dst);
bool comprehensionBlock(ParseNode* pn, MutableHandleValue dst);
bool comprehensionIf(ParseNode* pn, MutableHandleValue dst);
bool comprehension(ParseNode* pn, MutableHandleValue dst);
bool generatorExpression(ParseNode* pn, MutableHandleValue dst);
@@ -3421,23 +3422,24 @@ ASTSerializer::function(ParseNode* pn, A
NodeVector args(cx);
NodeVector defaults(cx);
RootedValue body(cx), rest(cx);
if (func->hasRest())
rest.setUndefined();
else
rest.setNull();
- return functionArgsAndBody(pn->pn_body, args, defaults, &body, &rest) &&
+ return functionArgsAndBody(pn->pn_body, args, defaults, isAsync, isExpression, &body, &rest) &&
builder.function(type, &pn->pn_pos, id, args, defaults, body,
rest, generatorStyle, isAsync, isExpression, dst);
}
bool
ASTSerializer::functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
+ bool isAsync, bool isExpression,
MutableHandleValue body, MutableHandleValue rest)
{
ParseNode* pnargs;
ParseNode* pnbody;
/* Extract the args and body separately. */
if (pn->isKind(PNK_PARAMSBODY)) {
pnargs = pn;
@@ -3461,16 +3463,24 @@ ASTSerializer::functionArgsAndBody(Parse
ParseNode* pnstart = pnbody->pn_head;
// Skip over initial yield in generator.
if (pnstart && pnstart->isKind(PNK_YIELD)) {
MOZ_ASSERT(pnstart->getOp() == JSOP_INITIALYIELD);
pnstart = pnstart->pn_next;
}
+ // Async arrow with expression body is converted into STATEMENTLIST
+ // to insert initial yield.
+ if (isAsync && isExpression) {
+ MOZ_ASSERT(pnstart->getKind() == PNK_RETURN);
+ return functionArgs(pn, pnargs, args, defaults, rest) &&
+ expression(pnstart->pn_kid, body);
+ }
+
return functionArgs(pn, pnargs, args, defaults, rest) &&
functionBody(pnstart, &pnbody->pn_pos, body);
}
default:
LOCAL_NOT_REACHED("unexpected function contents");
}
}