From 5c160382cc504267b5112983710eebdd1bbe58c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gr=C3=A9goire?= Date: Sun, 13 Sep 2026 21:43:42 -0400 Subject: [PATCH] rtl: add custom assert --- src/rtl/root.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rtl/root.zig b/src/rtl/root.zig index 0071f99..a40f86f 100644 --- a/src/rtl/root.zig +++ b/src/rtl/root.zig @@ -84,6 +84,19 @@ pub fn assert_interface(T: type, I: type) void { } } +pub fn assert(condition: bool, comptime msg: []const u8, args: anytype) void { + if (!condition) { + @branchHint(.unlikely); + + switch (@import("builtin").mode) { + .ReleaseFast, .ReleaseSmall => unreachable, + .Debug, .ReleaseSafe => { + std.debug.panicExtra(@returnAddress(), "Assertion failed: " ++ msg, args); + }, + } + } +} + test { std.testing.refAllDecls(@This()); }