MethodError: reduce_empty is ambiguous

(Julia 1.2.0)

I have a function which generates a list of integer lists, some of which might be empty. For example
L = [Int, [1]], so L is a 2-element Array{Array{Int64,1},1}.

This is how I want things to work. In reality, this happens: The function returns an

Array{T,1} where T[Union{}[], [1]]

and as a result summing the parts of L (which is expected to give [0, 1]) fails with a MethodError:

reduce_empty(::typeof(Base.add_sum), ::Type{Union{ }}) is ambiguous.

What I need is the compiler to recognize that the parts of L are of type Array{Int64,1} and not of
T[Union{}, [1]].

What is the probable cause and cure for this ambiguity?

can you post an example array to work with or the function that generates one of those arrays?

1 Like