You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using a 2d-array lookup table produces error: runtime value contains reference to comptime var #25319
$ zig-debug run test.zig
test.zig:10:17: error: runtime value contains reference to comptime var
_ = lookupTable[runtimeValue][runtimeValue];
~~~~~~~~~~~^~~~~~~~~~~~~~
test.zig:10:17: note: comptime var pointers are not available at runtime
test.zig:4:11: note: 'runtime_value' points to comptime var declared here
comptime var lookupTable: [32][32]u8 = @splat(@splat(0));
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
callMain [inlined]: /home/mint/zig/zig-out/lib/zig/std/start.zig:618:22
callMainWithArgs [inlined]: /home/mint/zig/zig-out/lib/zig/std/start.zig:587:20
posixCallMainAndExit: /home/mint/zig/zig-out/lib/zig/std/start.zig:542:36
2 reference(s) hidden; use '-freference-trace=5' to see all references
This does not happen with one-dimensional arrays.
Expected Behavior
It used to work in older zig versions (0.16.0-dev.321+3cc0fc601), so I assume this regressed in #25154.
I assume it was an unintentional change, since it wasn't mentioned in the migration guide.
Activity
xdBronch commentedon Sep 21, 2025
i do believe this is intentional, it was mentioned in the original pr #25138 (comment)
in essence, these pieces of code are equivalent
this should definitely be mentioned in the upgrade guide
this i am not sure of though, that part may be a bug?