authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:37:58 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:37:58 -07:00
log487fb89143d9f59d7d4c170e76fc6f996c7c1745
tree647e0fcea1d67613a6d5bab4795a5e76c2709b9b
parent5bd838ca3428a4ede13c5c5c94b36e7b93510bc2
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

more function logic cleanup


1 files changed, 5 insertions(+), 9 deletions(-)

src/lib.zig+5-9
......@@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
295295 }
296296 },
297297 .function => |v| {
298 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {
298 if (!v.raw) {
299 if (@hasDecl(opts.Ctx, "pek__" ++ v.name)) @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'");
299300 const func = @field(opts.Ctx, "pek_" ++ v.name);
300301 var list = std.Io.Writer.Allocating.init(alloc);
301302 defer list.deinit();
......@@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
307308 try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice());
308309 return;
309310 }
310 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {
311 if (v.raw) {
312 if (@hasDecl(opts.Ctx, "pek_" ++ v.name)) @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'");
311313 const func = @field(opts.Ctx, "pek__" ++ v.name);
312314 var list = std.Io.Writer.Allocating.init(alloc);
313315 defer list.deinit();
......@@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
326328 try writeReplacementString(writer, v.raw, opts.escaped, list.written());
327329 return;
328330 }
329 if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {
330 @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'");
331 }
332 if (!v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {
333 @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'");
334 }
335 @compileError("pek: unknown custom function: " ++ v.name);
331 comptime unreachable;
336332 },
337333 else => unreachable,
338334 }