Shouldnβt Julia be able to infer that the return type is Vector{Float64} in the example below? prevx is initialized to a Float64 value and randn() returns a Float64 value.
julia> function gen1(n)
prevx = 0.0
map(1:n) do _
x = randn()
r = prevx + x
prevx = x
r
end
end
gen1 (generic function with 1 method)
julia> @code_warntype gen1(10)
MethodInstance for gen1(::Int64)
from gen1(n) in Main at REPL[44]:1
Arguments
#self#::Core.Const(gen1)
n::Int64
Locals
#25::var"#25#26"
prevx::Core.Box
Body::Vector
1 β (prevx = Core.Box())
β Core.setfield!(prevx, :contents, 0.0)
β (#25 = %new(Main.:(var"#25#26"), prevx))
β %4 = #25::var"#25#26"
β %5 = (1:n)::Core.PartialStruct(UnitRange{Int64}, Any[Core.Const(1), Int64])
β %6 = Main.map(%4, %5)::Vector
βββ return %6