You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation on current master (see below) claims to provide compatibility for overriding cld/fld, but actually doesn’t (at least in the case of HalfIntegers.jl, which is currently broken on master for this reason).
fld(x::T, y::T) where {T<:Real} =throw(MethodError(div, (x, y, RoundDown)))
cld(x::T, y::T) where {T<:Real} =throw(MethodError(div, (x, y, RoundUp)))
HalfIntegers.jl defines fld(x::T, y::T) where T<:HalfInteger. Due to the changes on master, this method isn’t called anymore when fld is called with two different types of HalfIntegers. In order for the above code to fulfill its purpose, the first two and last two methods above could be replaced with
fld(x::Real, y::Real) =fld(promote(x,y)...)
cld(x::Real, y::Real) =cld(promote(x,y)...)
fld(x::T, y::T) where {T<:Real} =div(x, y, RoundDown)
cld(x::T, y::T) where {T<:Real} =div(x, y, RoundUp)
The text was updated successfully, but these errors were encountered:
Yeah, this fallback doesn't work 100% of the time, but your suggestion doesn't work either, because it would cause dispatch loops due to the reverse fallbacks elsewhere in the code. This is the best I could come up with for the time being. Packages were quite inconsistent about how these methods were being overloaded. I'd recommend additionally defining fld(x::HalfInteger, y::HalfInteger) and the three-argument div method in your package.
The implementation on current master (see below) claims to provide compatibility for overriding
cld
/fld
, but actually doesn’t (at least in the case of HalfIntegers.jl, which is currently broken on master for this reason).julia/base/div.jl
Lines 223 to 233 in 8707744
HalfIntegers.jl defines
fld(x::T, y::T) where T<:HalfInteger
. Due to the changes on master, this method isn’t called anymore whenfld
is called with two different types ofHalfInteger
s. In order for the above code to fulfill its purpose, the first two and last two methods above could be replaced withThe text was updated successfully, but these errors were encountered: