I'm having a "unable to resolve comptime value" on some code and I'm unable to reason what is the cause / solution.
I manage to produce a little example code that reproduces my issue: https://zigbin.io/b695ef
The code is quite simple, just passing around a struct and trying to call a method on it:
pub fn init(vertexShader: Shader, fragmentShader: Shader, allocator: std.mem.Allocator) Program {
if (!vertexShader.isValid() || !fragmentShader.isValid()) {
std.debug.panic("GPU: Failed to create program: Invalid shaders", .{});
}
if (vertexShader.stage() != VERTEX_SHADER or fragmentShader.stage() != FRAGMENT_SHADER) {
std.debug.panic("GPU: Failed to create program; Incorrect shader stages for graphics pipeline", .{});
}
// Some more code
return .{
.id = 3,
};
}
But that gives me the:
./example.zig:32:26: error: unable to resolve comptime value
if (!vertexShader.isValid() || !fragmentShader.isValid()) {
~~~~~~~~~~~~^~~~~~~~
./example.zig:32:13: note: types must be comptime-known
if (!vertexShader.isValid() || !fragmentShader.isValid()) {
^~~~~~~~~~~~~~~~~~~~~~~
My real code is more complex, it does some OpenGL calls here and there, but the example linked reproduces the issue.