diff --git a/packages/bun-internal-test/src/banned.json b/packages/bun-internal-test/src/banned.json index d3df1c1a0772b0..92f96ecfbdd6f2 100644 --- a/packages/bun-internal-test/src/banned.json +++ b/packages/bun-internal-test/src/banned.json @@ -3,5 +3,9 @@ "@import(\"root\").bun.": "Only import 'bun' once", "std.mem.indexOfAny": "Use bun.strings.indexAny or bun.strings.indexAnyComptime", "std.debug.print": "Don't let this be committed", + " == undefined": "This is by definition Undefined Behavior.", + " != undefined": "This is by definition Undefined Behavior.", + "undefined == ": "This is by definition Undefined Behavior.", + "undefined != ": "This is by definition Undefined Behavior.", "": "" } diff --git a/src/bun.zig b/src/bun.zig index 100f524bafd1bd..024fdfaaee95a6 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -3101,6 +3101,16 @@ pub fn assert(value: bool) callconv(callconv_inline) void { } } +/// This has no effect on the real code but capturing 'a' and 'b' into parameters makes assertion failures much easier inspect in a debugger. +pub inline fn assert_eql(a: anytype, b: anytype) void { + return assert(a == b); +} + +/// This has no effect on the real code but capturing 'a' and 'b' into parameters makes assertion failures much easier inspect in a debugger. +pub inline fn assert_neql(a: anytype, b: anytype) void { + return assert(a != b); +} + pub inline fn unsafeAssert(condition: bool) void { if (!condition) { unreachable; diff --git a/src/install/semver.zig b/src/install/semver.zig index 84562dc2ea67aa..fb90aa78159192 100644 --- a/src/install/semver.zig +++ b/src/install/semver.zig @@ -47,22 +47,6 @@ pub const String = extern struct { }; } - pub inline fn init( - buf: string, - in: string, - ) String { - if (comptime Environment.isDebug) { - const out = realInit(buf, in); - if (!out.isInline()) { - assert(@as(u64, @bitCast(out.slice(buf)[0..8].*)) != undefined); - } - - return out; - } else { - return realInit(buf, in); - } - } - pub const Formatter = struct { str: *const String, buf: string, @@ -150,7 +134,7 @@ pub const String = extern struct { } }; - fn realInit( + pub fn init( buf: string, in: string, ) String {