vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

No in-editor warnings when using indexing on a bad type

Open grab-a-byte opened this issue 1 year ago • 8 comments

I'm trying to learn Zig and using VSCode for it, I'm using an array list and while I've figured out I need to use arrList.items[0] I'm still curious why i'm not getting the error in-editor before i compile it, this seems like a normal part of tooling and it is really making it difficult to learn the language.

image

Am I missing something here or is this not something that is implemented?

Thanks in advance.

grab-a-byte avatar Sep 13 '23 22:09 grab-a-byte

The buildOnSave option should handle this but it seems to be broken at the moment.

Vexu avatar Sep 14 '23 13:09 Vexu

I also faced similar problem warnings / errors aren't shown in VSCode. It worked only after enabling buildonsave option that I understood from below.

The buildOnSave option should handle this but it seems to be broken at the moment.

akhildevelops avatar Sep 15 '23 04:09 akhildevelops

Build on save seems o have fixed this but it also seems like a slightly sub-par experience. Having to save and wait for a build to do some type checking like that really slows down development iterations. Is there a reason it has to be build on save or it has to be built at all to get this kind of error showing in the editor?

grab-a-byte avatar Sep 15 '23 11:09 grab-a-byte

After enabling buildOnSave I get all warnings and errors without saving the file.

akhildevelops avatar Sep 15 '23 13:09 akhildevelops

@akhildevelops are you on linux or Mac? I'm on windows (something I probabaly should've mentioned earlier.)

grab-a-byte avatar Sep 15 '23 16:09 grab-a-byte

On Linux, why would that matter ?

akhildevelops avatar Sep 15 '23 17:09 akhildevelops

I just know sometimes tooling is worse on windows that other OS's which I've had experience before and could be something windows specific that means this setting isn't working for my setup. Just trying to narrow down possible causes.

grab-a-byte avatar Sep 16 '23 09:09 grab-a-byte

I just know sometimes tooling is worse on windows that other OS's which I've had experience before and could be something windows specific that means this setting isn't working for my setup. Just trying to narrow down possible causes.

Based on my experimentation, it's possible that you have zig.buildOnSave turned on. Actually you need to enable zig.zls.enableBuildOnSave to get the error message.

My English is not very good, the above is translated by Deelp.

ghost avatar Jun 01 '24 20:06 ghost