Tricky "too many parameters for type" error

Not quite correct; the info about A <: AbstractArray is not lost. Consider the following

julia> struct Foo{A} ; a::A ; end

julia> const Bar = Foo{A} where A <: AbstractArray  # note the where N where T is unnecessary
Foo{A} where A<:AbstractArray

julia> Bar{typeof([1])}([1])
Foo{Array{Int64,1}}([1])

julia> Bar{typeof(1)}(1)  # not an AbstractArray
ERROR: TypeError: in Type, in A, expected A<:AbstractArray, got Type{Int64}
Stacktrace:
 [1] top-level scope at none:0

julia> Foo{typeof(1)}(1)  # directly with Foo (doesn't have the subtyping relation imposed)
Foo{Int64}(1)

Note that AbstractArray{T,N} where N where T is equivalent to AbstractArray on its own.

1 Like