ziglang / vscode-zig

Zig language support for VSCode
https://marketplace.visualstudio.com/items?itemName=ziglang.vscode-zig
MIT License
556 stars 60 forks source link

Wrong Type Hintings #240

Open ayananerv opened 1 month ago

ayananerv commented 1 month ago

vscode-zig version:

Zig Language v0.5.9

Issues:

I want a pointer with type *usize, so I allocated some memory with ArenaAllocator,. It should give me a buffer with type []usize, but the hinted result is []u8:

image

image

Techatrix commented 1 month ago

This is probably caused by https://github.com/zigtools/zls/issues/1841

ayananerv commented 1 month ago

This is probably caused by zigtools/zls#1841

Wow you really nailed it!!!

My first allocated memory has a type of u8:

const buffer = try arena.alloc(u8, stat.size);

And the type deduction is u8

When I changed this line to const buffer = try arena.alloc(usize, stat.size);, all the left deductions are changed to usize!

I'm actually not familiar with vscode-zig and I just disabled zls in vscode a few days ago. It seems that this plugin depends on zls.