the issue
Code:
// Type your code here, or load an example.
const std = @import("std");
export fn main() void {
works();
//failsAtComptime();
}
fn works() void {
const test_cases = .{
[_]u8{},
[_]u8{0x01},
};
inline for (test_cases) |case| {
std.debug.print("{any}", .{&case});
}
}
// Differences described in comments
fn failsAtComptime() void {
// We instead make the test cases into a tupe *of tuples*...
const test_cases = .{
.{0, [_]u8{}},
.{1, [_]u8{0x01}},
};
inline for (test_cases) |case| {
// ...which is unpacked into the same values as in `works()`
std.debug.print("{any}", .{&case[1]});
}
}
Link to code on CompilerExplorer.
Specifically, the function works()
...works. And the function failsAtComptime()
fails to compile, with an error code (139 for zig version 0.10.0, and 133 for zig trunk as of posting) but no error message.
Notably, this works if I change the print values to the raw arrays case
/case[1]
, instead of the array pointers &case
/&case[1]
.
question
what's going wrong with failsAtComptime
? Is this a user error (me?), or a compiler issue, or an error with CompilerExplorer?