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

Incorrect linter output in @eval block #3565

Open
schillic opened this issue Mar 13, 2024 · 0 comments
Open

Incorrect linter output in @eval block #3565

schillic opened this issue Mar 13, 2024 · 0 comments

Comments

@schillic
Copy link

Below are two MWEs to provoke wrong linter outputs related to (wrongly claimed) undefined variables in @eval blocks. They may or may not have the same source.

UnusedBinding

The following example provokes the linter report Variable has been assigned but not used.Julia(UnusedBinding).

module Example

@eval begin
    function foo(i)
        x = i  # UnusedBinding warning for x here
        x
    end
end

end

InvalidRedefofConst

The following more involved example provokes the linter report Invalid redefinition of constant.Julia(InvalidRedefofConst). Note that the following peculiarities are necessary for the situation to appear:

  • The struct needs to have the type parameter.
  • The constructor must be defined.
module Example

struct Foo{T}
    a::T

    function Foo(a::T) where T
        new{T}(a)
    end
end

@eval begin
    function foo(i)  # InvalidRedefofConst warning for i here
        Foo(i)
    end
end

end

x-ref #2601 #3171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants