Merge pull request #1316 from lightpanda-io/reject_non_new_constructor

Reject constructors called as function (i.e. without 'new')
This commit is contained in:
Karl Seguin
2026-01-07 07:14:13 +08:00
committed by GitHub
4 changed files with 8 additions and 4 deletions

View File

@@ -89,6 +89,10 @@ pub const CallOpts = struct {
};
pub fn constructor(self: *Caller, comptime T: type, func: anytype, info: v8.FunctionCallbackInfo, comptime opts: CallOpts) void {
if (!info.isConstructCall()) {
self.handleError(T, @TypeOf(func), error.InvalidArgument, info, opts);
return;
}
self._constructor(func, info) catch |err| {
self.handleError(T, @TypeOf(func), err, info, opts);
};