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

LibJS: Ensure get_new_target() never returns an empty value

Also add spec comments and remove a redundant exception check while
we're here :^)
This commit is contained in:
Linus Groh 2021-12-28 23:50:23 +01:00
parent 8d70a50aed
commit 451149df0b
4 changed files with 17 additions and 12 deletions

View file

@ -347,8 +347,6 @@ Value SuperCall::execute(Interpreter& interpreter, GlobalObject& global_object)
// 1. Let newTarget be GetNewTarget().
auto new_target = vm.get_new_target();
if (vm.exception())
return {};
// 2. Assert: Type(newTarget) is Object.
VERIFY(new_target.is_function());
@ -2873,7 +2871,7 @@ Value MetaProperty::execute(Interpreter& interpreter, GlobalObject& global_objec
InterpreterNodeScope node_scope { interpreter, *this };
if (m_type == MetaProperty::Type::NewTarget)
return interpreter.vm().get_new_target().value_or(js_undefined());
return interpreter.vm().get_new_target();
if (m_type == MetaProperty::Type::ImportMeta) {
interpreter.vm().throw_exception<InternalError>(global_object, ErrorType::NotImplemented, "'import.meta' in modules");
return {};