safety: a lot more exception checker progress (#20817)

This commit is contained in:
Meghan Denny
2025-07-10 14:34:51 -08:00
committed by GitHub
parent c6bce38ead
commit 6c5b863530
107 changed files with 967 additions and 2209 deletions

View File

@@ -841,17 +841,17 @@ pub const String = extern struct {
extern fn BunString__toWTFString(this: *String) void;
extern fn BunString__createUTF8ForJS(globalObject: *JSC.JSGlobalObject, ptr: [*]const u8, len: usize) JSC.JSValue;
pub fn createUTF8ForJS(globalObject: *JSC.JSGlobalObject, utf8_slice: []const u8) JSC.JSValue {
pub fn createUTF8ForJS(globalObject: *JSC.JSGlobalObject, utf8_slice: []const u8) bun.JSError!JSC.JSValue {
JSC.markBinding(@src());
return BunString__createUTF8ForJS(globalObject, utf8_slice.ptr, utf8_slice.len);
return bun.jsc.fromJSHostCall(globalObject, @src(), BunString__createUTF8ForJS, .{ globalObject, utf8_slice.ptr, utf8_slice.len });
}
pub fn createFormatForJS(globalObject: *JSC.JSGlobalObject, comptime fmt: [:0]const u8, args: anytype) JSC.JSValue {
pub fn createFormatForJS(globalObject: *JSC.JSGlobalObject, comptime fmt: [:0]const u8, args: anytype) bun.JSError!JSC.JSValue {
JSC.markBinding(@src());
var builder = std.ArrayList(u8).init(bun.default_allocator);
defer builder.deinit();
builder.writer().print(fmt, args) catch bun.outOfMemory();
return BunString__createUTF8ForJS(globalObject, builder.items.ptr, builder.items.len);
return bun.jsc.fromJSHostCall(globalObject, @src(), BunString__createUTF8ForJS, .{ globalObject, builder.items.ptr, builder.items.len });
}
pub fn parseDate(this: *String, globalObject: *JSC.JSGlobalObject) f64 {
@@ -1217,15 +1217,15 @@ pub const SliceWithUnderlyingString = struct {
try writer.writeAll(self.utf8.slice());
}
pub fn toJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
pub fn toJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) bun.JSError!JSC.JSValue {
return this.toJSWithOptions(globalObject, false);
}
pub fn transferToJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
pub fn transferToJS(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject) bun.JSError!JSC.JSValue {
return this.toJSWithOptions(globalObject, true);
}
fn toJSWithOptions(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject, transfer: bool) JSC.JSValue {
fn toJSWithOptions(this: *SliceWithUnderlyingString, globalObject: *JSC.JSGlobalObject, transfer: bool) bun.JSError!JSC.JSValue {
if ((this.underlying.tag == .Dead or this.underlying.tag == .Empty) and this.utf8.length() > 0) {
if (comptime bun.Environment.allow_assert) {
if (this.utf8.allocator.get()) |allocator| {