<p dir="auto">I find it desirable that in <code class="notranslate">map(f, T[])</code>, if <code class="notranslate">f</code> is type stable on <code class="notranslate">T</code>, then <code class="notranslate">map</code> would return an empty array of the correct type. At the moment it returns an empty array of type <code class="notranslate">T</code>.</p>
<p dir="auto">I ran into this when trying to do roughly this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="function f(x::Vector)
    y = map(symbol, x)
    return f(y)
end

function f(x::Vector{Symbol})
    # Do fun.
end"><pre class="notranslate"><code class="notranslate">function f(x::Vector)
    y = map(symbol, x)
    return f(y)
end

function f(x::Vector{Symbol})
    # Do fun.
end
</code></pre></div>
<p dir="auto">I've simplified this as much as possible from my use case:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; func1{U&lt;:AbstractArray, V}(arg::Union{AbstractArray{U},V}) = typeof(arg)
func1 (generic function with 1 method)

julia&gt; func1(Array{Any}[Array{Any}(1, 1)])
Array{Array{Any,N},1}

julia&gt; func2{U&lt;:AbstractArray, V}(arg::Union{AbstractArray{U},Set{V}}) = typeof(arg)
func2 (generic function with 1 method)

julia&gt; func2(Array{Any}[Array{Any}(1, 1)])
ERROR: MethodError: `func2` has no method matching func2(::Array{Array{Any,N},1})
Closest candidates are:
  func2{U&lt;:AbstractArray{T,N},V}(::Union{AbstractArray{U&lt;:AbstractArray{T,N},N},Set{V}})"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">func1</span><span class="pl-c1">{U&lt;:AbstractArray, V}</span>(arg<span class="pl-k">::</span><span class="pl-c1">Union{AbstractArray{U},V}</span>) <span class="pl-k">=</span> <span class="pl-c1">typeof</span>(arg)
func1 (generic <span class="pl-k">function</span> with <span class="pl-c1">1</span> method)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">func1</span>(Array{Any}[<span class="pl-c1">Array</span><span class="pl-c1">{Any}</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>)])
Array{Array{Any,N},<span class="pl-c1">1</span>}

julia<span class="pl-k">&gt;</span> <span class="pl-en">func2</span><span class="pl-c1">{U&lt;:AbstractArray, V}</span>(arg<span class="pl-k">::</span><span class="pl-c1">Union{AbstractArray{U},Set{V}}</span>) <span class="pl-k">=</span> <span class="pl-c1">typeof</span>(arg)
func2 (generic <span class="pl-k">function</span> with <span class="pl-c1">1</span> method)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">func2</span>(Array{Any}[<span class="pl-c1">Array</span><span class="pl-c1">{Any}</span>(<span class="pl-c1">1</span>, <span class="pl-c1">1</span>)])
ERROR<span class="pl-k">:</span> MethodError<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">`</span>func2<span class="pl-pds">`</span></span> has no method matching <span class="pl-c1">func2</span>(<span class="pl-k">::</span><span class="pl-c1">Array{Array{Any,N},1}</span>)
Closest candidates are<span class="pl-k">:</span>
  <span class="pl-c1">func2</span><span class="pl-c1">{U&lt;:AbstractArray{T,N},V}</span>(<span class="pl-k">::</span><span class="pl-c1">Union{AbstractArray{U&lt;:AbstractArray{T,N},N},Set{V}}</span>)</pre></div>
<p dir="auto">Surely both of these should work as they're both satisfying one component of the union?</p>