summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.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/AST.cpp
parentd30db070480359ded01282942483930ba2c7f3ee (diff)
downloadserenity-cea950fd701e98de073e37a4476fc5ca1719dee0.zip
LibJS: Support empty values in array expression
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r--Libraries/LibJS/AST.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index 199567a5f6..f6a2910bb2 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -973,7 +973,12 @@ void ArrayExpression::dump(int indent) const
{
ASTNode::dump(indent);
for (auto& element : m_elements) {
- element.dump(indent + 1);
+ if (element) {
+ element->dump(indent + 1);
+ } else {
+ print_indent(indent + 1);
+ printf("<empty>\n");
+ }
}
}
@@ -981,9 +986,12 @@ Value ArrayExpression::execute(Interpreter& interpreter) const
{
auto* array = interpreter.heap().allocate<Array>();
for (auto& element : m_elements) {
- auto value = element.execute(interpreter);
- if (interpreter.exception())
- return {};
+ auto value = Value();
+ if (element) {
+ value = element->execute(interpreter);
+ if (interpreter.exception())
+ return {};
+ }
array->elements().append(value);
}
return array;