JavaScript: Accept let expressions with an object literal as their body.

This commit is contained in:
Max Schaefer
2019-01-29 15:57:05 +00:00
parent 63ed569724
commit dbbb961b48
3 changed files with 642 additions and 348 deletions

View File

@@ -196,8 +196,12 @@ public class CustomParser extends FlowParser {
this.expect(TokenType.parenR);
if (this.type == TokenType.braceL) {
if (!maybeStatement)
this.unexpected();
if (!maybeStatement) {
// must be the start of an object literal
Expression body = this.parseObj(false, null);
return this.finishNode(new LetExpression(new SourceLocation(startLoc), decl.getDeclarations(), body));
}
BlockStatement body = this.parseBlock(false);
return this.finishNode(new LetStatement(new SourceLocation(startLoc), decl.getDeclarations(), body));
} else if (maybeStatement) {

View File

@@ -2,4 +2,6 @@ var x = 42, y = 19;
console.log(let (x = 23, y = 19) x + y);
console.log(x - y);
console.log(x - y);
JSON.stringify(let (x = 23, y = 19) { x: x, y: y});