mirror of
https://github.com/oven-sh/bun
synced 2026-02-28 12:31:00 +01:00
Fix 6281 (#6809)
* throw an error when `Script` is called without new fix https://github.com/oven-sh/bun/issues/6281 * fix typo in `File` without constructor error fix https://github.com/oven-sh/bun/issues/6281
This commit is contained in:
@@ -111,6 +111,11 @@ constructScript(JSGlobalObject* globalObject, CallFrame* callFrame, JSValue newT
|
||||
if (UNLIKELY(zigGlobalObject->NodeVMScript() != newTarget)) {
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
JSObject* targetObj = asObject(newTarget);
|
||||
if (targetObj == nullptr) {
|
||||
throwTypeError(globalObject, scope, "Class constructor Script cannot be invoked without 'new'"_s);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto* functionGlobalObject = reinterpret_cast<Zig::GlobalObject*>(getFunctionRealm(globalObject, targetObj));
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
structure = InternalFunction::createSubclassStructure(
|
||||
|
||||
Reference in New Issue
Block a user