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

Linter falsely reports unused assignment within @eval function #356

Open
cihga39871 opened this issue Jul 7, 2022 · 0 comments
Open

Linter falsely reports unused assignment within @eval function #356

cihga39871 opened this issue Jul 7, 2022 · 0 comments
Labels

Comments

@cihga39871
Copy link

cihga39871 commented Jul 7, 2022

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)

@davidanthoff davidanthoff transferred this issue from julia-vscode/julia-vscode Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants