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
irrationals: restrict assume effects annotations to known types (#55886)
Other changes:
* replace `:total` with the less powerful `:foldable`
* add an `<:Integer` dispatch constraint on the `rationalize` method,
closes#55872
* replace `Rational{<:Integer}` with just `Rational`, they're equal
Other issues, related to `BigFloat` precision, are still present in
irrationals.jl, to be fixed by followup PRs, including #55853.
Fixes#55874
Complex{T}(x::AbstractIrrational) where {T<:Real} =Complex{T}(T(x))
53
53
54
-
#XXX this may change `DEFAULT_PRECISION`, thus not effect free
55
-
@assume_effects:totalfunctionRational{T}(x::AbstractIrrational) where T<:Integer
54
+
function_irrational_to_rational(::Type{T}, x::AbstractIrrational) where T<:Integer
56
55
o =precision(BigFloat)
57
56
p =256
58
57
whiletrue
@@ -66,13 +65,16 @@ Complex{T}(x::AbstractIrrational) where {T<:Real} = Complex{T}(T(x))
66
65
p +=32
67
66
end
68
67
end
69
-
Rational{BigInt}(x::AbstractIrrational) =throw(ArgumentError("Cannot convert an AbstractIrrational to a Rational{BigInt}: use rationalize(BigInt, x) instead"))
68
+
Rational{T}(x::AbstractIrrational) where {T<:Integer} =_irrational_to_rational(T, x)
69
+
_throw_argument_error_irrational_to_rational_bigint() =throw(ArgumentError("Cannot convert an AbstractIrrational to a Rational{BigInt}: use rationalize(BigInt, x) instead"))
0 commit comments