Closed alexsch01 closed 2 months ago
What is tripping up your code here is the fact that function calls, like std.mem.startsWith
and std.mem.endsWith
in your if
condition, are by default evaluated at runtime, even if all arguments are comptime-known.
You have to force comptime evaluation using the comptime
unary operator: if (comptime (std.mem.startsWith(u8, typeName, "*const [") and std.mem.endsWith(u8, typeName, ":0]u8"))) { ... }
.
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
/usr/lib/zig/std/fmt.zig:471:5: error: invalid format string 's' for type 'comptime_int' (exit status 1)
Expected Behavior
Hello World 123