IntervalSets.jl
IntervalSets.jl copied to clipboard
Conversion to complex should throw an error
The following behaviour is problematic:
julia> d = convert(AbstractInterval{ComplexF64}, 0..1)
0.0 + 0.0im..1.0 + 0.0im
julia> 0.5 in d
ERROR: MethodError: no method matching isless(::Complex{Float64}, ::Float64)
Closest candidates are:
isless(::Float64, ::Float64) at float.jl:459
isless(::Missing, ::Any) at missing.jl:66
isless(::AbstractFloat, ::AbstractFloat) at operators.jl:148
...
Stacktrace:
[1] <(::Complex{Float64}, ::Float64) at ./operators.jl:260
[2] <=(::Complex{Float64}, ::Float64) at ./operators.jl:309
[3] in(::Float64, ::Interval{:closed,:closed,Complex{Float64}}) at /Users/sheehanolver/.julia/packages/IntervalSets/xr34V/src/IntervalSets.jl:126
[4] top-level scope at none:0
Should we drop the following constructor, not just the conversion?
julia> d = (1)..(1+im)
1 + 0im..1 + 1im
julia> 1 in d
ERROR: MethodError: no method matching isless(::Complex{Int64}, ::Int64)
Closest candidates are:
isless(::AbstractFloat, ::Real) at ~/julia/julia-1.7.2/share/julia/base/operators.jl:186
isless(::Real, ::Real) at ~/julia/julia-1.7.2/share/julia/base/operators.jl:430
isless(::Any, ::Missing) at ~/julia/julia-1.7.2/share/julia/base/missing.jl:88
...
Stacktrace:
[1] <(x::Complex{Int64}, y::Int64)
@ Base ./operators.jl:352
[2] <=(x::Complex{Int64}, y::Int64)
@ Base ./operators.jl:401
[3] in(v::Int64, I::ClosedInterval{Complex{Int64}})
@ IntervalSets ~/.julia/dev/IntervalSets/src/IntervalSets.jl:120
[4] top-level scope
@ REPL[4]:1