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
#35483 introduced a new method for *(::Rational, ::Integer) which changed the return type of that operation. There was no specialized method for this before, so promotion was used.
I don't know if return types should be preserved in general, but for this particular case I would assume so, since, for this very reason, some computations that used to work now error:
Julia 1.0.5 (and probably up to 1.4.x)
julia>0x1*-1//1-1//1
Julia 1.5.0-beta1:
julia>0x1*-1//1
ERROR: InexactError:check_top_bit(UInt64, -1)
Stacktrace:
[1] throw_inexacterror(::Symbol, ::Type{UInt64}, ::Int64) at ./boot.jl:558
[2] check_top_bit at ./boot.jl:572 [inlined]
[3] toUInt64 at ./boot.jl:683 [inlined]
[4] UInt64 at ./boot.jl:713 [inlined]
[5] convert at ./number.jl:7 [inlined]
[6] _promote at ./promotion.jl:259 [inlined]
[7] promote at ./promotion.jl:282 [inlined]
[8] checked_mul at ./checked.jl:21 [inlined]
[9] *(::UInt8, ::Rational{Int64}) at /home/liozou/julia/base/rational.jl:318
[10] top-level scope at none:1
A solution consists in using promotions when doing binary operations: see PR #36279
#35483 introduced a new method for
*(::Rational, ::Integer)
which changed the return type of that operation. There was no specialized method for this before, so promotion was used.Julia 1.4.2:
Julia 1.5.0-beta1:
Should this return type be preserved between minor versions?
The text was updated successfully, but these errors were encountered: