1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00

LibJS: Allow "delete someGlobalVariable"

This is solved by allowing Identifier nodes to produce a Reference with
the global object as base.
This commit is contained in:
Andreas Kling 2020-04-27 12:37:27 +02:00
parent 67b8e6fc5b
commit 3c4a9e421f
6 changed files with 54 additions and 0 deletions

View file

@ -382,6 +382,11 @@ Reference Expression::to_reference(Interpreter&) const
return {};
}
Reference Identifier::to_reference(Interpreter& interpreter) const
{
return interpreter.get_reference(string());
}
Reference MemberExpression::to_reference(Interpreter& interpreter) const
{
auto object_value = m_object->execute(interpreter);
@ -404,6 +409,8 @@ Value UnaryExpression::execute(Interpreter& interpreter) const
return {};
if (reference.is_unresolvable())
return Value(true);
// FIXME: Support deleting locals
ASSERT(!reference.is_local_variable());
auto* base_object = reference.base().to_object(interpreter.heap());
if (!base_object)
return {};