-
-
Notifications
You must be signed in to change notification settings - Fork 396
Open
Labels
Description
ZLS fails to give type information when using MultiArrayList, here's an example:
const Foo = struct {
bar: usize,
baz: []const u8,
};
pub fn main() !void {
var structs = std.MultiArrayList(Foo).empty;
try structs.setCapacity(std.heap.page_allocator, 1);
defer structs.deinit(std.heap.page_allocator);
structs.appendAssumeCapacity(.{ .bar = 1, .baz = "first" });
const bar = structs.items(.bar)[0];
}
bar is an unknown type, also structs.items(<field name>) gives no suggestions. My understanding of why is that zls can't evaluate comptime code, but I would think that standard library code would be an exception, especially something like this which is generating an enum off of information that zls already has.
Maybe this hasn't been done yet because zig is still in early development, but it would be very useful.