mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibJS: Throw a TypeError when an arrow function is used as a constructor
This commit is contained in:
parent
1110b1b444
commit
3ffb0a4e87
Notes:
sideshowbarker
2024-07-19 05:58:18 +09:00
Author: https://github.com/jack-karamanian Commit: https://github.com/SerenityOS/serenity/commit/3ffb0a4e873 Pull-request: https://github.com/SerenityOS/serenity/pull/2454
2 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,13 @@ try {
|
|||
|
||||
assert(Baz.prototype === undefined);
|
||||
|
||||
assertThrowsError(() => {
|
||||
new Baz();
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Baz is not a constructor"
|
||||
});
|
||||
|
||||
(() => {
|
||||
"use strict";
|
||||
assert(isStrictMode());
|
||||
|
|
Loading…
Add table
Reference in a new issue