I’m getting some behavior that seems suspiciously like #265, but of course that cannot be.
Basically I’m calling a function, then defining a new method that should catch it, then calling it again, and my new method isn’t being called. Interestingly @which
shows my new method.
MWE:
julia> using FixedPointNumbers
julia> reinterpret(Fixed{Int16, 15}, 0xf123)
ERROR: bitcast: target type not a leaf primitive type
Stacktrace:
[1] reinterpret(::Type{FixedPointNumbers.Fixed{Int16,15}}, ::UInt16) at ./essentials.jl:155
julia> function Base.reinterpret(::Type{Fixed{T,f}}, x::Unsigned) where {T <: Signed,f}
reinterpret(Fixed{T, f}, reinterpret(T, x))
end
julia> reinterpret(Fixed{Int16, 15}, 0xf123)
ERROR: bitcast: target type not a leaf primitive type
Stacktrace:
[1] reinterpret(::Type{FixedPointNumbers.Fixed{Int16,15}}, ::UInt16) at ./essentials.jl:155
julia> @which reinterpret(Fixed{Int16, 15}, 0xf123)
reinterpret(::Type{FixedPointNumbers.Fixed{T,f}}, x::Unsigned) where {T<:Signed, f} in Main at REPL[3]:2
You can see below that if I define my method before I call it, it’s OK:
julia> using FixedPointNumbers
julia> function Base.reinterpret(::Type{Fixed{T,f}}, x::Unsigned) where {T <: Signed,f}
reinterpret(Fixed{T, f}, reinterpret(T, x))
end
julia> reinterpret(Fixed{Int16, 15}, 0xf123)
-0.11612Q0f15
Any clues what’s going on?