Closed
Description
Reading the documentation about conversion and promotion of 0.6.2, the isnan
line looked weird:
function convert(::Type{Rational{T}}, x::AbstractFloat, tol::Real) where T<:Integer
if isnan(x); return zero(T)//zero(T); end
The issue is multiple:
- in the actual source
convert
has been changed torationalize
. The doc could be updated, for clarity. - Trying that in julia 0.6.2 yields an error message that could be puzzling before looking at the source.
julia> rationalize(Int64, NaN, 1e-16)
ERROR: ArgumentError: invalid rational: zero(Int64)//zero(Int64)
Stacktrace:
[1] Rational{Int64}(::Int64, ::Int64) at ./rational.jl:13
[2] rationalize(::Type{Int64}, ::Float64, ::Float64) at ./rational.jl:131
What about replacing zero(T)//zero(T)
with something like throw(ArgumentError("received NaN, not allowed for integer-related types")
?
Here is the corresponding line in the repo:
Line 130 in c0e6b5b
This is not #25702.
Activity