Overloading zeros

I find the error message here unclear, it seems to me that the zeros for this new type is clearly defined. What is going on here? Is there any reason not to define new methods to zeros explicitly?

julia> struct A
           n::Int
           x::Vector{Float64}
       end

julia> Base.zeros(::A, n) = A(0, zeros(n))

julia> zeros(A, 3)
ERROR: MethodError: no method matching zero(::Type{A})

It should be

Base.zeros(::Type{A}, n) = A(0, zeros(n))

The former expects an instance of A and the latter expects the type.

4 Likes

Thanks, forgot about that.