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

Unbound argument should not be counted if a method isn't called #86

Open
jishnub opened this issue Sep 9, 2022 · 3 comments
Open

Unbound argument should not be counted if a method isn't called #86

jishnub opened this issue Sep 9, 2022 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists test: unbound args

Comments

@jishnub
Copy link
Contributor

jishnub commented Sep 9, 2022

Let's say that I have a module

module abcd

f(::NTuple{N, T}) where {N,T} = (N,T)
f(::Tuple{}) = (0,Any)

end # module

Testing this using Aqua, I obtain

Unbound type parameters: Test Failed at /home/jishnu/.julia/packages/Aqua/HWLbM/src/unbound_args.jl:10
  Expression: detect_unbound_args_recursively(m) == []
   Evaluated: Any[f(::Tuple{Vararg{T, N}}) where {N, T} in abcd at /home/jishnu/Dropbox/JuliaPackages/abcd/src/abcd.jl:3] == Any[]
Stacktrace:
 [1] macro expansion
   @ ~/packages/julias/julia-1.8/share/julia/stdlib/v1.8/Test/src/Test.jl:464 [inlined]
 [2] test_unbound_args(m::Module)
   @ Aqua ~/.julia/packages/Aqua/HWLbM/src/unbound_args.jl:10

The issue seems to be with the T argument, and I think it's because in the N=0 case, T becomes an unbound argument in the first method. However, this method is not called in the N=0 case because the second method is more specific. Perhaps this should be ignored from the report?
The function calls are:

julia> abcd.f(())
(0, Any)

julia> abcd.f((1,))
(1, Int64)

If I'm missing something here, could someone please clarify this?

@SimonDanisch
Copy link

I think I'm running into something similar... Or at least I don't know how to fix:

Vec{N}(x::NTuple{N, T}) where {N, T} = Vec{N,T}(x)

@jishnub
Copy link
Contributor Author

jishnub commented Sep 15, 2022

This seems to pass:

struct Vec{N,T}
    x :: NTuple{N,T}
    function Vec{N,T}(x::NTuple{N,T}) where {N,T}
        new{N,T}(x)
    end
end
Vec{N}(x::NTuple{N}) where {N} = Vec{N,eltype(x)}(x)
Vec{0}(x::Tuple{}) = Vec{0,Any}(x)

@jakobnissen
Copy link
Contributor

Duplicate of JuliaLang/julia#28086 - since Aqua uses Test's function to detect them, this is an upstream issue

@lgoettgens lgoettgens added bug Something isn't working test: unbound args duplicate This issue or pull request already exists labels Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists test: unbound args
Projects
None yet
Development

No branches or pull requests

4 participants