Closed
Description
hi.
This fails to compile:
export fn func() void {
inline for ([_]u8{1,2}) |phase| {
const S = struct {
val: if (phase == 1) u32 else [2]f32,
};
const s = S{.val = if (phase== 1) 1 else [2]f32{1,2} };
}
}
(with error: 6:57: error: array access of non-array type 'u32'
)
Looks like the second iteration tries to use the struct from the first iteration or something like this.
If I declare both structs before hand, it works:
export fn func2() void {
const S1 = struct {
val: u32,
};
const S2 = struct {
val: [2]f32,
};
inline for ([_]u8{1,2}) |phase| {
const S = if (phase == 1) S1 else S2;
const s = S{.val = if (phase== 1) 1 else [2]f32{1,2} };
}
}