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
commit cea950fd70
Notes: sideshowbarker 2024-07-19 07:33:59 +09:00
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);