| ... | @@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 295 | } | 295 | } |
| 296 | }, | 296 | }, |
| 297 | .function => |v| { | 297 | .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 ++ "}'"); |
| 299 | const func = @field(opts.Ctx, "pek_" ++ v.name); | 300 | const func = @field(opts.Ctx, "pek_" ++ v.name); |
| 300 | var list = std.Io.Writer.Allocating.init(alloc); | 301 | var list = std.Io.Writer.Allocating.init(alloc); |
| 301 | defer list.deinit(); | 302 | defer list.deinit(); |
| ... | @@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 307 | try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice()); | 308 | try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice()); |
| 308 | return; | 309 | return; |
| 309 | } | 310 | } |
| 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 ++ "}'"); |
| 311 | const func = @field(opts.Ctx, "pek__" ++ v.name); | 313 | const func = @field(opts.Ctx, "pek__" ++ v.name); |
| 312 | var list = std.Io.Writer.Allocating.init(alloc); | 314 | var list = std.Io.Writer.Allocating.init(alloc); |
| 313 | defer list.deinit(); | 315 | defer list.deinit(); |
| ... | @@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 326 | try writeReplacementString(writer, v.raw, opts.escaped, list.written()); | 328 | try writeReplacementString(writer, v.raw, opts.escaped, list.written()); |
| 327 | return; | 329 | return; |
| 328 | } | 330 | } |
| 329 | if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) { | 331 | comptime unreachable; |
| 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); | | |
| 336 | }, | 332 | }, |
| 337 | else => unreachable, | 333 | else => unreachable, |
| 338 | } | 334 | } |