From 487fb89143d9f59d7d4c170e76fc6f996c7c1745 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 10 Jun 2026 01:37:58 -0700 Subject: [PATCH] more function logic cleanup --- src/lib.zig | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lib.zig b/src/lib.zig index 0c901ca043466dcc369b7bfbb8534bdbf5d8eea1..020c3528c203a5b7cac5d8170e4191bb2ed15e3a 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val } }, .function => |v| { - if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) { + if (!v.raw) { + if (@hasDecl(opts.Ctx, "pek__" ++ v.name)) @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'"); const func = @field(opts.Ctx, "pek_" ++ v.name); var list = std.Io.Writer.Allocating.init(alloc); defer list.deinit(); @@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice()); return; } - if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) { + if (v.raw) { + if (@hasDecl(opts.Ctx, "pek_" ++ v.name)) @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'"); const func = @field(opts.Ctx, "pek__" ++ v.name); var list = std.Io.Writer.Allocating.init(alloc); defer list.deinit(); @@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val try writeReplacementString(writer, v.raw, opts.escaped, list.written()); return; } - if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) { - @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'"); - } - if (!v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) { - @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'"); - } - @compileError("pek: unknown custom function: " ++ v.name); + comptime unreachable; }, else => unreachable, } -- 2.54.0