1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +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

@ -497,9 +497,14 @@ String VM::join_arguments(size_t start_index) const
return joined_arguments.build();
}
// 9.4.5 GetNewTarget ( ), https://tc39.es/ecma262/#sec-getnewtarget
Value VM::get_new_target()
{
// 1. Let envRec be GetThisEnvironment().
auto& env = get_this_environment(*this);
// 2. Assert: envRec has a [[NewTarget]] field.
// 3. Return envRec.[[NewTarget]].
return verify_cast<FunctionEnvironment>(env).new_target();
}