#unable to resolve comptime value

1 messages · Page 1 of 1 (latest)

exotic breach
#

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.

jaunty swallow
#

use or instead of ||

exotic breach
#

shiet, really?

tiny star
#

yes, really.

exotic breach
#

I was sure it was some little thing like that, thank you!

tiny star
#

|| is for capturing. Might be a good idea to read the language reference. Zig isn't language you came from.

little radish
exotic breach
#

I obviously read the reference, just can't remember all details.
As I said, thank you.