mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-19 00:31:52 +00:00
LibJS: Support empty values in array expression
This commit is contained in:
parent
d30db07048
commit
cea950fd70
Notes:
sideshowbarker
2024-07-19 07:33:59 +09:00
Author: https://github.com/linusg
Commit: cea950fd70
Pull-request: https://github.com/SerenityOS/serenity/pull/1812
4 changed files with 44 additions and 10 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue