Linter falsely reports unused assignment within @eval function
cihga39871 opened this issue · 0 comments
cihga39871 commented
Julia Insider v1.6.26
Julia v1.7.2
@eval
makes the linter fail to detect which variable is used.
For example, copying the following code in vscode:
struct Job
x::Int
y::Int
end
@eval function Base.display(job::Job)
fs = $(fieldnames(Job))
fs_string = $(map(string, fieldnames(Job)))
max_byte = $(maximum(length, map(string, fieldnames(Job))))
println("Job:")
for (i,f) in enumerate(fs)
print(" ", f, " " ^ (max_byte - length(fs_string[i])), " → ")
display(getfield(job, f))
end
end
In vscode, linter hints fs
, fs_string
, max_bype
variables have been assigned but not used. Julia(UnusedBinding).
If we remove @eval
, linter can detect those variables are used. (But it does not hint ERROR: syntax: "$" expression outside quote)