Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused variables should be detected by the language server #2016

Closed
maclong9 opened this issue Aug 29, 2024 · 2 comments
Closed

Unused variables should be detected by the language server #2016

maclong9 opened this issue Aug 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@maclong9
Copy link

Zig Version

0.13.0

ZLS Version

0.14.0-dev.135+b481aae

Client / Code Editor / Extensions

Helix Editor

Steps to Reproduce and Observed Behavior

print("defer means x inside the block is equal to\n", .{x});

The above when compiled returns the following error:

error: unused argument in 'defer means x inside the block is equal to
                                                                                    '
            1 => @compileError("unused argument in '" ++ fmt ++ "'"),
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    print__anon_2902: /Users/maclong/.local/share/mise/installs/zig/0.13.0/lib/std/io/Writer.zig:24:26
    print: /Users/maclong/.local/share/mise/installs/zig/0.13.0/lib/std/io.zig:324:47
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

It should be displayed in the editor before compiling.

Expected Behavior

Error should display as an error in editor so we can easily catch these errors before compilation.

Relevant log output

No response

@maclong9 maclong9 added the bug Something isn't working label Aug 29, 2024
@xdBronch
Copy link
Contributor

doing this is very hard if not effectively impossible, at least correctly. std.fmt relies heavily on comptime which zls doesnt support yet, its the same reason there arent proper type errors in general. in the meantime you can try the build_on_save feature, heres a nice article to get it setup https://kristoff.it/blog/improving-your-zls-experience/

@Techatrix
Copy link
Member

This issue is a very specific example of #2017 + #2018. There is no need to track this separately so I will be closing this.

@Techatrix Techatrix closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants