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
const builtin = @import("builtin");
fn find(comptime T: type) ?*T {
return null;
}
fn generic(comptime SelfType: type) void {
inline for (@typeInfo(SelfType).Struct.fields) |field| {
comptime const ComponentType = @typeInfo(field.field_type).Pointer.child;
// this line seems to be causing the crash
const maybe_component = find(ComponentType);
// it works fine if i use this in an expression. only assigning it to a
// variable fails
// if (find(ComponentType) != null) {}
}
}
const A = struct{ unused: u32 };
const B = struct{ unused: u32 };
const Data = struct{
// works if both fields are the same time!
one: *A,
two: *B,
};
test "" {
generic(Data);
}
Getting an error when trying to read nested struct typeInfo:
zig: /home/bheads/zig/src/codegen.cpp:2813: LLVMOpaqueValue* ir_render_decl_var(CodeGen*, IrExecutable*, IrInstructionDeclVar*): Assertion `var->value->type == init_value->value.type' failed.
The text was updated successfully, but these errors were encountered: