julia> collect(range(蟺, stop=蟺, length=1))
ERROR: MethodError: no method matching Irrational{:蟺}(::Float64)
...
The problem seems to be that range(蟺, stop=蟺, length=1) isa LinRange{Irrational{:蟺}}
, which, when iterate
d, causes a call to T(::Float64)
with T===Irrational{:蟺}
in unsage_getindex
here:
https://github.com/JuliaLang/julia/blob/353e1296ae3927eef07a5476554fb641dd1a287c/base/range.jl#L689
Not sure what the correct fix would be
I'm not sure this needs to work.
Care to elaborate? collect(range(2蟺, stop=2蟺, length=1))
and collect(range(1, stop=1, length=1))
do work. Isn't the current behavior surprising?
EDIT: in other words, isn't this an instance of implementation details leaking over into the behavior of ranges?
2蟺
is a Float64, not an Irrational. Irrational
can't support all operations, and that's just a tradeoff we have accepted. I guess we could special-case the first element to return the start point instead of doing arithmetic, but it doesn't seem worth it just to allow 1-element ranges of Irrationals.
I see, thanks for the explanation! There seems to be a powerful consensus here, so closing.
Most helpful comment
I'm not sure this needs to work.