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

Erroneous Unused Binding Errors

Open jrbaxter0 opened this issue 3 years ago • 2 comments

The linter is reporting Variable has been assigned but not used.Julia(UnusedBinding) for nearly every variable inside every function. Here’s an example: normal is very clearly used on the following line.

image

I was advised to disable the following setting: julia.lint.useoffuncargs, which I did, then restarted VSCode. This did not make a difference. The file is saved, not temprorary, and this has been observed with both the release and pre-release versions.

Appears related to: https://github.com/julia-vscode/julia-vscode/issues/2601 I originally brought this up on discourse: https://discourse.julialang.org/t/erroneous-unused-binding-errors/91324

jrbaxter0 avatar Dec 12 '22 02:12 jrbaxter0

Another recent example when using the julia repo: image The variable S is marked as unused.

jishnub avatar Aug 12 '24 11:08 jishnub

I have experienced this issue a lot, and I find that if I adjust the formatting to make sure there is a line ending right after the "unused" variable is defined, the linter corrects the display.

In the example above, I would go to the line S = eigtype(eltype(A)) and hit Enter after the last closing parenthesis.

After I make this kind of formatting adjustment, the linter correctly identifies the variable as used and I delete the extra blank line if I don't want them (sometimes I realise it makes the code look more readable and keep it).

I hope this information is helpful to you.

mpec-vrtalbot avatar Jul 02 '25 21:07 mpec-vrtalbot