I don't see any actual type-instability there. There are a few expressions annotated with a meaningless `Any` that @code_warntype fails to expunge from its output. In general when I see `((foo::Float64)::Any)` I just ignore it. It's more reliable to ask whether any of your variables are type-unstable, or whether the return type is unstable, or whether you see explicit Union types, or whether you see (foo::Any) (which _is_ a problem, whereas ((foo::Float64)::Any) is not).
Of course, improving @code_warntype itself would be a great contribution... --Tim On Friday, September 18, 2015 01:31:53 AM Tomas Lycken wrote: > I’m getting an odd type instability that I don’t understand the cause of, > as illustrated in this gist > <https://gist.github.com/tlycken/18db1ed677cd9074b8fe>. It seems that the > type instability comes from the coordlookup function, but I don't > understand why that wouldn't be type stable. Perhaps easiest illustrated > with a code sample: > > julia> foo(r::FloatRange, x) = (r.divisor * x - r.start) / r.step + > one(eltype(r)) # not the actual name, but exactly the actual body foo > (generic function with 1 method) > > julia> @code_warntype foo(2:2.1:10, 3.2) > Variables: > r::FloatRange{Float64} > x::Float64 > > Body: > begin # none, line 1: > return > (Base.box)(Base.Float64,(Base.add_float)((Base.box)(Base.Float64,(Base.div_ > float)((Base.box)(Base.Float64,(Base.sub_float)((Base.box)(Base.Float64,(Bas > e.mul_float)((top(getfield))(r::FloatRange{Float64},:divisor)::Float64,x::Fl > oat64)::Any)::Float64,(top(getfield))(r::FloatRange{Float64},:start)::Float6 > 4)::Any)::Float64,(top(getfield))(r::FloatRange{Float64},:step)::Float64)::A > ny)::Float64,(Base.box)(Float64,(Base.sitofp)(Float64,1)::Any)::Float64)::An > y)::Float64 end::Float64 > julia> versioninfo() > Julia Version 0.4.0-rc1 > Commit e5c6964 (2015-09-09 16:07 UTC) > Platform Info: > System: Windows (x86_64-w64-mingw32) > CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz > WORD_SIZE: 64 > BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell) > LAPACK: libopenblas > LIBM: libopenlibm > LLVM: libLLVM-3.3 > >
