Type Instability with AbstractArray

Don’t use abstract types for struct fields, as explained in the manual. If you want to support any type of AbstractArray here, then you can do:

mutable struct mystate{Tq,Tv<:AbstractVector{Tq}}
    x::Tv
end

or simply

mutable struct mystate{Tv<:AbstractVector}
    x::Tv
end

(AbstractVector{T} is just a convenient synonym for AbstractArray{T,1}.)

3 Likes