From db8c0744767b3d472f9682827a312a8ffed74adf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 26 Sep 2024 16:46:02 -0700 Subject: [PATCH] fix still calling std.builtin.panic sometimes --- lib/std/builtin.zig | 2 +- src/Sema.zig | 2 +- src/Zcu.zig | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 67a144eebf..664a45f12b 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -770,7 +770,7 @@ pub const panic: PanicFn = if (@hasDecl(root, "panic")) else if (@hasDecl(root, "os") and @hasDecl(root.os, "panic")) root.os.panic else - std.debug.defaultPanic; + Panic.call; /// This namespace is used by the Zig compiler to emit various kinds of safety /// panics. These can be overridden by making a public `Panic` namespace in the diff --git a/src/Sema.zig b/src/Sema.zig index 0f4c3bedbe..31da83f344 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -27639,7 +27639,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void { const zcu = pt.zcu; if (zcu.panic_func_index == .none) { - const fn_ref = try sema.analyzeNavVal(block, src, try pt.getBuiltinNav("panic")); + const fn_ref = try sema.getBuiltinInnerAsInst(block, src, "Panic", "call"); const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{ .needed_comptime_reason = "panic handler must be comptime-known", }); diff --git a/src/Zcu.zig b/src/Zcu.zig index 827c4cca84..2a52bf4bcf 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -2918,8 +2918,9 @@ pub fn addGlobalAssembly(zcu: *Zcu, cau: InternPool.Cau.Index, source: []const u } pub const Feature = enum { - /// When this feature is enabled, Sema will emit calls to `std.builtin.panic` - /// for things like safety checks and unreachables. Otherwise traps will be emitted. + /// When this feature is enabled, Sema will emit calls to + /// `std.builtin.Panic` functions for things like safety checks and + /// unreachables. Otherwise traps will be emitted. panic_fn, /// When this feature is enabled, Sema will insert tracer functions for gathering a stack /// trace for error returns.