Best practices to add more than one bound to type parameters

This doesn’t mean what you think it means, the lower bound just gets ignored AFAIK. Compare:

julia> T where {T>:Int}
Any

julia> Vector{T} where {T>:Int}
Vector{T} where T>:Int64 (alias for Array{T, 1} where T>:Int64)

To partially work around this, wrap the tuple within another struct:

const TwoOrThreeTuple{T} = Union{NTuple{2, T}, NTuple{3, T}}
struct W{P}
    p::P   
end
struct myT{T, N, NTuple{N, T}<:V<:TwoOrThreeTuple{T}}
    a::W{V}
end

This still fails at construction, but the static parameter matching of N succeeds, at least. Compare with @code_warntype. Also, I believe the reason it fails to match for V is a dispatch bug:

2 Likes