1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:15:07 +00:00

LibJS: Throw a TypeError when an arrow function is used as a constructor

This commit is contained in:
Jack Karamanian 2020-05-30 00:16:42 -05:00 committed by Andreas Kling
parent 1110b1b444
commit 3ffb0a4e87
2 changed files with 9 additions and 0 deletions

View file

@ -125,6 +125,8 @@ Value ScriptFunction::call(Interpreter& interpreter)
Value ScriptFunction::construct(Interpreter& interpreter)
{
if (m_is_arrow_function)
return interpreter.throw_exception<TypeError>(String::format("%s is not a constructor", m_name.characters()));
return call(interpreter);
}