Hi All, I am trying to upgrade my zig installation from 0.13 to 0.14, and I am now getting error " initializer of comptime-only union ‘builtin.Type’ must be comptime-known" with the following code:
inline fn objTypeOf(comptime tp:type) type {
// construct a type with __obj_base plus the object
const ti = @typeInfo(tp);
comptime std.debug.assert(ti == .pointer);
const cti = @typeInfo(ti.pointer.child);
const objt = struct {
__obj_base:Object
};
const base_field = @typeInfo(objt).@"struct".fields;
const new_fields = [_]std.builtin.Type.StructField{base_field[0],
std.builtin.Type.StructField{
.name = "object",
.type = @Type(cti),
.alignment = @alignOf(tp),
.default_value_ptr = null,
.is_comptime = false
},
};
const new_type:std.builtin.Type = .{.@"struct" = std.builtin.Type.Struct {
.decls = &[_]std.builtin.Type.Declaration{},
.fields = &new_fields,
.layout = .auto,
.is_tuple = false,
.backing_integer = null
}};
return @Type(new_type);
}
it worked with 0.13 (with some field name differences), but I can’t figure out why with 0.14. any hints would be appreciated.