mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Throw TypeError when calling non-function object
We now have "undefined is not a function" :^)
This commit is contained in:
committed by
Andreas Kling
parent
d4e3688f4f
commit
fb0401871c
@@ -66,8 +66,9 @@ Value CallExpression::execute(Interpreter& interpreter) const
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
|
||||
ASSERT(callee.is_object());
|
||||
ASSERT(callee.as_object()->is_function());
|
||||
if (!callee.is_object() || !callee.as_object()->is_function())
|
||||
return interpreter.throw_exception<Error>("TypeError", String::format("%s is not a function", callee.to_string().characters()));
|
||||
|
||||
auto* function = static_cast<Function*>(callee.as_object());
|
||||
|
||||
auto& call_frame = interpreter.push_call_frame();
|
||||
|
||||
Reference in New Issue
Block a user