Unfortunately, I have not managed to create an MVE, but I think I can ask a good question:
I use a Ref to make a Float64 mutable within a struct. Using a mutable struct arguably makes more sense, and resolves my issue, I checked, but I want to learn. This part of a larger code
struct OUTstaticX{Tλ,Tλx}
Lλ :: Tλ
Lλx :: Tλx
α :: Ref{Float64}
end
...
out.α[] = min(out.α[],α)
run with Profile and examined with warntype_last() outputs
│ %26 = Base.getproperty(out, :α)::Ref{Float64} # the type is typeset in red!!!
│ %27 = Base.getindex(%26)::Any
where ::Ref{Float64} is typeset in red. This puzzles my neuron:
- I assume that
warntype_last()wraps@code_warntype, and that the later uses red to emphasize variables resolved to anabstracttype by the compiler. YetRef{Float64}is a concrete type. Under what conditions can my assumption be wrong? -
How can a
Ref{Float64}dereference toAny?
…and I am sure both surprises are related.