zls icon indicating copy to clipboard operation
zls copied to clipboard

Comptime Enum Auto complete not working

Open SOG-web opened this issue 1 month ago • 0 comments

fn BuildFieldEnum(comptime T: type) type {
    const fields = @typeInfo(T).@"struct".fields;
    var enum_fields: [fields.len]std.builtin.Type.EnumField = undefined;

    inline for (fields, 0..) |field, i| {
        enum_fields[i] = .{
            .name = field.name,
            .value = i,
        };
    }

    return @Type(.{ .@"enum" = .{
        .decls = &.{},
        .tag_type = u32,
        .fields = &enum_fields,
        .is_exhaustive = true,
    } });
}
const User = struct {
        id: i64,
        name: []const u8,

        pub fn tableName() []const u8 {
            return "users";
        }
    };
const UserField = BuildFieldEnum(User);

UserField is showing (unknown type)

zig version 0.15.1

SOG-web avatar Nov 25 '25 00:11 SOG-web