The function in your example has no type instability? It returns the concrete Float64? I see from your gist that getindex has a type instability but I don't think it is from coordlookup.
On Friday, September 18, 2015 at 10:31:53 AM UTC+2, 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,(Base.mul_float)((top(getfield))(r::FloatRange{Float64},:divisor)::Float64,x::Float64)::Any)::Float64,(top(getfield))(r::FloatRange{Float64},:start)::Float64)::Any)::Float64,(top(getfield))(r::FloatRange{Float64},:step)::Float64)::Any)::Float64,(Base.box)(Float64,(Base.sitofp)(Float64,1)::Any)::Float64)::Any)::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 > > >