# Aqua: "Unbound type parameters detected" for parametric structures

**URL:** https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962
**Category:** Tooling
**Tags:** aqua
**Created:** [April 15, 2024, 1:21pm UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962 "2024-04-15T13:21:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)
#### Post date: [April 15, 2024, 1:21pm UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962/1 "2024-04-15T13:21:20Z")

</div>

Aqua.jl complains about the following code for the structure `StructBad`  
with the error `Unbound type parameters detected`. Is this a real problem in the code or a false positive of Aqua? The structures `StructOK2` and `StructOK3` are fine.

```julia
using Aqua
module mymod

struct StructBad{N,TC}
    field::NTuple{N,TC}
end

struct StructOK2{TC}
    field::NTuple{2,TC}
end

struct StructOK3{N}
    field::NTuple{N,Int}
end

end

Aqua.test_unbound_args(mymod)

```

The full error message is:

```julia
Unbound type parameters detected:
[1] Main.mymod.StructBad(field::Tuple{Vararg{TC, N}}) where {N, TC} @ Main.mymod ~/.julia/dev/CommonDataModel/test/test_aqua2.jl:5                                        
Test Failed at /home/abarth/.julia/packages/Aqua/tHrmY/src/unbound_args.jl:37
  Expression: isempty(unbounds)
   Evaluated: isempty(Method[Main.mymod.StructBad(field::Tuple{Vararg{TC, N}}) where {N, TC} @ Main.mymod ~/.julia/dev/CommonDataModel/test/test_aqua2.jl:5])

ERROR: LoadError: There was an error during testing
in expression starting at /home/abarth/.julia/dev/CommonDataModel/test/test_aqua2.jl:18

(v1.10) pkg> st Aqua
Status `/mnt/data1/abarth/.julia/environments/v1.10/Project.toml`
  [4c88cf16] Aqua v0.8.7

(v1.10) pkg> 

```

---

<div class="post-metadata">

### Author: ![lgoettgens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lgoettgens/32/203968_2.png) [@lgoettgens](https://discourse.julialang.org/u/lgoettgens)
#### Post date: [April 15, 2024, 1:29pm UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962/2 "2024-04-15T13:29:19Z")

</div>

The problem is that calling `StructBad(())` (the 0-length tuple as input), only fixes `N=0`, but the type parameter `TC` cannot be deduced by the input. Calling the above indeed errors in the REPL.

---

<div class="post-metadata">

### Author: ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)
#### Post date: [April 16, 2024, 6:30am UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962/3 "2024-04-16T06:30:41Z")

</div>

Thanks a lot! I use now the following definition which does not have this problem:

```julia
struct Struct{TC<:NTuple}
    field::TC
end

```

---

<div class="post-metadata">

### Author: ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)
#### Post date: [April 18, 2024, 8:38pm UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962/4 "2024-04-18T20:38:45Z")

</div>

> [@Alexander-Barth](#):
>
> ```julia
> struct StructOK2{TC}
> field::NTuple{2,TC}
> end
> 
> ```

This seems to work as well (I’m not sure if the use of `Union{}` here is really correct, but a zero-length NTuple can’t be inhabited, so I went with that instead of `Any`).

```julia
julia> struct StructOkN{N,TC}
           field::NTuple{N,TC}
       end

julia> StructOkN(::Tuple{}) = StructOkN{0,Union{}}(())
StructOkN

julia> StructOkN((1,2,3))
StructOkN{3, Int64}((1, 2, 3))

julia> StructOkN(())
StructOkN{0, Union{}}(())

```

---

<div class="post-metadata">

### Author: ![Alexander-Barth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexander-barth/32/3692_2.png) [@Alexander-Barth](https://discourse.julialang.org/u/Alexander-Barth)
#### Post date: [April 19, 2024, 8:33am UTC](https://discourse.julialang.org/t/aqua-unbound-type-parameters-detected-for-parametric-structures/112962/5 "2024-04-19T08:33:31Z")

</div>

Interesting! Thank you!
