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

LibJS/Bytecode: Make construct Call throw if callee isn't a constructor

This commit is contained in:
Luke Wilde 2022-03-19 19:41:15 +00:00 committed by Andreas Kling
parent eac5534ce4
commit 096d2bb772

View file

@ -411,9 +411,13 @@ ThrowCompletionOr<void> JumpUndefined::execute_impl(Bytecode::Interpreter& inter
ThrowCompletionOr<void> Call::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto callee = interpreter.reg(m_callee);
if (!callee.is_function())
if (m_type == CallType::Call && !callee.is_function())
return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::IsNotA, callee.to_string_without_side_effects(), "function"sv);
if (m_type == CallType::Construct && !callee.is_constructor())
return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::IsNotA, callee.to_string_without_side_effects(), "constructor"sv);
auto& function = callee.as_function();
auto this_value = interpreter.reg(m_this_value);