summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Runtime/ScriptFunction.cpp2
-rw-r--r--Libraries/LibJS/Tests/arrow-functions.js7
2 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp
index 5828bcdde3..fddee25d2a 100644
--- a/Libraries/LibJS/Runtime/ScriptFunction.cpp
+++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp
@@ -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);
}
diff --git a/Libraries/LibJS/Tests/arrow-functions.js b/Libraries/LibJS/Tests/arrow-functions.js
index e224415ded..add2c0a6fc 100644
--- a/Libraries/LibJS/Tests/arrow-functions.js
+++ b/Libraries/LibJS/Tests/arrow-functions.js
@@ -81,6 +81,13 @@ try {
assert(Baz.prototype === undefined);
+ assertThrowsError(() => {
+ new Baz();
+ }, {
+ error: TypeError,
+ message: "Baz is not a constructor"
+ });
+
(() => {
"use strict";
assert(isStrictMode());