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

false positive unbound type parameter in constructor #325

Closed
tpapp opened this issue Feb 26, 2025 · 2 comments
Closed

false positive unbound type parameter in constructor #325

tpapp opened this issue Feb 26, 2025 · 2 comments
Labels
invalid This doesn't seem right test: unbound args

Comments

@tpapp
Copy link

tpapp commented Feb 26, 2025

MWE

module Foo

using StaticArrays

struct Tangent{T}
    location::T
    slope::T
end

struct ScaledProblem{N,TA<:Real,TE<:Real}
    a::SVector{N,TA}
    ϵ::SVector{N,TE}
end

Base.@kwdef struct PrecalculatedProblem{N,M,TA<:Real,TE<:Real,TT<:Real}
    P::ScaledProblem{N,TA,TE}
    tangents::NTuple{M,Tangent{TT}}
end

end

using Aqua
Aqua.test_unbound_args(Foo)

error

Unbound type parameters detected:
[1] Main.Foo.PrecalculatedProblem(P::Main.Foo.ScaledProblem{N, TA, TE}, tangents::NTuple{M, Main.Foo.Tangent{TT}}) where {N, M, TA<:Real, TE<:Real, TT<:Real} @ Main.Foo /tmp/tmp.jl:16
Test Failed at /home/tamas/.julia/packages/Aqua/epbUr/src/unbound_args.jl:37
  Expression: isempty(unbounds)
   Evaluated: isempty(Method[Main.Foo.PrecalculatedProblem(P::Main.Foo.ScaledProblem{N, TA, TE}, tangents::NTuple{M, Main.Foo.Tangent{TT}}) where {N, M, TA<:Real, TE<:Real, TT<:Real} @ Main.Foo /tmp/tmp.jl:16])

versions

Status `~/code/julia/NonhomotheticCES/test/Project.toml`
  [4c88cf16] Aqua v0.8.11
  [90137ffa] StaticArrays v1.9.12

julia> VERSION
v"1.11.3"
@lgoettgens lgoettgens added invalid This doesn't seem right test: unbound args labels Feb 26, 2025
@lgoettgens
Copy link
Collaborator

This is acutally not a false behavior on Aqua's side here.
If you call PrecalculatedProblem with some ScaledProblem{N, TA, TE} and tangents=() (an empty NTuple), then TT is not specified.

@tpapp
Copy link
Author

tpapp commented Mar 4, 2025

Thanks for the explanation, this makes sense and indeed it is not an Aqua issue so I am closing.

(if anyone runs into this while searching, I also found that I can refactor as

Base.@kwdef struct PrecalculatedProblem{N,M,TA<:Real,TE<:Real,TT<:NTuple{M}}
    P::ScaledProblem{N,TA,TE}
    tangents::TT
end

and this avoid the ambiguity yet keep the M as a type parameter.)

@tpapp tpapp closed this as completed Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right test: unbound args
Projects
None yet
Development

No branches or pull requests

2 participants