It's not actually type-unstable. Note that the "::Any" annotation is on GetfieldNode(Base.Math,:sqrt_llvm), i.e., the lookup of the :sqrt_llvm symbol inside Base.Math.
Any PRs helping to improve the logic of code_warntype are appreciated. --Tim On Friday, February 20, 2015 01:00:07 PM Mauro wrote: > This might be something wrong in @code_warntype as @code_llvm and > @code_native give the same output. > > On Fri, 2015-02-20 at 12:20, Kristoffer Carlsson <[email protected]> wrote: > > I had a type instability in my program and I condensed it down to this > > minimal working example. > > > > Why is sqrt2 here unstable? The variable a should be inferred to always be > > a Float64 and then the function should be stable just like the normal > > sqrt function is? > > > > > > julia> function sqrt2(a::Float64) > > > > return sqrt(a) > > end > > > > sqrt2 (generic function with 1 method) > > > > > > > > julia> @code_warntype sqrt2(5.0) > > > > Variables: > > a::Float64 > > > > Body: > > begin # none, line 2: > > return > > (GetfieldNode(Base.Math,:box,Any))(Float64,(GetfieldNode(Base.Math > > > > ,:sqrt_llvm,Any))(a::Float64)::Any)::Float64 > > > > end::Float64 > > > > julia> @code_warntype sqrt(5.0) > > > > Variables: > > x::Float64 > > > > Body: > > begin # math.jl, line 130: > > return box(Float64,sqrt_llvm(x::Float64)) > > > > end::Float64 > > > > Best regards, > > Kristoffer Carlsson
