1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 09:14:58 +00:00

LibJS: Support empty values in array expression

This commit is contained in:
Linus Groh 2020-04-15 20:09:06 +01:00 committed by Andreas Kling
parent d30db07048
commit cea950fd70
4 changed files with 44 additions and 10 deletions

View file

@ -473,9 +473,12 @@ NonnullRefPtr<ArrayExpression> Parser::parse_array_expression()
{
consume(TokenType::BracketOpen);
NonnullRefPtrVector<Expression> elements;
while (match_expression()) {
elements.append(parse_expression(0));
Vector<RefPtr<Expression>> elements;
while (match_expression() || match(TokenType::Comma)) {
RefPtr<Expression> expression;
if (match_expression())
expression = parse_expression(0);
elements.append(expression);
if (!match(TokenType::Comma))
break;
consume(TokenType::Comma);