Could anybody please help me improve my understanding of what looks like strange behavior?
function good1(x::Array{T,1}) where T<:Float64
n = length(x)
x *= 1 # problem is not here
[i for i in x]
end
function good2(x::Array{T,1}) where T<:Float64
n = length(x)
[x[i] for i in 1:n] # problem is not here
end
function wrong(x::Array{T,1}) where T<:Float64
n = length(x)
x *= 1
[x[i] for i in 1:n]
end
@code_warntype good1([0.])
@code_warntype good2([0.])
@code_warntype wrong([0.]) # also n is interpreted as Any here!