Fix arrow function body parsing precedence (#546)

This commit is contained in:
Daniel Wirtz 2019-03-18 17:11:02 +01:00 committed by GitHub
parent fd99589527
commit 858cca5a38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1437,9 +1437,14 @@ export class Parser extends DiagnosticEmitter {
tn.range(signatureStart, tn.pos)
);
var body: Statement | null;
var body: Statement | null = null;
if (arrowKind) {
body = this.parseStatement(tn, false);
if (tn.skip(Token.OPENBRACE)) {
body = this.parseBlockStatement(tn, false);
} else {
let bodyExpression = this.parseExpression(tn, Precedence.COMMA + 1);
if (bodyExpression) body = Node.createExpressionStatement(bodyExpression);
}
} else {
if (!tn.skip(Token.OPENBRACE)) {
this.error(