summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-03-30 13:41:17 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-30 14:43:58 +0200
commitfb0401871cdd5613500a45493ea697adaf6fa1df (patch)
tree6299058a556d2a96276e9a7d815c29256b2ec637 /Libraries/LibJS/AST.cpp
parentd4e3688f4f5338ce5995a4c9bcce1e0bb961845f (diff)
downloadserenity-fb0401871cdd5613500a45493ea697adaf6fa1df.zip
LibJS: Throw TypeError when calling non-function object
We now have "undefined is not a function" :^)
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r--Libraries/LibJS/AST.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index b3daa4eb3b..a20b90d028 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -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();