Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatch bug? for convert(typeof(x), x) with x an Interval #32884

Closed
dpsanders opened this issue Aug 13, 2019 · 2 comments
Closed

Dispatch bug? for convert(typeof(x), x) with x an Interval #32884

dpsanders opened this issue Aug 13, 2019 · 2 comments

Comments

@dpsanders
Copy link
Contributor

dpsanders commented Aug 13, 2019

(v1.3) pkg> add IntervalArithmetic

julia> using IntervalArithmetic

julia> x = interval(3, 4)
[3, 4]

julia> T = typeof(x)
Interval{Float64}

julia> @which convert(T, x)
convert(::Type{Interval{T}}, x::Interval) where T in IntervalArithmetic at /Users/dpsanders/.julia/dev/IntervalArithmetic/src/intervals/conversion.jl:20

This should be calling the previous line instead, which defines the more specific (?) method

convert(::Type{Interval{T}}, x::Interval{T}) where {T}

See
https://github.com/JuliaIntervals/IntervalArithmetic.jl/blob/1516c5e1ca8e088aeafa9574072512aa2df241fb/src/intervals/conversion.jl#L19

Reported here: JuliaIntervals/IntervalArithmetic.jl#317

Fix here: JuliaIntervals/IntervalArithmetic.jl#320
which replaces convert(::Type{Interval{T}}, x::Interval) with convert(::Type{Interval{T}}, x::Interval{S}) where {T, S}

@JeffBezanson
Copy link
Member

Sorry about that. This is #6383 again. It's because the type parameter in Interval is restricted to Real, but in Interval{T} where T it's unrestricted.

@dpsanders
Copy link
Contributor Author

Ah I see, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants