1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibJS: Ensure GetBy{Id,Value} never load <empty> into the accumulator

This commit is contained in:
Matthew Olsson 2021-06-13 08:50:05 -07:00 committed by Andreas Kling
parent ce04c2259f
commit 3ee627909a

View file

@ -151,7 +151,7 @@ void SetVariable::execute_impl(Bytecode::Interpreter& interpreter) const
void GetById::execute_impl(Bytecode::Interpreter& interpreter) const void GetById::execute_impl(Bytecode::Interpreter& interpreter) const
{ {
if (auto* object = interpreter.accumulator().to_object(interpreter.global_object())) if (auto* object = interpreter.accumulator().to_object(interpreter.global_object()))
interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)); interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)).value_or(js_undefined());
} }
void PutById::execute_impl(Bytecode::Interpreter& interpreter) const void PutById::execute_impl(Bytecode::Interpreter& interpreter) const
@ -328,7 +328,7 @@ void GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const
auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object()); auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object());
if (interpreter.vm().exception()) if (interpreter.vm().exception())
return; return;
interpreter.accumulator() = object->get(property_key); interpreter.accumulator() = object->get(property_key).value_or(js_undefined());
} }
} }