summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Parser.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-15 20:09:06 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-15 21:23:06 +0200
commitcea950fd701e98de073e37a4476fc5ca1719dee0 (patch)
treed803ff44bc48a56332990f93959779358b72ae05 /Libraries/LibJS/Parser.cpp
parentd30db070480359ded01282942483930ba2c7f3ee (diff)
downloadserenity-cea950fd701e98de073e37a4476fc5ca1719dee0.zip
LibJS: Support empty values in array expression
Diffstat (limited to 'Libraries/LibJS/Parser.cpp')
-rw-r--r--Libraries/LibJS/Parser.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp
index c04b189cc5..015e0e0d46 100644
--- a/Libraries/LibJS/Parser.cpp
+++ b/Libraries/LibJS/Parser.cpp
@@ -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);